Make the min. required version of SuiteSparse to be 4.5.6

With this change we can drop the complicated/conditional handling
around CAMD and assume that it is always available.

Change-Id: I93e1da676fb75817f79824b8b2b6549d03f278b0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6bf905..d72fe29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -266,7 +266,7 @@
   # built with SuiteSparse support.
 
   # Check for SuiteSparse and dependencies.
-  find_package(SuiteSparse 4.0 COMPONENTS CHOLMOD SPQR)
+  find_package(SuiteSparse 4.5.6 COMPONENTS CHOLMOD SPQR)
   if (SuiteSparse_FOUND)
     set(SuiteSparse_DEPENDENCY "find_dependency(SuiteSparse ${SuiteSparse_VERSION})")
     # By default, if all of SuiteSparse's dependencies are found, Ceres is
diff --git a/docs/source/installation.rst b/docs/source/installation.rst
index fa845c1..7cce067 100644
--- a/docs/source/installation.rst
+++ b/docs/source/installation.rst
@@ -68,7 +68,7 @@
   examples and tests and usually a dependency for glog.
 
 - `SuiteSparse <http://faculty.cse.tamu.edu/davis/suitesparse.html>`_
-  4.0 or later. Needed for solving large sparse linear
+  4.5.6 or later. Needed for solving large sparse linear
   systems. **Optional; strongly recommended for large scale bundle
   adjustment**
 
diff --git a/internal/ceres/reorder_program.cc b/internal/ceres/reorder_program.cc
index a4f7c35..bda4545 100644
--- a/internal/ceres/reorder_program.cc
+++ b/internal/ceres/reorder_program.cc
@@ -120,10 +120,9 @@
   cholmod_sparse* block_jacobian_transpose = ss.CreateSparseMatrix(
       const_cast<TripletSparseMatrix*>(&tsm_block_jacobian_transpose));
 
-  // No CAMD or the user did not supply a useful ordering, then just
-  // use regular AMD.
-  if (parameter_block_ordering.NumGroups() <= 1 ||
-      !SuiteSparse::IsConstrainedApproximateMinimumDegreeOrderingAvailable()) {
+  // If the user did not supply a useful ordering, then just use
+  // regular AMD.
+  if (parameter_block_ordering.NumGroups() <= 1) {
     ss.ApproximateMinimumDegreeOrdering(block_jacobian_transpose, &ordering[0]);
   } else {
     vector<int> constraints;
@@ -331,10 +330,6 @@
     const ParameterBlockOrdering& parameter_block_ordering, Program* program) {
 #ifndef CERES_NO_SUITESPARSE
   SuiteSparse ss;
-  if (!SuiteSparse::IsConstrainedApproximateMinimumDegreeOrderingAvailable()) {
-    return;
-  }
-
   vector<int> constraints;
   vector<ParameterBlock*>& parameter_blocks =
       *(program->mutable_parameter_blocks());
diff --git a/internal/ceres/suitesparse.cc b/internal/ceres/suitesparse.cc
index 7dffe1c..a7d28e6 100644
--- a/internal/ceres/suitesparse.cc
+++ b/internal/ceres/suitesparse.cc
@@ -352,16 +352,7 @@
 
 bool SuiteSparse::ConstrainedApproximateMinimumDegreeOrdering(
     cholmod_sparse* matrix, int* constraints, int* ordering) {
-#ifndef CERES_NO_CAMD
   return cholmod_camd(matrix, nullptr, 0, constraints, ordering, &cc_);
-#else
-  LOG(FATAL) << "Congratulations you have found a bug in Ceres."
-             << "Ceres Solver was compiled with SuiteSparse "
-             << "version 4.1.0 or less. Calling this function "
-             << "in that case is a bug. Please contact the"
-             << "the Ceres Solver developers.";
-  return false;
-#endif
 }
 
 std::unique_ptr<SparseCholesky> SuiteSparseCholesky::Create(
diff --git a/internal/ceres/suitesparse.h b/internal/ceres/suitesparse.h
index ad7b0da..b8dc666 100644
--- a/internal/ceres/suitesparse.h
+++ b/internal/ceres/suitesparse.h
@@ -49,28 +49,6 @@
 #include "cholmod.h"
 #include "glog/logging.h"
 
-// Before SuiteSparse version 4.2.0, cholmod_camd was only enabled
-// if SuiteSparse was compiled with Metis support. This makes
-// calling and linking into cholmod_camd problematic even though it
-// has nothing to do with Metis. This has been fixed reliably in
-// 4.2.0.
-//
-// The fix was actually committed in 4.1.0, but there is
-// some confusion about a silent update to the tar ball, so we are
-// being conservative and choosing the next minor version where
-// things are stable.
-#if (SUITESPARSE_VERSION < 4002)
-#define CERES_NO_CAMD
-#endif
-
-// UF_long is deprecated but SuiteSparse_long is only available in
-// newer versions of SuiteSparse. So for older versions of
-// SuiteSparse, we define SuiteSparse_long to be the same as UF_long,
-// which is what recent versions of SuiteSparse do anyways.
-#ifndef SuiteSparse_long
-#define SuiteSparse_long UF_long
-#endif
-
 #include "ceres/internal/disable_warnings.h"
 
 namespace ceres::internal {
@@ -240,20 +218,6 @@
   // Find a fill reducing ordering using nested dissection.
   bool NestedDissectionOrdering(cholmod_sparse* matrix, int* ordering);
 
-  // Before SuiteSparse version 4.2.0, cholmod_camd was only enabled
-  // if SuiteSparse was compiled with Metis support. This makes
-  // calling and linking into cholmod_camd problematic even though it
-  // has nothing to do with Metis. This has been fixed reliably in
-  // 4.2.0.
-  //
-  // The fix was actually committed in 4.1.0, but there is
-  // some confusion about a silent update to the tar ball, so we are
-  // being conservative and choosing the next minor version where
-  // things are stable.
-  static bool IsConstrainedApproximateMinimumDegreeOrderingAvailable() {
-    return (SUITESPARSE_VERSION > 4001);
-  }
-
   // Nested dissection is only available if SuiteSparse is compiled
   // with Metis support.
   static bool IsNestedDissectionAvailable() {
@@ -274,9 +238,6 @@
   // Calling ApproximateMinimumDegreeOrdering is equivalent to calling
   // ConstrainedApproximateMinimumDegreeOrdering with a constraint
   // array that puts all columns in the same elimination group.
-  //
-  // If CERES_NO_CAMD is defined then calling this function will
-  // result in a crash.
   bool ConstrainedApproximateMinimumDegreeOrdering(cholmod_sparse* matrix,
                                                    int* constraints,
                                                    int* ordering);
@@ -339,17 +300,6 @@
 
 class CERES_NO_EXPORT SuiteSparse {
  public:
-  // Defining this static function even when SuiteSparse is not
-  // available, allows client code to check for the presence of CAMD
-  // without checking for the absence of the CERES_NO_CAMD symbol.
-  //
-  // This is safer because the symbol maybe missing due to a user
-  // accidentally not including suitesparse.h in their code when
-  // checking for the symbol.
-  static bool IsConstrainedApproximateMinimumDegreeOrderingAvailable() {
-    return false;
-  }
-
   void Free(void* /*arg*/) {}
 };
 
diff --git a/internal/ceres/trust_region_preprocessor.cc b/internal/ceres/trust_region_preprocessor.cc
index 4b97021..daf6601 100644
--- a/internal/ceres/trust_region_preprocessor.cc
+++ b/internal/ceres/trust_region_preprocessor.cc
@@ -227,21 +227,15 @@
 
     if (options.linear_solver_type == SPARSE_SCHUR) {
       // When using SPARSE_SCHUR, we ignore the user's postordering
-      // preferences in certain cases.
-      //
-      // 1. SUITE_SPARSE is the sparse linear algebra library requested
-      //    but cholmod_camd is not available.
-      // 2. CX_SPARSE is the sparse linear algebra library requested.
+      // preferences if CX_SPARSE is the sparse linear algebra
+      // backend.
       //
       // This ensures that the linear solver does not assume that a
       // fill-reducing pre-ordering has been done.
       //
       // TODO(sameeragarwal): Implement the reordering of parameter
       // blocks for CX_SPARSE.
-      if ((options.sparse_linear_algebra_library_type == SUITE_SPARSE &&
-           !SuiteSparse::
-               IsConstrainedApproximateMinimumDegreeOrderingAvailable()) ||
-          (options.sparse_linear_algebra_library_type == CX_SPARSE)) {
+      if (options.sparse_linear_algebra_library_type == CX_SPARSE) {
         pp->linear_solver_options.use_postordering = true;
       }
     }