Fix the build on Eigen version 3.2.1 and older.

Change-Id: I18f5cb5d42113737d7b8f78a67acee28bd5b3e08
diff --git a/internal/ceres/schur_complement_solver.h b/internal/ceres/schur_complement_solver.h
index d1efd28..1b431dc 100644
--- a/internal/ceres/schur_complement_solver.h
+++ b/internal/ceres/schur_complement_solver.h
@@ -191,16 +191,16 @@
 
 #ifdef CERES_USE_EIGEN_SPARSE
 
-  // For Eigen versions less than 3.2.2, we cannot pre-order the
-  // Jacobian, so we must use an AMD ordering.
+  // The preprocessor gymnastics here are dealing with the fact that
+  // before version 3.2.2, Eigen did not support a third template
+  // parameter to specify the ordering.
 #if EIGEN_VERSION_AT_LEAST(3,2,2)
-  typedef Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>,
-                                Eigen::Lower,
-                                Eigen::NaturalOrdering<int> > SimplicialLDLT;
+  typedef Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>, Eigen::Lower,
+                                Eigen::NaturalOrdering<int> >
+  SimplicialLDLT;
 #else
-  typedef Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>,
-                                Eigen::Lower,
-                                Eigen::AMDOrdering<int> > SimplicialLDLT;
+  typedef Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>, Eigen::Lower>
+  SimplicialLDLT;
 #endif
 
   scoped_ptr<SimplicialLDLT> simplicial_ldlt_;
diff --git a/internal/ceres/sparse_normal_cholesky_solver.cc b/internal/ceres/sparse_normal_cholesky_solver.cc
index e7da6a8..94f7e58 100644
--- a/internal/ceres/sparse_normal_cholesky_solver.cc
+++ b/internal/ceres/sparse_normal_cholesky_solver.cc
@@ -252,6 +252,7 @@
                                &event_logger);
   }
 
+#if EIGEN_VERSION_AT_LEAST(3,2,2)
   // The common case
   if (natural_ldlt_.get() == NULL) {
     natural_ldlt_.reset(new SimplicialLDLTWithNaturalOrdering);
@@ -263,6 +264,7 @@
                              natural_ldlt_.get(),
                              rhs_and_solution,
                              &event_logger);
+#endif
 
 #endif  // EIGEN_USE_EIGEN_SPARSE
 }
diff --git a/internal/ceres/sparse_normal_cholesky_solver.h b/internal/ceres/sparse_normal_cholesky_solver.h
index d1efe00..12c0524 100644
--- a/internal/ceres/sparse_normal_cholesky_solver.h
+++ b/internal/ceres/sparse_normal_cholesky_solver.h
@@ -95,17 +95,28 @@
   cs_dis* cxsparse_factor_;
 
 #ifdef CERES_USE_EIGEN_SPARSE
-  typedef Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>,
-                                Eigen::Upper,
+
+  // The preprocessor gymnastics here are dealing with the fact that
+  // before version 3.2.2, Eigen did not support a third template
+  // parameter to specify the ordering.
+#if EIGEN_VERSION_AT_LEAST(3,2,2)
+  typedef Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>, Eigen::Upper,
                                 Eigen::NaturalOrdering<int> >
   SimplicialLDLTWithNaturalOrdering;
-  typedef Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>,
-                                Eigen::Upper,
+  scoped_ptr<SimplicialLDLTWithNaturalOrdering> natural_ldlt_;
+
+  typedef Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>, Eigen::Upper,
                                 Eigen::AMDOrdering<int> >
   SimplicialLDLTWithAMDOrdering;
-
-  scoped_ptr<SimplicialLDLTWithNaturalOrdering> natural_ldlt_;
   scoped_ptr<SimplicialLDLTWithAMDOrdering> amd_ldlt_;
+
+#else
+  typedef Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>, Eigen::Upper>
+  SimplicialLDLTWithAMDOrdering;
+
+  scoped_ptr<SimplicialLDLTWithAMDOrdering> amd_ldlt_;
+#endif
+
 #endif
 
   scoped_ptr<CompressedRowSparseMatrix> outer_product_;