Do not create a SparseCholesky object when not needed.

SchurComplementSolver implements a variant of ITERATIVE_SCHUR
when explicit_schur_complement is set to true. In this case
the SparseCholesky object should not be instantiated. Even
though there is no CPU cost, it can be the case that ITERATIVE_SCHUR
is being used when there are not sparse linear algebra libraries
are available, and this can result in a crash.

Change-Id: I349d5f79201782689b3ab0ccc2c5001804b44c7b
This commit is contained in:
Sameer Agarwal
2017-06-02 10:28:54 -07:00
parent 4c9c5d12f4
commit 99aca60b2c
+5 -3
View File
@@ -226,9 +226,11 @@ DenseSchurComplementSolver::SolveReducedLinearSystem(
SparseSchurComplementSolver::SparseSchurComplementSolver(
const LinearSolver::Options& options)
: SchurComplementSolver(options) {
sparse_cholesky_.reset(
SparseCholesky::Create(options.sparse_linear_algebra_library_type,
options.use_postordering ? AMD : NATURAL));
if (options.type != ITERATIVE_SCHUR) {
sparse_cholesky_.reset(
SparseCholesky::Create(options.sparse_linear_algebra_library_type,
options.use_postordering ? AMD : NATURAL));
}
}
SparseSchurComplementSolver::~SparseSchurComplementSolver() {