Exemplo n.º 1
0
  /** Babai's algorithm should work perfectly for Zn. This tests that it does. */
  @Test
  public void returnsCorrectForZn() {
    System.out.println("returnsCorrectForZn");
    double[] y = {1.1, 2.2, 3.9, -4.1, -100.49};
    Babai babai = new Babai();
    // construc the integer lattice
    Zn lattice = new Zn(y.length);

    babai.setLattice(lattice);

    lattice.nearestPoint(y);
    double[] xtrue = lattice.getLatticePoint();
    double[] utrue = lattice.getIndex();

    babai.nearestPoint(y);
    double[] xtest = babai.getLatticePoint();
    double[] utest = babai.getIndex();

    System.out.println(VectorFunctions.print(xtrue));
    System.out.println(VectorFunctions.print(xtest));

    assertTrue(VectorFunctions.distance_between(utest, utrue) < 0.00001);
    assertTrue(VectorFunctions.distance_between(xtest, xtrue) < 0.00001);
    assertTrue(VectorFunctions.distance_between(utest, xtrue) < 0.00001);
    assertTrue(VectorFunctions.distance_between(xtest, utrue) < 0.00001);
  }
  /** Test of generateReceivedSignal method, of class simulator.qam.FadingNoisyQAM. */
  public void testGenerateReceivedSignal() {
    System.out.println("generateReceivedSignal");

    FadingNoisyQAM instance = new FadingNoisyQAM();
    double[] xr = {1.0, 2.0, -2.0};
    double[] xi = {1.0, -3.0, 1.0};
    instance.setChannel(-0.4326, -1.6656);

    RealRandomVariable noise = new pubsim.distributions.UniformNoise(0.0, 0.0);
    instance.setNoiseGenerator(noise);

    instance.setTransmittedSignal(xr, xi);

    double[] expr = {1.2330, -5.8620, 2.5308};
    double[] expi = {-2.0982, -2.0334, 2.8986};
    instance.generateReceivedSignal();

    System.out.println(VectorFunctions.print(instance.getInphase()));
    System.out.println(VectorFunctions.print(instance.getQuadrature()));

    assertEquals(true, VectorFunctions.distance_between(expr, instance.getInphase()) < 0.00001);
    assertEquals(true, VectorFunctions.distance_between(expi, instance.getQuadrature()) < 0.00001);
  }