From fbcfc2f86225891dd21ccdefa4a01b7f9409a992 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 4 Jul 2016 17:19:38 +0200 Subject: Add unit test for solveWithGuess, and fix template resolution. --- test/sparse_solver.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/sparse_solver.h') diff --git a/test/sparse_solver.h b/test/sparse_solver.h index b67653496..8cf35bef7 100644 --- a/test/sparse_solver.h +++ b/test/sparse_solver.h @@ -11,6 +11,21 @@ #include #include +template +void solve_with_guess(IterativeSolverBase& solver, const MatrixBase& b, const Guess& g, Result &x) { + x = solver.derived().solveWithGuess(b.derived(),g); +} + +template +void solve_with_guess(SparseSolverBase& solver, const MatrixBase& b, const Guess& , Result& x) { + x = solver.derived().solve(b); +} + +template +void solve_with_guess(SparseSolverBase& solver, const SparseMatrixBase& b, const Guess& , Result& x) { + x = solver.derived().solve(b); +} + template void check_sparse_solving(Solver& solver, const typename Solver::MatrixType& A, const Rhs& b, const DenseMat& dA, const DenseRhs& db) { @@ -37,6 +52,12 @@ void check_sparse_solving(Solver& solver, const typename Solver::MatrixType& A, } VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); VERIFY(x.isApprox(refX,test_precision())); + + x.setZero(); + solve_with_guess(solver, b, x, x); + VERIFY(solver.info() == Success && "solving failed when using analyzePattern/factorize API"); + 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 -- cgit v1.2.3