Handle NULL permutation from SuiteSparseQR
SuiteSparseQR sets permutation to NULL when the permutation is the
identity. Thus, instead of checking that permutation is not NULL, we
handle that case when building the inverse_permutation.
Change-Id: Ib0fcdf3462da765ac0d4b7aee47a1dff7b3a6c53
diff --git a/internal/ceres/covariance_impl.cc b/internal/ceres/covariance_impl.cc
index 7c63c2c..f7f1dc9 100644
--- a/internal/ceres/covariance_impl.cc
+++ b/internal/ceres/covariance_impl.cc
@@ -651,7 +651,6 @@
&permutation,
&cc);
event_logger.AddEvent("Numeric Factorization");
- CHECK_NOTNULL(permutation);
CHECK_NOTNULL(R);
if (rank < cholmod_jacobian.ncol) {
@@ -665,8 +664,14 @@
}
vector<int> inverse_permutation(num_cols);
- for (SuiteSparse_long i = 0; i < num_cols; ++i) {
- inverse_permutation[permutation[i]] = i;
+ if (permutation) {
+ for (SuiteSparse_long i = 0; i < num_cols; ++i) {
+ inverse_permutation[permutation[i]] = i;
+ }
+ } else {
+ for (SuiteSparse_long i = 0; i < num_cols; ++i) {
+ inverse_permutation[i] = i;
+ }
}
const int* rows = covariance_matrix_->rows();