AlternatingLeastSquaresSolver { Matrix addLambdaTimesNuiTimesE(Matrix matrix, double lambda, int nui) { Preconditions.checkArgument(matrix.numCols() == matrix.numRows()); for (int n = 0; n < matrix.numCols(); n++) { matrix.setQuick(n, n, matrix.getQuick(n, n) + lambda * nui); } return matrix; }  Vector solve(Iterable<Vector> featureVectors, Vector ratingVector, double lambda, int numFeatures);  }
@Test public void addLambdaTimesNuiTimesE() { int nui = 5; double lambda = 0.2; Matrix matrix = new SparseMatrix(5, 5); solver.addLambdaTimesNuiTimesE(matrix, lambda, nui); for (int n = 0; n < 5; n++) { assertEquals(1.0, matrix.getQuick(n, n), EPSILON); } }