LanczosSolver solver = new LanczosSolver();
LanczosState state = new LanczosState(m, size, desiredRank, initialVector);
// set initial vector?
solver.solve(state, desiredRank, true);
EigenvalueDecomposition decomposition = new EigenvalueDecomposition(m);
DoubleMatrix1D eigenvalues = decomposition.getRealEigenvalues();
float fractionOfEigensExpectedGood = 0.6f;
for(int i = 0; i < fractionOfEigensExpectedGood * desiredRank; i++) {
double s = state.getSingularValue(desiredRank - i - 1);
double e = eigenvalues.get(eigenvalues.size() - i - 1);
log.info(i + " : L = {}, E = {}", s, e);
assertTrue("Singular value differs from eigenvalue", Math.abs((s-e)/e) < ERROR_TOLERANCE);
Vector v = state.getRightSingularVector(i);
Vector v2 = decomposition.getV().viewColumn(eigenvalues.size() - i - 1).toVector();
double error = 1 - Math.abs(v.dot(v2)/(v.norm(2) * v2.norm(2)));
log.info("error: {}", error);
assertTrue(i + ": 1 - cosAngle = " + error, error < ERROR_TOLERANCE);
}
}