diff options
Diffstat (limited to 'unsupported/test')
-rw-r--r-- | unsupported/test/CMakeLists.txt | 57 | ||||
-rw-r--r-- | unsupported/test/bicgstab.cpp | 45 | ||||
-rw-r--r-- | unsupported/test/conjugate_gradient.cpp | 47 | ||||
-rw-r--r-- | unsupported/test/simplicial_cholesky.cpp | 57 | ||||
-rw-r--r-- | unsupported/test/sparse_solver.h | 193 | ||||
-rw-r--r-- | unsupported/test/superlu_support.cpp | 41 | ||||
-rw-r--r-- | unsupported/test/umfpack_support.cpp | 41 |
7 files changed, 0 insertions, 481 deletions
diff --git a/unsupported/test/CMakeLists.txt b/unsupported/test/CMakeLists.txt index 5dfc81fff..83e947665 100644 --- a/unsupported/test/CMakeLists.txt +++ b/unsupported/test/CMakeLists.txt @@ -2,46 +2,6 @@ include_directories(../../test ../../unsupported ../../Eigen ${CMAKE_CURRENT_BINARY_DIR}/../../test) -set(SPARSE_LIBS "") - -# configure blas/lapack (use Eigen's by default) -set(BLAS_FOUND TRUE) -set(LAPACK_FOUND TRUE) -set(BLAS_LIBRARIES eigen_blas) -set(LAPACK_LIBRARIES eigen_lapack) - -find_package(Cholmod) -if(CHOLMOD_FOUND AND BLAS_FOUND AND LAPACK_FOUND) - add_definitions("-DEIGEN_CHOLMOD_SUPPORT") - include_directories(${CHOLMOD_INCLUDES}) - set(SPARSE_LIBS ${SPARSE_LIBS} ${CHOLMOD_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}) - ei_add_property(EIGEN_TESTED_BACKENDS "Cholmod, ") -else() - ei_add_property(EIGEN_MISSING_BACKENDS "Cholmod, ") -endif() - -find_package(Umfpack) -if(UMFPACK_FOUND AND BLAS_FOUND) - add_definitions("-DEIGEN_UMFPACK_SUPPORT") - include_directories(${UMFPACK_INCLUDES}) - set(SPARSE_LIBS ${SPARSE_LIBS} ${UMFPACK_LIBRARIES} ${BLAS_LIBRARIES}) - set(UMFPACK_ALL_LIBS ${UMFPACK_LIBRARIES} ${BLAS_LIBRARIES}) - ei_add_property(EIGEN_TESTED_BACKENDS "UmfPack, ") -else() - ei_add_property(EIGEN_MISSING_BACKENDS "UmfPack, ") -endif() - -find_package(SuperLU) -if(SUPERLU_FOUND AND BLAS_FOUND) - add_definitions("-DEIGEN_SUPERLU_SUPPORT") - include_directories(${SUPERLU_INCLUDES}) - set(SPARSE_LIBS ${SPARSE_LIBS} ${SUPERLU_LIBRARIES} ${BLAS_LIBRARIES}) - set(SUPERLU_ALL_LIBS ${SUPERLU_LIBRARIES} ${BLAS_LIBRARIES}) - ei_add_property(EIGEN_TESTED_BACKENDS "SuperLU, ") -else() - ei_add_property(EIGEN_MISSING_BACKENDS "SuperLU, ") -endif() - find_package(GoogleHash) if(GOOGLEHASH_FOUND) add_definitions("-DEIGEN_GOOGLEHASH_SUPPORT") @@ -88,22 +48,6 @@ else() ei_add_property(EIGEN_MISSING_BACKENDS "MPFR C++, ") endif() -ei_add_test(sparse_llt "" "${SPARSE_LIBS}") -ei_add_test(sparse_ldlt "" "${SPARSE_LIBS}") -ei_add_test(sparse_lu_legacy "" "${SPARSE_LIBS}") - -ei_add_test(simplicial_cholesky) -ei_add_test(conjugate_gradient) -ei_add_test(bicgstab) - -if(UMFPACK_FOUND) - ei_add_test(umfpack_support "" "${UMFPACK_ALL_LIBS}") -endif() - -if(SUPERLU_FOUND) - ei_add_test(superlu_support "" "${SUPERLU_ALL_LIBS}") -endif() - ei_add_test(sparse_extra "" "") find_package(FFTW) @@ -150,4 +94,3 @@ endif(GSL_FOUND) ei_add_test(polynomialsolver " " "${GSL_LIBRARIES}" ) ei_add_test(polynomialutils) ei_add_test(kronecker_product) -ei_add_test(cg) diff --git a/unsupported/test/bicgstab.cpp b/unsupported/test/bicgstab.cpp deleted file mode 100644 index 4acb54ade..000000000 --- a/unsupported/test/bicgstab.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2011 Gael Guennebaud <g.gael@free.fr> -// -// Eigen is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 3 of the License, or (at your option) any later version. -// -// Alternatively, you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License and a copy of the GNU General Public License along with -// Eigen. If not, see <http://www.gnu.org/licenses/>. - -#include "sparse_solver.h" -#include <Eigen/IterativeSolvers> - -template<typename T> void test_bicgstab_T() -{ - BiCGSTAB<SparseMatrix<T>, DiagonalPreconditioner<T> > bicgstab_colmajor_diag; - BiCGSTAB<SparseMatrix<T>, IdentityPreconditioner > bicgstab_colmajor_I; - BiCGSTAB<SparseMatrix<T>, IncompleteLU<T> > bicgstab_colmajor_ilu; - - CALL_SUBTEST( check_sparse_square_solving(bicgstab_colmajor_diag) ); - CALL_SUBTEST( check_sparse_square_solving(bicgstab_colmajor_I) ); - CALL_SUBTEST( check_sparse_square_solving(bicgstab_colmajor_ilu) ); -} - -void test_bicgstab() -{ - for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1(test_bicgstab_T<double>()); - //CALL_SUBTEST_2(test_bicgstab_T<std::complex<double> >()); - } -} diff --git a/unsupported/test/conjugate_gradient.cpp b/unsupported/test/conjugate_gradient.cpp deleted file mode 100644 index 91a205a77..000000000 --- a/unsupported/test/conjugate_gradient.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2011 Gael Guennebaud <g.gael@free.fr> -// -// Eigen is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 3 of the License, or (at your option) any later version. -// -// Alternatively, you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License and a copy of the GNU General Public License along with -// Eigen. If not, see <http://www.gnu.org/licenses/>. - -#include "sparse_solver.h" -#include <Eigen/IterativeSolvers> - -template<typename T> void test_conjugate_gradient_T() -{ - ConjugateGradient<SparseMatrix<T>, Lower> cg_colmajor_lower_diag; - ConjugateGradient<SparseMatrix<T>, Upper> cg_colmajor_upper_diag; - ConjugateGradient<SparseMatrix<T>, Lower, IdentityPreconditioner> cg_colmajor_lower_I; - ConjugateGradient<SparseMatrix<T>, Upper, IdentityPreconditioner> cg_colmajor_upper_I; - - CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_lower_diag) ); - CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_upper_diag) ); - CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_lower_I) ); - CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_upper_I) ); -} - -void test_conjugate_gradient() -{ - for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1(test_conjugate_gradient_T<double>()); - CALL_SUBTEST_2(test_conjugate_gradient_T<std::complex<double> >()); - } -} diff --git a/unsupported/test/simplicial_cholesky.cpp b/unsupported/test/simplicial_cholesky.cpp deleted file mode 100644 index b9a55ef36..000000000 --- a/unsupported/test/simplicial_cholesky.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2011 Gael Guennebaud <g.gael@free.fr> -// -// Eigen is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 3 of the License, or (at your option) any later version. -// -// Alternatively, you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License and a copy of the GNU General Public License along with -// Eigen. If not, see <http://www.gnu.org/licenses/>. - -#include "sparse_solver.h" - -template<typename T> void test_simplicial_cholesky_T() -{ - SimplicialCholesky<SparseMatrix<T>, Lower> chol_colmajor_lower; - SimplicialCholesky<SparseMatrix<T>, Upper> chol_colmajor_upper; - SimplicialLLt<SparseMatrix<T>, Lower> llt_colmajor_lower; - SimplicialLDLt<SparseMatrix<T>, Upper> llt_colmajor_upper; - SimplicialLDLt<SparseMatrix<T>, Lower> ldlt_colmajor_lower; - SimplicialLDLt<SparseMatrix<T>, Upper> ldlt_colmajor_upper; - - check_sparse_spd_solving(chol_colmajor_lower); - check_sparse_spd_solving(chol_colmajor_upper); - check_sparse_spd_solving(llt_colmajor_lower); - check_sparse_spd_solving(llt_colmajor_upper); - check_sparse_spd_solving(ldlt_colmajor_lower); - check_sparse_spd_solving(ldlt_colmajor_upper); - - check_sparse_spd_determinant(chol_colmajor_lower); - check_sparse_spd_determinant(chol_colmajor_upper); - check_sparse_spd_determinant(llt_colmajor_lower); - check_sparse_spd_determinant(llt_colmajor_upper); - check_sparse_spd_determinant(ldlt_colmajor_lower); - check_sparse_spd_determinant(ldlt_colmajor_upper); -} - -void test_simplicial_cholesky() -{ - for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1(test_simplicial_cholesky_T<double>()); - CALL_SUBTEST_2(test_simplicial_cholesky_T<std::complex<double> >()); - } -} diff --git a/unsupported/test/sparse_solver.h b/unsupported/test/sparse_solver.h deleted file mode 100644 index d803ef539..000000000 --- a/unsupported/test/sparse_solver.h +++ /dev/null @@ -1,193 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2011 Gael Guennebaud <g.gael@free.fr> -// -// Eigen is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 3 of the License, or (at your option) any later version. -// -// Alternatively, you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License and a copy of the GNU General Public License along with -// Eigen. If not, see <http://www.gnu.org/licenses/>. - -#include "sparse.h" -#include <Eigen/SparseExtra> - -template<typename Solver, typename Rhs, typename DenseMat, typename DenseRhs> -void check_sparse_solving(Solver& solver, const typename Solver::MatrixType& A, const Rhs& b, const DenseMat& dA, const DenseRhs& db) -{ - typedef typename Solver::MatrixType Mat; - typedef typename Mat::Scalar Scalar; - - DenseRhs refX = dA.lu().solve(db); - - Rhs x(b.rows(), b.cols()); - Rhs oldb = b; - - solver.compute(A); - if (solver.info() != Success) - { - std::cerr << "sparse SPD: factorization failed (check_sparse_solving)\n"; - exit(0); - return; - } - x = solver.solve(b); - if (solver.info() != Success) - { - std::cerr << "sparse SPD: solving failed\n"; - return; - } - VERIFY(oldb.isApprox(b) && "sparse SPD: the rhs should not be modified!"); - - VERIFY(x.isApprox(refX,test_precision<Scalar>())); -} - -template<typename Solver, typename DenseMat> -void check_sparse_determinant(Solver& solver, const typename Solver::MatrixType& A, const DenseMat& dA) -{ - typedef typename Solver::MatrixType Mat; - typedef typename Mat::Scalar Scalar; - typedef typename Mat::RealScalar RealScalar; - - solver.compute(A); - if (solver.info() != Success) - { - std::cerr << "sparse SPD: factorization failed (check_sparse_determinant)\n"; - return; - } - - Scalar refDet = dA.determinant(); - VERIFY_IS_APPROX(refDet,solver.determinant()); -} - - -template<typename Solver, typename DenseMat> -int generate_sparse_spd_problem(Solver& , typename Solver::MatrixType& A, typename Solver::MatrixType& halfA, DenseMat& dA, int maxSize = 300) -{ - typedef typename Solver::MatrixType Mat; - typedef typename Mat::Scalar Scalar; - typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; - - int size = internal::random<int>(1,maxSize); - double density = (std::max)(8./(size*size), 0.01); - - Mat M(size, size); - DenseMatrix dM(size, size); - - initSparse<Scalar>(density, dM, M, ForceNonZeroDiag); - - A = M * M.adjoint(); - dA = dM * dM.adjoint(); - - halfA.resize(size,size); - halfA.template selfadjointView<Solver::UpLo>().rankUpdate(M); - - return size; -} - -template<typename Solver> void check_sparse_spd_solving(Solver& solver) -{ - typedef typename Solver::MatrixType Mat; - typedef typename Mat::Scalar Scalar; - typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; - typedef Matrix<Scalar,Dynamic,1> DenseVector; - - // generate the problem - Mat A, halfA; - DenseMatrix dA; - int size = generate_sparse_spd_problem(solver, A, halfA, dA); - - // generate the right hand sides - int rhsCols = internal::random<int>(1,16); - double density = (std::max)(8./(size*rhsCols), 0.1); - Mat B(size,rhsCols); - DenseVector b = DenseVector::Random(size); - DenseMatrix dB(size,rhsCols); - initSparse<Scalar>(density, dB, B); - - check_sparse_solving(solver, A, b, dA, b); - check_sparse_solving(solver, halfA, b, dA, b); - check_sparse_solving(solver, A, dB, dA, dB); - check_sparse_solving(solver, halfA, dB, dA, dB); - check_sparse_solving(solver, A, B, dA, dB); - check_sparse_solving(solver, halfA, B, dA, dB); -} - -template<typename Solver> void check_sparse_spd_determinant(Solver& solver) -{ - typedef typename Solver::MatrixType Mat; - typedef typename Mat::Scalar Scalar; - typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; - - // generate the problem - Mat A, halfA; - DenseMatrix dA; - generate_sparse_spd_problem(solver, A, halfA, dA, 30); - - check_sparse_determinant(solver, A, dA); - check_sparse_determinant(solver, halfA, dA ); -} - -template<typename Solver, typename DenseMat> -int generate_sparse_square_problem(Solver&, typename Solver::MatrixType& A, DenseMat& dA, int maxSize = 300) -{ - typedef typename Solver::MatrixType Mat; - typedef typename Mat::Scalar Scalar; - typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; - - int size = internal::random<int>(1,maxSize); - double density = (std::max)(8./(size*size), 0.01); - - A.resize(size,size); - dA.resize(size,size); - - initSparse<Scalar>(density, dA, A, ForceNonZeroDiag); - - return size; -} - -template<typename Solver> void check_sparse_square_solving(Solver& solver) -{ - typedef typename Solver::MatrixType Mat; - typedef typename Mat::Scalar Scalar; - typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; - typedef Matrix<Scalar,Dynamic,1> DenseVector; - - int rhsCols = internal::random<int>(1,16); - - Mat A; - DenseMatrix dA; - int size = generate_sparse_square_problem(solver, A, dA); - - DenseVector b = DenseVector::Random(size); - DenseMatrix dB = DenseMatrix::Random(size,rhsCols); - - check_sparse_solving(solver, A, b, dA, b); - check_sparse_solving(solver, A, dB, dA, dB); -} - -template<typename Solver> void check_sparse_square_determinant(Solver& solver) -{ - typedef typename Solver::MatrixType Mat; - typedef typename Mat::Scalar Scalar; - typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; - - // generate the problem - Mat A; - DenseMatrix dA; - generate_sparse_square_problem(solver, A, dA, 30); - - check_sparse_determinant(solver, A, dA); -} diff --git a/unsupported/test/superlu_support.cpp b/unsupported/test/superlu_support.cpp deleted file mode 100644 index e54d72c1c..000000000 --- a/unsupported/test/superlu_support.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2011 Gael Guennebaud <g.gael@free.fr> -// -// Eigen is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 3 of the License, or (at your option) any later version. -// -// Alternatively, you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License and a copy of the GNU General Public License along with -// Eigen. If not, see <http://www.gnu.org/licenses/>. - -#include "sparse_solver.h" - -#ifdef EIGEN_SUPERLU_SUPPORT -#include <Eigen/SuperLUSupport> -#endif - -void test_superlu_support() -{ - for(int i = 0; i < g_repeat; i++) { - SuperLU<SparseMatrix<double> > superlu_double_colmajor; - SuperLU<SparseMatrix<std::complex<double> > > superlu_cplxdouble_colmajor; - CALL_SUBTEST_1( check_sparse_square_solving(superlu_double_colmajor) ); - CALL_SUBTEST_2( check_sparse_square_solving(superlu_cplxdouble_colmajor) ); - CALL_SUBTEST_1( check_sparse_square_determinant(superlu_double_colmajor) ); - CALL_SUBTEST_2( check_sparse_square_determinant(superlu_cplxdouble_colmajor) ); - } -} diff --git a/unsupported/test/umfpack_support.cpp b/unsupported/test/umfpack_support.cpp deleted file mode 100644 index 16f688302..000000000 --- a/unsupported/test/umfpack_support.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2011 Gael Guennebaud <g.gael@free.fr> -// -// Eigen is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 3 of the License, or (at your option) any later version. -// -// Alternatively, you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License and a copy of the GNU General Public License along with -// Eigen. If not, see <http://www.gnu.org/licenses/>. - -#include "sparse_solver.h" - -#ifdef EIGEN_UMFPACK_SUPPORT -#include <Eigen/UmfPackSupport> -#endif - -void test_umfpack_support() -{ - for(int i = 0; i < g_repeat; i++) { - UmfPackLU<SparseMatrix<double> > umfpack_double_colmajor; - UmfPackLU<SparseMatrix<std::complex<double> > > umfpack_cplxdouble_colmajor; - CALL_SUBTEST_1(check_sparse_square_solving(umfpack_double_colmajor)); - CALL_SUBTEST_2(check_sparse_square_solving(umfpack_cplxdouble_colmajor)); - CALL_SUBTEST_1(check_sparse_square_determinant(umfpack_double_colmajor)); - CALL_SUBTEST_2(check_sparse_square_determinant(umfpack_cplxdouble_colmajor)); - } -} |