From b240a3fad9d0147aeb287a1ee74238558081a2ec Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 27 Feb 2012 13:22:38 +0100 Subject: [PATCH] add unit tests for analyzePatter/factorize API --- test/sparse_solver.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/sparse_solver.h b/test/sparse_solver.h index 1a5483050..d6c111362 100644 --- a/test/sparse_solver.h +++ b/test/sparse_solver.h @@ -46,10 +46,30 @@ void check_sparse_solving(Solver& solver, const typename Solver::MatrixType& A, x = solver.solve(b); if (solver.info() != Success) { - std::cerr << "sparse SPD: solving failed\n"; + std::cerr << "sparse solver testing: solving failed\n"; return; } - VERIFY(oldb.isApprox(b) && "sparse SPD: the rhs should not be modified!"); + VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); + + VERIFY(x.isApprox(refX,test_precision())); + + 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())); }