/** Test a column matrix. */ @Test public void testSmallDeviations() { System.out.println("testSmallDeviations"); // run nearest point test by making small deviations (del) to lattice points. int iters = 10; Random r = new Random(); double del = 0.0001; for (int t = 0; t < iters; t++) { int n = r.nextInt(10) + 5; LatticeAndNearestPointAlgorithm lattice = new AnstarSorted(n - 1); Matrix G = lattice.getGeneratorMatrix(); Babai babai = new Babai(); babai.setLattice(lattice); // System.out.println("G is " + G.getRowDimension() + " by " + G.getColumnDimension()); double[] x = new double[G.getRowDimension()]; double[] xdel = new double[G.getRowDimension()]; double[] u = VectorFunctions.randomIntegerVector(n, 1000); // System.out.println("u is length " + u.length + ", x is length" + x.length); VectorFunctions.matrixMultVector(G, u, x); for (int i = 0; i < x.length; i++) { xdel[i] = x[i] + r.nextGaussian() * del; } babai.nearestPoint(xdel); double dist = VectorFunctions.distance_between(babai.getLatticePoint(), x); System.out.println(dist); assertEquals(true, dist < 0.00001); } }