AlternatingLeastSquaresSolver { static Matrix createMiIi(Iterable<Vector> featureVectors, int numFeatures) { double[][] MiIi = new double[numFeatures][Iterables.size(featureVectors)]; int n = 0; for (Vector featureVector : featureVectors) { for (int m = 0; m < numFeatures; m++) { MiIi[m][n] = featureVector.getQuick(m); } n++; } return new DenseMatrix(MiIi, true); } private  AlternatingLeastSquaresSolver(); static Vector solve(Iterable<Vector> featureVectors, Vector ratingVector, double lambda, int numFeatures);  }
@Test public void createMiIi() { Vector f1 = new DenseVector(new double[] { 1, 2, 3 }); Vector f2 = new DenseVector(new double[] { 4, 5, 6 }); Matrix miIi = AlternatingLeastSquaresSolver.createMiIi(Arrays.asList(f1, f2), 3); assertEquals(1.0, miIi.getQuick(0, 0), EPSILON); assertEquals(2.0, miIi.getQuick(1, 0), EPSILON); assertEquals(3.0, miIi.getQuick(2, 0), EPSILON); assertEquals(4.0, miIi.getQuick(0, 1), EPSILON); assertEquals(5.0, miIi.getQuick(1, 1), EPSILON); assertEquals(6.0, miIi.getQuick(2, 1), EPSILON); }