diff --git a/unsupported/test/sparse_ldlt.cpp b/unsupported/test/sparse_ldlt.cpp index 07666273c..4ceda3188 100644 --- a/unsupported/test/sparse_ldlt.cpp +++ b/unsupported/test/sparse_ldlt.cpp @@ -57,10 +57,27 @@ template void sparse_ldlt(int rows, int cols) else std::cerr << "warning LDLT failed\n"; -// VERIFY_IS_APPROX(refMat2.template selfadjointView() * x, b); + VERIFY_IS_APPROX(refMat3.template selfadjointView() * x, b); VERIFY(refX.isApprox(x,test_precision()) && "LDLT: default"); - +#ifdef EIGEN_CHOLMOD_SUPPORT + { + x = b; + SparseLDLT ldlt2(m3); + if (ldlt2.succeeded()) + { + ldlt2.solveInPlace(x); + VERIFY_IS_APPROX(refMat3.template selfadjointView() * x, b); + VERIFY(refX.isApprox(x,test_precision()) && "LDLT: cholmod solveInPlace"); + + x = ldlt2.solve(b); + VERIFY_IS_APPROX(refMat3.template selfadjointView() * x, b); + VERIFY(refX.isApprox(x,test_precision()) && "LDLT: cholmod solve"); + } + else + std::cerr << "warning LDLT failed\n"; + } +#endif // new Simplicial LLT @@ -144,28 +161,7 @@ template void sparse_ldlt(int rows, int cols) // VERIFY_IS_APPROX(refMat2.template selfadjointView() * x, b); // VERIFY(refX.isApprox(x,test_precision()) && "LDLT: default"); -#ifdef EIGEN_CHOLMOD_SUPPORT -// x = b; -// SparseLDLT ldlt2(m2); -// if (ldlt2.succeeded()) -// ldlt2.solveInPlace(x); -// else -// std::cerr << "warning LDLT failed\n"; -// -// VERIFY_IS_APPROX(refMat2.template selfadjointView() * x, b); -// VERIFY(refX.isApprox(x,test_precision()) && "LDLT: cholmod solveInPlace"); -// -// -// SparseLDLT ldlt3(m2); -// if (ldlt3.succeeded()) -// x = ldlt3.solve(b); -// else -// std::cerr << "warning LDLT failed\n"; -// -// VERIFY_IS_APPROX(refMat2.template selfadjointView() * x, b); -// VERIFY(refX.isApprox(x,test_precision()) && "LDLT: cholmod solve"); -#endif } void test_sparse_ldlt() diff --git a/unsupported/test/sparse_lu.cpp b/unsupported/test/sparse_lu.cpp index c1e50d272..188d291cc 100644 --- a/unsupported/test/sparse_lu.cpp +++ b/unsupported/test/sparse_lu.cpp @@ -44,7 +44,6 @@ template void sparse_lu(int rows, int cols) std::vector zeroCoords; std::vector nonzeroCoords; - static int count = 0; SparseMatrix m2(rows, cols); DenseMatrix refMat2(rows, cols); @@ -61,6 +60,21 @@ template void sparse_lu(int rows, int cols) x.setZero(); // // SparseLU > (m2).solve(b,&x); // // VERIFY(refX.isApprox(x,test_precision()) && "LU: default"); + + #ifdef EIGEN_UMFPACK_SUPPORT + { + // check solve + x.setZero(); + SparseLU,UmfPack> lu(m2); + VERIFY(lu.succeeded() && "umfpack LU decomposition failed"); + VERIFY(lu.solve(b,&x) && "umfpack LU solving failed"); + VERIFY(refX.isApprox(x,test_precision()) && "LU: umfpack"); + VERIFY_IS_APPROX(refDet,lu.determinant()); + // TODO check the extracted data + //std::cerr << slu.matrixL() << "\n"; + } + #endif + #ifdef EIGEN_SUPERLU_SUPPORT { x.setZero(); @@ -85,24 +99,7 @@ template void sparse_lu(int rows, int cols) } } #endif - #ifdef EIGEN_UMFPACK_SUPPORT -// { -// // check solve -// x.setZero(); -// SparseLU,UmfPack> slu(m2); -// if (slu.succeeded()) { -// if (slu.solve(b,&x)) { -// if (count==0) { -// VERIFY(refX.isApprox(x,test_precision()) && "LU: umfpack"); // FIXME solve is not very stable for complex -// } -// } -// VERIFY_IS_APPROX(refDet,slu.determinant()); -// // TODO check the extracted data -// //std::cerr << slu.matrixL() << "\n"; -// } -// } - #endif - count++; + } void test_sparse_lu()