diff options
Diffstat (limited to 'test/sparse_solver.h')
-rw-r--r-- | test/sparse_solver.h | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/test/sparse_solver.h b/test/sparse_solver.h index 645a965bb..d84aff070 100644 --- a/test/sparse_solver.h +++ b/test/sparse_solver.h @@ -17,53 +17,54 @@ void check_sparse_solving(Solver& solver, const typename Solver::MatrixType& A, typedef typename Mat::Scalar Scalar; DenseRhs refX = dA.lu().solve(db); + { + Rhs x(b.rows(), b.cols()); + Rhs oldb = b; - Rhs x(b.rows(), b.cols()); - Rhs oldb = b; + solver.compute(A); + if (solver.info() != Success) + { + std::cerr << "sparse solver testing: factorization failed (check_sparse_solving)\n"; + exit(0); + return; + } + x = solver.solve(b); + if (solver.info() != Success) + { + std::cerr << "sparse solver testing: solving failed\n"; + return; + } + VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); - solver.compute(A); - if (solver.info() != Success) - { - std::cerr << "sparse solver testing: factorization failed (check_sparse_solving)\n"; - exit(0); - return; - } - x = solver.solve(b); - if (solver.info() != Success) - { - std::cerr << "sparse solver testing: solving failed\n"; - return; - } - VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x.isApprox(refX,test_precision<Scalar>())); + x.setZero(); + // test the analyze/factorize API + solver.analyzePattern(A); + solver.factorize(A); + if (solver.info() != Success) + { + std::cerr << "sparse solver testing: factorization failed (check_sparse_solving)\n"; + exit(0); + return; + } + x = solver.solve(b); + if (solver.info() != Success) + { + std::cerr << "sparse solver testing: solving failed\n"; + return; + } + VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); - VERIFY(x.isApprox(refX,test_precision<Scalar>())); - x.setZero(); - // test the analyze/factorize API - solver.analyzePattern(A); - solver.factorize(A); - if (solver.info() != Success) - { - std::cerr << "sparse solver testing: factorization failed (check_sparse_solving)\n"; - exit(0); - return; - } - x = solver.solve(b); - if (solver.info() != Success) - { - std::cerr << "sparse solver testing: solving failed\n"; - return; + VERIFY(x.isApprox(refX,test_precision<Scalar>())); } - VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); - - VERIFY(x.isApprox(refX,test_precision<Scalar>())); - // test Block as the result and rhs: + // test dense Block as the result and rhs: { DenseRhs x(db.rows(), db.cols()); - DenseRhs b(db), oldb(db); + DenseRhs oldb(db); x.setZero(); - x.block(0,0,x.rows(),x.cols()) = solver.solve(b.block(0,0,b.rows(),b.cols())); - VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); + x.block(0,0,x.rows(),x.cols()) = solver.solve(db.block(0,0,db.rows(),db.cols())); + VERIFY(oldb.isApprox(db) && "sparse solver testing: the rhs should not be modified!"); VERIFY(x.isApprox(refX,test_precision<Scalar>())); } } |