From ece48a645051a9984a78a3197027c9c861a0c702 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 18 Jun 2010 11:28:30 +0200 Subject: split the Sparse module into multiple ones, and move non stable parts to unsupported/ (see the ML for details) --- test/sparse_solvers.cpp | 135 +----------------------------------------------- 1 file changed, 1 insertion(+), 134 deletions(-) (limited to 'test/sparse_solvers.cpp') diff --git a/test/sparse_solvers.cpp b/test/sparse_solvers.cpp index 9d30af146..30ee72af0 100644 --- a/test/sparse_solvers.cpp +++ b/test/sparse_solvers.cpp @@ -1,7 +1,7 @@ // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // -// Copyright (C) 2008 Daniel Gomez Ferro +// Copyright (C) 2008-2010 Gael Guennebaud // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -105,139 +105,6 @@ template void sparse_solvers(int rows, int cols) VERIFY_IS_APPROX(refMat2.template triangularView().solve(vec2), m2.template triangularView().solve(vec3)); } - - // test LLT - { - // TODO fix the issue with complex (see SparseLLT::solveInPlace) - SparseMatrix m2(rows, cols); - DenseMatrix refMat2(rows, cols); - - DenseVector b = DenseVector::Random(cols); - DenseVector refX(cols), x(cols); - - initSparse(density, refMat2, m2, ForceNonZeroDiag|MakeLowerTriangular, 0, 0); - for(int i=0; i().llt().solve(b); - if (!NumTraits::IsComplex) - { - x = b; - SparseLLT > (m2).solveInPlace(x); - VERIFY(refX.isApprox(x,test_precision()) && "LLT: default"); - } - #ifdef EIGEN_CHOLMOD_SUPPORT - x = b; - SparseLLT ,Cholmod>(m2).solveInPlace(x); - VERIFY(refX.isApprox(x,test_precision()) && "LLT: cholmod"); - #endif - - #ifdef EIGEN_TAUCS_SUPPORT - // TODO fix TAUCS with complexes - if (!NumTraits::IsComplex) - { - x = b; -// SparseLLT ,Taucs>(m2,IncompleteFactorization).solveInPlace(x); -// VERIFY(refX.isApprox(x,test_precision()) && "LLT: taucs (IncompleteFactorization)"); - - x = b; - SparseLLT ,Taucs>(m2,SupernodalMultifrontal).solveInPlace(x); - VERIFY(refX.isApprox(x,test_precision()) && "LLT: taucs (SupernodalMultifrontal)"); - x = b; - SparseLLT ,Taucs>(m2,SupernodalLeftLooking).solveInPlace(x); - VERIFY(refX.isApprox(x,test_precision()) && "LLT: taucs (SupernodalLeftLooking)"); - } - #endif - } - - // test LDLT - { - SparseMatrix m2(rows, cols); - DenseMatrix refMat2(rows, cols); - - DenseVector b = DenseVector::Random(cols); - DenseVector refX(cols), x(cols); - - initSparse(density, refMat2, m2, ForceNonZeroDiag|MakeUpperTriangular, 0, 0); - for(int i=0; i().ldlt().solve(b); - typedef SparseMatrix SparseSelfAdjointMatrix; - x = b; - SparseLDLT ldlt(m2); - if (ldlt.succeeded()) - ldlt.solveInPlace(x); - else - std::cerr << "warning LDLT failed\n"; - - VERIFY_IS_APPROX(refMat2.template selfadjointView() * x, b); - VERIFY(refX.isApprox(x,test_precision()) && "LDLT: default"); - } - - // test LU - { - static int count = 0; - SparseMatrix m2(rows, cols); - DenseMatrix refMat2(rows, cols); - - DenseVector b = DenseVector::Random(cols); - DenseVector refX(cols), x(cols); - - initSparse(density, refMat2, m2, ForceNonZeroDiag, &zeroCoords, &nonzeroCoords); - - FullPivLU refLu(refMat2); - refX = refLu.solve(b); - #if defined(EIGEN_SUPERLU_SUPPORT) || defined(EIGEN_UMFPACK_SUPPORT) - Scalar refDet = refLu.determinant(); - #endif - x.setZero(); - // // SparseLU > (m2).solve(b,&x); - // // VERIFY(refX.isApprox(x,test_precision()) && "LU: default"); - #ifdef EIGEN_SUPERLU_SUPPORT - { - x.setZero(); - SparseLU,SuperLU> slu(m2); - if (slu.succeeded()) - { - if (slu.solve(b,&x)) { - VERIFY(refX.isApprox(x,test_precision()) && "LU: SuperLU"); - } - // std::cerr << refDet << " == " << slu.determinant() << "\n"; - if (slu.solve(b, &x, SvTranspose)) { - VERIFY(b.isApprox(m2.transpose() * x, test_precision())); - } - - if (slu.solve(b, &x, SvAdjoint)) { - VERIFY(b.isApprox(m2.adjoint() * x, test_precision())); - } - - if (count==0) { - VERIFY_IS_APPROX(refDet,slu.determinant()); // FIXME det is not very stable for complex - } - } - } - #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_solvers() -- cgit v1.2.3