Lint and other cleanups from William Rucklidge

Change-Id: I7fb23c2db85f0f121204560b79f1966f3d584431
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 58026da..403720f 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -48,7 +48,7 @@
 # built documents.
 #
 # The short X.Y version.
-version = '1.7'
+version = '1.8'
 # The full version, including alpha/beta/rc tags.
 release = '1.8.0'
 
diff --git a/include/ceres/solver.h b/include/ceres/solver.h
index 7d8e4e2..7776c47 100644
--- a/include/ceres/solver.h
+++ b/include/ceres/solver.h
@@ -385,7 +385,7 @@
     // Type of preconditioner to use with the iterative linear solvers.
     PreconditionerType preconditioner_type;
 
-    // Type of clustering algorithm to use visibility based
+    // Type of clustering algorithm to use for visibility based
     // preconditioning. This option is used only when the
     // preconditioner_type is CLUSTER_JACOBI or CLUSTER_TRIDIAGONAL.
     VisibilityClusteringType visibility_clustering_type;
diff --git a/include/ceres/types.h b/include/ceres/types.h
index c8c9cfe..c94bd04 100644
--- a/include/ceres/types.h
+++ b/include/ceres/types.h
@@ -134,7 +134,7 @@
   CANONICAL_VIEWS,
 
   // The classic single linkage algorithm. It is extremely fast as
-  // compared to CANONICAL_VIEWS, but can give slightly poor
+  // compared to CANONICAL_VIEWS, but can give slightly poorer
   // results. For problems with large number of cameras though, this
   // is generally a pretty good option.
   //
diff --git a/internal/ceres/generate_partitioned_matrix_view_specializations.py b/internal/ceres/generate_partitioned_matrix_view_specializations.py
index 1ee8b8e..c6ab573 100644
--- a/internal/ceres/generate_partitioned_matrix_view_specializations.py
+++ b/internal/ceres/generate_partitioned_matrix_view_specializations.py
@@ -36,7 +36,7 @@
 # This script creates two sets of files.
 #
 # 1. partitioned_matrix_view_x_x_x.cc
-# where, the x indicates the template parameters and
+# where the x indicates the template parameters and
 #
 # 2. partitioned_matrix_view.cc
 #
diff --git a/internal/ceres/implicit_schur_complement.cc b/internal/ceres/implicit_schur_complement.cc
index 8ab6b6d..2da6235 100644
--- a/internal/ceres/implicit_schur_complement.cc
+++ b/internal/ceres/implicit_schur_complement.cc
@@ -42,7 +42,8 @@
 namespace ceres {
 namespace internal {
 
-ImplicitSchurComplement::ImplicitSchurComplement(const LinearSolver::Options& options)
+ImplicitSchurComplement::ImplicitSchurComplement(
+    const LinearSolver::Options& options)
     : options_(options),
       D_(NULL),
       b_(NULL) {
diff --git a/internal/ceres/partitioned_matrix_view.h b/internal/ceres/partitioned_matrix_view.h
index 98423a0..661252d 100644
--- a/internal/ceres/partitioned_matrix_view.h
+++ b/internal/ceres/partitioned_matrix_view.h
@@ -87,14 +87,16 @@
   // BlockStructure (preferably created using
   // CreateBlockDiagonalMatrixEtE) which is has the same structure as
   // the block diagonal of E'E.
-  virtual void UpdateBlockDiagonalEtE(BlockSparseMatrix* block_diagonal) const = 0;
+  virtual void UpdateBlockDiagonalEtE(
+      BlockSparseMatrix* block_diagonal) const = 0;
 
   // Compute the block diagonal of the matrix F'F and store it in
   // block_diagonal. The matrix block_diagonal is expected to have a
   // BlockStructure (preferably created using
   // CreateBlockDiagonalMatrixFtF) which is has the same structure as
   // the block diagonal of F'F.
-  virtual void UpdateBlockDiagonalFtF(BlockSparseMatrix* block_diagonal) const = 0;
+  virtual void UpdateBlockDiagonalFtF(
+      BlockSparseMatrix* block_diagonal) const = 0;
 
   virtual int num_col_blocks_e() const = 0;
   virtual int num_col_blocks_f() const = 0;
diff --git a/internal/ceres/partitioned_matrix_view_impl.h b/internal/ceres/partitioned_matrix_view_impl.h
index 5fd5fe1..ae7f776 100644
--- a/internal/ceres/partitioned_matrix_view_impl.h
+++ b/internal/ceres/partitioned_matrix_view_impl.h
@@ -279,7 +279,8 @@
 }
 
 template <int kRowBlockSize, int kEBlockSize, int kFBlockSize>
-BlockSparseMatrix* PartitionedMatrixView<kRowBlockSize, kEBlockSize, kFBlockSize>::
+BlockSparseMatrix*
+PartitionedMatrixView<kRowBlockSize, kEBlockSize, kFBlockSize>::
 CreateBlockDiagonalFtF() const {
   BlockSparseMatrix* block_diagonal =
       CreateBlockDiagonalMatrixLayout(
diff --git a/internal/ceres/schur_jacobi_preconditioner.cc b/internal/ceres/schur_jacobi_preconditioner.cc
index 46e6d02..6dc9e89 100644
--- a/internal/ceres/schur_jacobi_preconditioner.cc
+++ b/internal/ceres/schur_jacobi_preconditioner.cc
@@ -70,7 +70,7 @@
 // Initialize the SchurEliminator.
 void SchurJacobiPreconditioner::InitEliminator(
     const CompressedRowBlockStructure& bs) {
-    LinearSolver::Options eliminator_options;
+  LinearSolver::Options eliminator_options;
   eliminator_options.elimination_groups = options_.elimination_groups;
   eliminator_options.num_threads = options_.num_threads;
   eliminator_options.e_block_size = options_.e_block_size;
diff --git a/internal/ceres/single_linkage_clustering.h b/internal/ceres/single_linkage_clustering.h
index a0fe8f9..9b137cf 100644
--- a/internal/ceres/single_linkage_clustering.h
+++ b/internal/ceres/single_linkage_clustering.h
@@ -44,7 +44,7 @@
       : min_similarity(0.99) {
   }
 
-  // Graph edges with edge weight less that min_similarity are ignored
+  // Graph edges with edge weight less than min_similarity are ignored
   // during the clustering process.
   double min_similarity;
 };
diff --git a/internal/ceres/single_linkage_clustering_test.cc b/internal/ceres/single_linkage_clustering_test.cc
index 8fbf84b..42cbda3 100644
--- a/internal/ceres/single_linkage_clustering_test.cc
+++ b/internal/ceres/single_linkage_clustering_test.cc
@@ -61,6 +61,8 @@
   EXPECT_EQ(membership[1], membership[0]);
   EXPECT_EQ(membership[2], membership[0]);
   EXPECT_EQ(membership[3], membership[0]);
+  EXPECT_NE(membership[4], membership[0]);
+  EXPECT_NE(membership[5], membership[0]);
   EXPECT_EQ(membership[4], membership[5]);
 }
 
@@ -88,6 +90,8 @@
   EXPECT_EQ(membership[1], membership[0]);
   EXPECT_EQ(membership[2], membership[0]);
   EXPECT_EQ(membership[3], membership[0]);
+  EXPECT_NE(membership[4], membership[0]);
+  EXPECT_NE(membership[5], membership[0]);
   EXPECT_NE(membership[4], membership[5]);
 }
 
diff --git a/internal/ceres/solver.cc b/internal/ceres/solver.cc
index 2750e23..0445cfb 100644
--- a/internal/ceres/solver.cc
+++ b/internal/ceres/solver.cc
@@ -241,8 +241,10 @@
     if (preconditioner_type == CLUSTER_JACOBI ||
         preconditioner_type == CLUSTER_TRIDIAGONAL) {
       StringAppendF(&report, "Visibility clustering%24s%25s\n",
-                    VisibilityClusteringTypeToString(visibility_clustering_type),
-                    VisibilityClusteringTypeToString(visibility_clustering_type));
+                    VisibilityClusteringTypeToString(
+                        visibility_clustering_type),
+                    VisibilityClusteringTypeToString(
+                        visibility_clustering_type));
     }
     StringAppendF(&report, "Threads             % 25d% 25d\n",
                   num_threads_given, num_threads_used);
diff --git a/internal/ceres/visibility_based_preconditioner.cc b/internal/ceres/visibility_based_preconditioner.cc
index c760c5b..8104356 100644
--- a/internal/ceres/visibility_based_preconditioner.cc
+++ b/internal/ceres/visibility_based_preconditioner.cc
@@ -210,6 +210,8 @@
     num_clusters_ = ComputeSingleLinkageClustering(clustering_options,
                                                    *schur_complement_graph,
                                                    &membership);
+  } else {
+    LOG(FATAL) << "Unknown visibility clustering algorithm.";
   }
 
   CHECK_GT(num_clusters_, 0);
@@ -593,10 +595,9 @@
 
     if (index == cluster_id_to_index.size()) {
       cluster_id_to_index[cluster_id] = index;
-      CHECK_NE(index, cluster_id_to_index.size());
     }
 
-    CHECK_NE(index, num_clusters_);
+    CHECK_LT(index, num_clusters_);
     membership_vector->at(camera_id) = index;
   }
 }
diff --git a/jni/Android.mk b/jni/Android.mk
index 3f37f35..56f5db6 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -195,7 +195,7 @@
                    $(CERES_SRC_PATH)/generated/schur_eliminator_4_4_3.cc \
                    $(CERES_SRC_PATH)/generated/schur_eliminator_4_4_4.cc \
                    $(CERES_SRC_PATH)/generated/schur_eliminator_4_4_d.cc \
-		   $(CERES_SRC_PATH)/generated/partitioned_matrix_view_d_d_d.cc \
+                   $(CERES_SRC_PATH)/generated/partitioned_matrix_view_d_d_d.cc \
                    $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_2.cc \
                    $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_3.cc \
                    $(CERES_SRC_PATH)/generated/partitioned_matrix_view_2_2_4.cc \