void run_test(const Matrix &mat, int k, int m) { DenseGenMatProd<double> op(mat); GenEigsSolver<double, SelectionRule, DenseGenMatProd<double>> eigs(&op, k, m); eigs.init(); int nconv = eigs.compute(); int niter = eigs.num_iterations(); int nops = eigs.num_operations(); REQUIRE( nconv > 0 ); ComplexVector evals = eigs.eigenvalues(); ComplexMatrix evecs = eigs.eigenvectors(); ComplexMatrix err = mat * evecs - evecs * evals.asDiagonal(); INFO( "nconv = " << nconv ); INFO( "niter = " << niter ); INFO( "nops = " << nops ); INFO( "||AU - UD||_inf = " << err.array().abs().maxCoeff() ); REQUIRE( err.array().abs().maxCoeff() == Approx(0.0) ); }
void run_test(const MatType& mat, int k, int m, double sigma, bool allow_fail = false) { typename OpTypeTrait<MatType>::OpType op(mat); GenEigsRealShiftSolver<double, SelectionRule, typename OpTypeTrait<MatType>::OpType> eigs(&op, k, m, sigma); eigs.init(); int nconv = eigs.compute(); int niter = eigs.num_iterations(); int nops = eigs.num_operations(); if(allow_fail) { if( eigs.info() != SUCCESSFUL ) { WARN( "FAILED on this test" ); std::cout << "nconv = " << nconv << std::endl; std::cout << "niter = " << niter << std::endl; std::cout << "nops = " << nops << std::endl; return; } } else { INFO( "nconv = " << nconv ); INFO( "niter = " << niter ); INFO( "nops = " << nops ); REQUIRE( eigs.info() == SUCCESSFUL ); } ComplexVector evals = eigs.eigenvalues(); ComplexMatrix evecs = eigs.eigenvectors(); ComplexMatrix resid = mat * evecs - evecs * evals.asDiagonal(); const double err = resid.array().abs().maxCoeff(); INFO( "||AU - UD||_inf = " << err ); REQUIRE( err == Approx(0.0) ); }