Multiple sparse linear algebra backends.
1. Added support for CXSparse - SparseNormalCholesky and
SchurComplementSolver support SuiteSparse and CXSparse now.
I am not sure I will add suport for visibility based
preconditioning using CXSparse. Its not a high priority.
2. New enum SparseLinearAlgebraLibraryType which allows the user
to indicate which sparse linear algebra library should be used.
3. Updated tests for SolverImpl and system_test.
4. Build system changes to automatically detect CXSparse and
link to it by default -- just like SuiteSparse.
5. Minor bug fixes dealing in the cmake files and VBP.
6. Changed the order of the system test.
7. Deduped the unsymmetric linear solver test.
Change-Id: I33252a103c87b722ecb7ed7b5f0ae7fd91249244
diff --git a/internal/ceres/solver_impl_test.cc b/internal/ceres/solver_impl_test.cc
index 2abca63..20190f1 100644
--- a/internal/ceres/solver_impl_test.cc
+++ b/internal/ceres/solver_impl_test.cc
@@ -432,14 +432,14 @@
EXPECT_EQ(parameter_blocks[2]->user_state(), &y);
}
-#ifdef CERES_NO_SUITESPARSE
+#if defined(CERES_NO_SUITESPARSE) && defined(CERES_NO_CXSPARSE)
TEST(SolverImpl, CreateLinearSolverNoSuiteSparse) {
Solver::Options options;
options.linear_solver_type = SPARSE_NORMAL_CHOLESKY;
string error;
EXPECT_FALSE(SolverImpl::CreateLinearSolver(&options, &error));
}
-#endif // CERES_NO_SUITESPARSE
+#endif
TEST(SolverImpl, CreateLinearSolverNegativeMaxNumIterations) {
Solver::Options options;
@@ -477,11 +477,12 @@
scoped_ptr<LinearSolver> solver(
SolverImpl::CreateLinearSolver(&options, &error));
EXPECT_TRUE(solver != NULL);
-#ifndef CERES_NO_SUITESPARSE
- EXPECT_EQ(options.linear_solver_type, SPARSE_NORMAL_CHOLESKY);
-#else
+
+#if defined(CERES_NO_SUITESPARSE) && defined(CERES_NO_CXSPARSE)
EXPECT_EQ(options.linear_solver_type, DENSE_QR);
-#endif // CERES_NO_SUITESPARSE
+#else
+ EXPECT_EQ(options.linear_solver_type, SPARSE_NORMAL_CHOLESKY);
+#endif
}
TEST(SolverImpl, CreateLinearSolverDenseSchurMultipleThreads) {
@@ -508,10 +509,19 @@
#ifndef CERES_NO_SUITESPARSE
options.linear_solver_type = SPARSE_NORMAL_CHOLESKY;
+ options.sparse_linear_algebra_library = SUITE_SPARSE;
solver.reset(SolverImpl::CreateLinearSolver(&options, &error));
EXPECT_EQ(options.linear_solver_type, SPARSE_NORMAL_CHOLESKY);
EXPECT_TRUE(solver.get() != NULL);
-#endif // CERES_NO_SUITESPARSE
+#endif
+
+#ifndef CERES_NO_CXSPARSE
+ options.linear_solver_type = SPARSE_NORMAL_CHOLESKY;
+ options.sparse_linear_algebra_library = CX_SPARSE;
+ solver.reset(SolverImpl::CreateLinearSolver(&options, &error));
+ EXPECT_EQ(options.linear_solver_type, SPARSE_NORMAL_CHOLESKY);
+ EXPECT_TRUE(solver.get() != NULL);
+#endif
options.linear_solver_type = DENSE_SCHUR;
options.num_eliminate_blocks = 2;
@@ -521,13 +531,14 @@
options.linear_solver_type = SPARSE_SCHUR;
options.num_eliminate_blocks = 2;
-#ifndef CERES_NO_SUITESPARSE
solver.reset(SolverImpl::CreateLinearSolver(&options, &error));
+
+#if defined(CERES_NO_SUITESPARSE) && defined(CERES_NO_CXSPARSE)
+ EXPECT_TRUE(SolverImpl::CreateLinearSolver(&options, &error) == NULL);
+#else
EXPECT_TRUE(solver.get() != NULL);
EXPECT_EQ(options.linear_solver_type, SPARSE_SCHUR);
-#else // CERES_NO_SUITESPARSE
- EXPECT_TRUE(SolverImpl::CreateLinearSolver(&options, &error) == NULL);
-#endif // CERES_NO_SUITESPARSE
+#endif
options.linear_solver_type = ITERATIVE_SCHUR;
options.num_eliminate_blocks = 2;