From 9e885fb76608c8d90da20151db6459a99be360d6 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 9 Mar 2015 14:33:15 +0100 Subject: [PATCH] Add unit tests for CG and sparse-LLT for long int as storage-index --- Eigen/src/OrderingMethods/Ordering.h | 4 ++-- Eigen/src/SparseCholesky/SimplicialCholesky.h | 5 ++-- test/bicgstab.cpp | 2 +- test/conjugate_gradient.cpp | 18 +++++++------- test/simplicial_cholesky.cpp | 24 ++++++++++--------- 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Eigen/src/OrderingMethods/Ordering.h b/Eigen/src/OrderingMethods/Ordering.h index e88e637a4..cb838d04a 100644 --- a/Eigen/src/OrderingMethods/Ordering.h +++ b/Eigen/src/OrderingMethods/Ordering.h @@ -90,11 +90,11 @@ class AMDOrdering * \note Returns an empty permutation matrix * \tparam Index The type of indices of the matrix */ -template +template class NaturalOrdering { public: - typedef PermutationMatrix PermutationType; + typedef PermutationMatrix PermutationType; /** Compute the permutation vector from a column-major sparse matrix */ template diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky.h b/Eigen/src/SparseCholesky/SimplicialCholesky.h index a0815e708..f56298e8c 100644 --- a/Eigen/src/SparseCholesky/SimplicialCholesky.h +++ b/Eigen/src/SparseCholesky/SimplicialCholesky.h @@ -69,6 +69,7 @@ class SimplicialCholeskyBase : public SparseSolverBase typedef SparseMatrix CholMatrixType; typedef CholMatrixType const * ConstCholMatrixPtr; typedef Matrix VectorType; + typedef Matrix VectorI; public: @@ -250,8 +251,8 @@ class SimplicialCholeskyBase : public SparseSolverBase CholMatrixType m_matrix; VectorType m_diag; // the diagonal coefficients (LDLT mode) - VectorXi m_parent; // elimination tree - VectorXi m_nonZerosPerCol; + VectorI m_parent; // elimination tree + VectorI m_nonZerosPerCol; PermutationMatrix m_P; // the permutation PermutationMatrix m_Pinv; // the inverse permutation diff --git a/test/bicgstab.cpp b/test/bicgstab.cpp index 6d76389ce..7a9a11330 100644 --- a/test/bicgstab.cpp +++ b/test/bicgstab.cpp @@ -26,6 +26,6 @@ template void test_bicgstab_T() void test_bicgstab() { CALL_SUBTEST_1((test_bicgstab_T()) ); - CALL_SUBTEST_1((test_bicgstab_T())); CALL_SUBTEST_2((test_bicgstab_T, int>())); + CALL_SUBTEST_3((test_bicgstab_T())); } diff --git a/test/conjugate_gradient.cpp b/test/conjugate_gradient.cpp index 019cc4d64..9622fd86d 100644 --- a/test/conjugate_gradient.cpp +++ b/test/conjugate_gradient.cpp @@ -10,13 +10,14 @@ #include "sparse_solver.h" #include -template void test_conjugate_gradient_T() +template void test_conjugate_gradient_T() { - ConjugateGradient, Lower > cg_colmajor_lower_diag; - ConjugateGradient, Upper > cg_colmajor_upper_diag; - ConjugateGradient, Lower|Upper> cg_colmajor_loup_diag; - ConjugateGradient, Lower, IdentityPreconditioner> cg_colmajor_lower_I; - ConjugateGradient, Upper, IdentityPreconditioner> cg_colmajor_upper_I; + typedef SparseMatrix SparseMatrixType; + ConjugateGradient cg_colmajor_lower_diag; + ConjugateGradient cg_colmajor_upper_diag; + ConjugateGradient cg_colmajor_loup_diag; + ConjugateGradient cg_colmajor_lower_I; + ConjugateGradient cg_colmajor_upper_I; CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_lower_diag) ); CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_upper_diag) ); @@ -27,6 +28,7 @@ template void test_conjugate_gradient_T() void test_conjugate_gradient() { - CALL_SUBTEST_1(test_conjugate_gradient_T()); - CALL_SUBTEST_2(test_conjugate_gradient_T >()); + CALL_SUBTEST_1(( test_conjugate_gradient_T() )); + CALL_SUBTEST_2(( test_conjugate_gradient_T, int>() )); + CALL_SUBTEST_3(( test_conjugate_gradient_T() )); } diff --git a/test/simplicial_cholesky.cpp b/test/simplicial_cholesky.cpp index 786468421..b7cc2d351 100644 --- a/test/simplicial_cholesky.cpp +++ b/test/simplicial_cholesky.cpp @@ -9,16 +9,17 @@ #include "sparse_solver.h" -template void test_simplicial_cholesky_T() +template void test_simplicial_cholesky_T() { - SimplicialCholesky, Lower> chol_colmajor_lower_amd; - SimplicialCholesky, Upper> chol_colmajor_upper_amd; - SimplicialLLT, Lower> llt_colmajor_lower_amd; - SimplicialLLT, Upper> llt_colmajor_upper_amd; - SimplicialLDLT, Lower> ldlt_colmajor_lower_amd; - SimplicialLDLT, Upper> ldlt_colmajor_upper_amd; - SimplicialLDLT, Lower, NaturalOrdering > ldlt_colmajor_lower_nat; - SimplicialLDLT, Upper, NaturalOrdering > ldlt_colmajor_upper_nat; + typedef SparseMatrix SparseMatrixType; + SimplicialCholesky chol_colmajor_lower_amd; + SimplicialCholesky chol_colmajor_upper_amd; + SimplicialLLT< SparseMatrixType, Lower> llt_colmajor_lower_amd; + SimplicialLLT< SparseMatrixType, Upper> llt_colmajor_upper_amd; + SimplicialLDLT< SparseMatrixType, Lower> ldlt_colmajor_lower_amd; + SimplicialLDLT< SparseMatrixType, Upper> ldlt_colmajor_upper_amd; + SimplicialLDLT< SparseMatrixType, Lower, NaturalOrdering > ldlt_colmajor_lower_nat; + SimplicialLDLT< SparseMatrixType, Upper, NaturalOrdering > ldlt_colmajor_upper_nat; check_sparse_spd_solving(chol_colmajor_lower_amd); check_sparse_spd_solving(chol_colmajor_upper_amd); @@ -40,6 +41,7 @@ template void test_simplicial_cholesky_T() void test_simplicial_cholesky() { - CALL_SUBTEST_1(test_simplicial_cholesky_T()); - CALL_SUBTEST_2(test_simplicial_cholesky_T >()); + CALL_SUBTEST_1(( test_simplicial_cholesky_T() )); + CALL_SUBTEST_2(( test_simplicial_cholesky_T, int>() )); + CALL_SUBTEST_3(( test_simplicial_cholesky_T() )); }