Fix a number of typos

Change-Id: I0038f9c91dc70c422c01305dc10fca5a22a2f0d0
diff --git a/examples/libmv_bundle_adjuster.cc b/examples/libmv_bundle_adjuster.cc
index 69a3e0e..52dea87 100644
--- a/examples/libmv_bundle_adjuster.cc
+++ b/examples/libmv_bundle_adjuster.cc
@@ -289,7 +289,7 @@
     if (file_descriptor_ < 0) {
       return false;
     }
-    // Get an endian tpye of data in the file.
+    // Get an endian type of data in the file.
     auto file_endian_type_flag = Read<unsigned char>();
     if (file_endian_type_flag == 'V') {
       file_endian_type_ = kBigEndian;
@@ -709,7 +709,7 @@
     }
 
     // Rotation of camera denoted in angle axis followed with
-    // camera translaiton.
+    // camera translation.
     double* current_camera_R_t = &all_cameras_R_t[camera->image](0);
 
     errors.emplace_back(marker.x, marker.y);
diff --git a/include/ceres/cubic_interpolation.h b/include/ceres/cubic_interpolation.h
index 29f246b..57fcdf4 100644
--- a/include/ceres/cubic_interpolation.h
+++ b/include/ceres/cubic_interpolation.h
@@ -171,7 +171,7 @@
 //
 // The function being provided can be vector valued, in which case
 // kDataDimension > 1. The dimensional slices of the function maybe
-// interleaved, or they maybe stacked, i.e, if the function has
+// interleaved, or they maybe stacked, i.e., if the function has
 // kDataDimension = 2, if kInterleaved = true, then it is stored as
 //
 //   f01, f02, f11, f12 ....
@@ -349,7 +349,7 @@
 
 // An object that implements an infinite two dimensional grid needed
 // by the BiCubicInterpolator where the source of the function values
-// is an grid of type T on the grid
+// is a grid of type T on the grid
 //
 //   [(row_start,   col_start), ..., (row_start,   col_end - 1)]
 //   [                          ...                            ]
@@ -362,7 +362,7 @@
 // The function being provided can be vector valued, in which case
 // kDataDimension > 1. The data maybe stored in row or column major
 // format and the various dimensional slices of the function maybe
-// interleaved, or they maybe stacked, i.e, if the function has
+// interleaved, or they maybe stacked, i.e., if the function has
 // kDataDimension = 2, is stored in row-major format and if
 // kInterleaved = true, then it is stored as
 //
diff --git a/include/ceres/manifold.h b/include/ceres/manifold.h
index ec4eff0..e22b59f 100644
--- a/include/ceres/manifold.h
+++ b/include/ceres/manifold.h
@@ -211,7 +211,7 @@
                      const double* x,
                      double* y_minus_x) const = 0;
 
-  // Compute the derivative of Minus(y, x) w.r.t y at y = x, i.e
+  // Compute the derivative of Minus(y, x) w.r.t y at y = x, i.e.
   //
   //   (D_1 Minus) (x, x)
   //
diff --git a/include/ceres/manifold_test_utils.h b/include/ceres/manifold_test_utils.h
index 3e61457..37841f9 100644
--- a/include/ceres/manifold_test_utils.h
+++ b/include/ceres/manifold_test_utils.h
@@ -55,7 +55,7 @@
 //
 // To verify these general requirements for a custom Manifold, use the
 // EXPECT_THAT_MANIFOLD_INVARIANTS_HOLD() macro from within a gtest test. Note
-// that additional domain-specific tests may also be prudent, e.g to verify the
+// that additional domain-specific tests may also be prudent, e.g. to verify the
 // behaviour of a Quaternion Manifold about pi.
 //
 // [1] "Integrating Generic Sensor Fusion Algorithms with Sound State
diff --git a/include/ceres/numeric_diff_first_order_function.h b/include/ceres/numeric_diff_first_order_function.h
index 612ace9..790cbcd 100644
--- a/include/ceres/numeric_diff_first_order_function.h
+++ b/include/ceres/numeric_diff_first_order_function.h
@@ -187,7 +187,7 @@
   bool Evaluate(const double* const parameters,
                 double* cost,
                 double* gradient) const override {
-    // Get the function value (cost) at the the point to evaluate.
+    // Get the function value (cost) at the point to evaluate.
     if (!(*functor_)(parameters, cost)) {
       return false;
     }
diff --git a/include/ceres/types.h b/include/ceres/types.h
index f5b66a9..be8e1d2 100644
--- a/include/ceres/types.h
+++ b/include/ceres/types.h
@@ -189,7 +189,7 @@
 // of the method. e.g., when doing sparse Cholesky factorization,
 // there are matrices for which a good ordering will give a
 // Cholesky factor with O(n) storage, where as a bad ordering will
-// result in an completely dense factor.
+// result in a completely dense factor.
 //
 // So sparse direct solvers like SPARSE_NORMAL_CHOLESKY and
 // SPARSE_SCHUR and preconditioners like SUBSET, CLUSTER_JACOBI &
diff --git a/internal/ceres/block_jacobian_writer.cc b/internal/ceres/block_jacobian_writer.cc
index e29bc1b..34cdc1b 100644
--- a/internal/ceres/block_jacobian_writer.cc
+++ b/internal/ceres/block_jacobian_writer.cc
@@ -93,7 +93,7 @@
       }
     }
     if (num_jacobian_blocks > std::numeric_limits<int>::max()) {
-      LOG(ERROR) << "Overlow error. Too many blocks in the jacobian matrix : "
+      LOG(ERROR) << "Overflow error. Too many blocks in the jacobian matrix : "
                  << num_jacobian_blocks;
       return false;
     }
@@ -156,7 +156,7 @@
         f_block_pos += jacobian_block_size;
         if (f_block_pos > std::numeric_limits<int>::max()) {
           LOG(ERROR)
-              << "Overlow error. Too many entries in the Jacobian matrix.";
+              << "Overflow error. Too many entries in the Jacobian matrix.";
           return false;
         }
       }
diff --git a/internal/ceres/block_sparse_matrix.cc b/internal/ceres/block_sparse_matrix.cc
index 0878988..f42c869 100644
--- a/internal/ceres/block_sparse_matrix.cc
+++ b/internal/ceres/block_sparse_matrix.cc
@@ -328,7 +328,7 @@
   CHECK(x != nullptr);
   CHECK(y != nullptr);
   // Single-threaded left products are always computed using a non-transpose
-  // block structure, because it has linear acess pattern to matrix elements
+  // block structure, because it has linear access pattern to matrix elements
   for (int i = 0; i < block_structure_->rows.size(); ++i) {
     int row_block_pos = block_structure_->rows[i].block.position;
     int row_block_size = block_structure_->rows[i].block.size;
diff --git a/internal/ceres/conjugate_gradients_solver.h b/internal/ceres/conjugate_gradients_solver.h
index dc948d2..fa06f16 100644
--- a/internal/ceres/conjugate_gradients_solver.h
+++ b/internal/ceres/conjugate_gradients_solver.h
@@ -96,8 +96,8 @@
 //
 // This implementation is templated over DenseVectorType and then in turn on
 // ConjugateGradientsLinearOperator, which allows us to write an abstract
-// implementaion of the Conjugate Gradients algorithm without worrying about how
-// these objects are implemented or where they are stored. In particular it
+// implementation of the Conjugate Gradients algorithm without worrying about
+// how these objects are implemented or where they are stored. In particular it
 // allows us to have a single implementation that works on CPU and GPU based
 // matrices and vectors.
 //
diff --git a/internal/ceres/context_impl.h b/internal/ceres/context_impl.h
index cc301ee..86381f4 100644
--- a/internal/ceres/context_impl.h
+++ b/internal/ceres/context_impl.h
@@ -106,7 +106,7 @@
   //  and leave no running computations on exit.
   //  This slightly penalizes multi-stream workloads, but makes it easier to
   //  avoid race conditions when  multiple-stream workload depends on results of
-  //  any preceeding gpu computations.
+  //  any preceding gpu computations.
 
   // Initializes cuBLAS, cuSOLVER, and cuSPARSE contexts, creates an
   // asynchronous CUDA stream, and associates the stream with the contexts.
diff --git a/internal/ceres/cuda_block_structure.cc b/internal/ceres/cuda_block_structure.cc
index 2a42d90..b5ee3a3 100644
--- a/internal/ceres/cuda_block_structure.cc
+++ b/internal/ceres/cuda_block_structure.cc
@@ -98,7 +98,7 @@
     }
     num_row_blocks_e_ = row_block_id + 1;
     // In E sub-matrix there is exactly a single E cell in the row
-    // since E cells are stored separately from F cells, crs-compatiblity of
+    // since E cells are stored separately from F cells, crs-compatibility of
     // F sub-matrix only breaks if there are more than 2 cells in row (that
     // is, more than 1 cell in F sub-matrix)
     if (num_cells > 2 && row_block_size > 1) {
diff --git a/internal/ceres/cuda_sparse_cholesky.cc b/internal/ceres/cuda_sparse_cholesky.cc
index d829242..3e06877 100644
--- a/internal/ceres/cuda_sparse_cholesky.cc
+++ b/internal/ceres/cuda_sparse_cholesky.cc
@@ -186,7 +186,7 @@
 class CERES_NO_EXPORT CudaSparseCholeskyImpl final : public SparseCholesky {
  public:
   static_assert(std::is_same_v<Scalar, float> || std::is_same_v<Scalar, double>,
-                "Scalar type is unsuported by cuDSS");
+                "Scalar type is unsupported by cuDSS");
   static constexpr cudaDataType_t kCuDSSScalar =
       std::is_same_v<Scalar, float> ? CUDA_R_32F : CUDA_R_64F;
 
diff --git a/internal/ceres/cuda_sparse_cholesky.h b/internal/ceres/cuda_sparse_cholesky.h
index e147633..0e4b1f3 100644
--- a/internal/ceres/cuda_sparse_cholesky.h
+++ b/internal/ceres/cuda_sparse_cholesky.h
@@ -49,7 +49,7 @@
 // This class is a factory for implementation of sparse cholesky that uses cuDSS
 // on CUDA capable GPU's to solve sparse linear systems. Scalar controls the
 // precision used during computations, currently float and double are supported.
-// Details of implementation are incapsulated into cuda_sparse_cholesky.cc
+// Details of implementation are encapsulated into cuda_sparse_cholesky.cc
 template <typename Scalar = double>
 class CERES_NO_EXPORT CudaSparseCholesky : public SparseCholesky {
  public:
diff --git a/internal/ceres/cuda_streamed_buffer.h b/internal/ceres/cuda_streamed_buffer.h
index e6296aa..4daa595 100644
--- a/internal/ceres/cuda_streamed_buffer.h
+++ b/internal/ceres/cuda_streamed_buffer.h
@@ -165,7 +165,7 @@
   //
   // b. Copying from regular memory
   // In this case a copy from regular memory to page-locked memory is required
-  // in order to get asynchrnonous operation. Because pinned memory on host-side
+  // in order to get asynchronous operation. Because pinned memory on host-side
   // is reused, additional synchronization is required. On each iteration method
   // the following actions are performed:
   //  - Wait till previous copy operation in stream is completed
diff --git a/internal/ceres/evaluation_callback_test.cc b/internal/ceres/evaluation_callback_test.cc
index 7ce110c..c921566 100644
--- a/internal/ceres/evaluation_callback_test.cc
+++ b/internal/ceres/evaluation_callback_test.cc
@@ -151,7 +151,7 @@
       EXPECT_EQ(evaluate_last_parameter_hash, incoming_parameter_hash);
     }
 
-    // Check: Parameter matches value in in parameter blocks during prepare.
+    // Check: Parameter matches value in parameter blocks during prepare.
     EXPECT_EQ(prepare_parameter_hash, incoming_parameter_hash);
 
     // Check: jacobians are requested if they were in PrepareForEvaluation().
diff --git a/internal/ceres/line_search.cc b/internal/ceres/line_search.cc
index 749345a..fd33328 100644
--- a/internal/ceres/line_search.cc
+++ b/internal/ceres/line_search.cc
@@ -634,7 +634,7 @@
     // bracketing phase: step_size_{k+1} \in [step_size_k, step_size_k *
     // factor]. However this does not account for the function returning invalid
     // values which we support, in which case we need to contract the step size
-    // whilst ensuring that we do not invert the bracket, i.e, we require that:
+    // whilst ensuring that we do not invert the bracket, i.e., we require that:
     // step_size_{k-1} <= step_size_{k+1} < step_size_k.
     const double min_step_size =
         current.value_is_valid ? current.x : previous.x;
diff --git a/internal/ceres/parallel_for.h b/internal/ceres/parallel_for.h
index 97fc95e..0c76aaf 100644
--- a/internal/ceres/parallel_for.h
+++ b/internal/ceres/parallel_for.h
@@ -55,7 +55,7 @@
 // num_threads. It will execute all the work on the calling thread if
 // num_threads or (end - start) is equal to 1.
 // Depending on function signature, it will be supplied with either loop index
-// or a range of loop indicies; function can also be supplied with thread_id.
+// or a range of loop indices; function can also be supplied with thread_id.
 // The following function signatures are supported:
 //  - Functions accepting a single loop index:
 //     - [](int index) { ... }
diff --git a/internal/ceres/parallel_invoke.h b/internal/ceres/parallel_invoke.h
index 73c3aea..c9cc29c 100644
--- a/internal/ceres/parallel_invoke.h
+++ b/internal/ceres/parallel_invoke.h
@@ -236,8 +236,8 @@
       // num_work_blocks - num_base_p1_sized_blocks of size base_block_size
       //
       // Then, start index of the block #block_id is given by a total
-      // length of preceeding blocks:
-      //  * Total length of preceeding blocks of size base_block_size + 1:
+      // length of preceding blocks:
+      //  * Total length of preceding blocks of size base_block_size + 1:
       //     min(block_id, num_base_p1_sized_blocks) * (base_block_size + 1)
       //
       //  * Total length of preceeding blocks of size base_block_size:
diff --git a/internal/ceres/partitioned_matrix_view_impl.h b/internal/ceres/partitioned_matrix_view_impl.h
index 322d00f..b2802ad 100644
--- a/internal/ceres/partitioned_matrix_view_impl.h
+++ b/internal/ceres/partitioned_matrix_view_impl.h
@@ -439,7 +439,7 @@
 }
 
 // Similar to the code in RightMultiplyAndAccumulateE, except instead of the
-// matrix vector multiply its an outer product.
+// matrix vector multiply it's an outer product.
 //
 //    block_diagonal = block_diagonal(E'E)
 //
@@ -523,7 +523,7 @@
 }
 
 // Similar to the code in RightMultiplyAndAccumulateF, except instead of the
-// matrix vector multiply its an outer product.
+// matrix vector multiply it's an outer product.
 //
 //   block_diagonal = block_diagonal(F'F)
 //
diff --git a/internal/ceres/program_evaluator.h b/internal/ceres/program_evaluator.h
index a9bd65a..080de2a 100644
--- a/internal/ceres/program_evaluator.h
+++ b/internal/ceres/program_evaluator.h
@@ -170,7 +170,7 @@
       jacobian->SetZero(options_.context, options_.num_threads);
     }
 
-    // Each thread gets it's own cost and evaluate scratch space.
+    // Each thread gets its own cost and evaluate scratch space.
     for (int i = 0; i < options_.num_threads; ++i) {
       evaluate_scratch_[i].cost = 0.0;
       if (gradient != nullptr) {
diff --git a/internal/ceres/reorder_program.cc b/internal/ceres/reorder_program.cc
index 6753df9..dadf851 100644
--- a/internal/ceres/reorder_program.cc
+++ b/internal/ceres/reorder_program.cc
@@ -461,7 +461,7 @@
   }
 
   if (parameter_block_ordering->NumGroups() == 1) {
-    // If the user supplied an parameter_block_ordering with just one
+    // If the user supplied a parameter_block_ordering with just one
     // group, it is equivalent to the user supplying nullptr as an
     // parameter_block_ordering. Ceres is completely free to choose the
     // parameter block ordering as it sees fit. For Schur type solvers,
diff --git a/internal/ceres/rotation_test.cc b/internal/ceres/rotation_test.cc
index ffa5ff3..0b7b385 100644
--- a/internal/ceres/rotation_test.cc
+++ b/internal/ceres/rotation_test.cc
@@ -81,7 +81,7 @@
 // double actual_quaternion[4];
 // EXPECT_THAT(actual_quaternion, IsNearQuaternion(expected_quaternion));
 MATCHER_P(IsNearQuaternion, expected, "") {
-  // Quaternions are equivalent upto a sign change. So we will compare
+  // Quaternions are equivalent up to a sign change. So we will compare
   // both signs before declaring failure.
   bool is_near = true;
   // NOTE: near (and far) can be defined as macros on the Windows platform (for
diff --git a/internal/ceres/schur_eliminator.h b/internal/ceres/schur_eliminator.h
index 06eb47b..77bca54 100644
--- a/internal/ceres/schur_eliminator.h
+++ b/internal/ceres/schur_eliminator.h
@@ -84,7 +84,7 @@
 //
 // The rows of A are ordered so that for every variable block in y,
 // all the rows containing that variable block occur as a vertically
-// contiguous block. i.e the matrix A looks like
+// contiguous block. i.e. the matrix A looks like
 //
 //              E                 F                   chunk
 //  A = [ y1   0   0   0 |  z1    0    0   0    z5]     1
@@ -136,7 +136,7 @@
 //  1. E'E is a block diagonal matrix.
 //
 //  2. When E'F is computed, only the terms within a single chunk
-//  interact, i.e for y1 column blocks when transposed and multiplied
+//  interact, i.e. for y1 column blocks when transposed and multiplied
 //  with F, the only non-zero contribution comes from the blocks in
 //  chunk1.
 //
diff --git a/internal/ceres/schur_eliminator_impl.h b/internal/ceres/schur_eliminator_impl.h
index f018b42..545f906 100644
--- a/internal/ceres/schur_eliminator_impl.h
+++ b/internal/ceres/schur_eliminator_impl.h
@@ -505,7 +505,7 @@
 }
 
 // Compute the outer product F'E(E'E)^{-1}E'F and subtract it from the
-// Schur complement matrix, i.e
+// Schur complement matrix, i.e.
 //
 //  S -= F'E(E'E)^{-1}E'F.
 template <int kRowBlockSize, int kEBlockSize, int kFBlockSize>
diff --git a/internal/ceres/trust_region_minimizer.cc b/internal/ceres/trust_region_minimizer.cc
index 9d9b8e8..dba7842 100644
--- a/internal/ceres/trust_region_minimizer.cc
+++ b/internal/ceres/trust_region_minimizer.cc
@@ -547,7 +547,7 @@
   // region step so this ratio is a good measure of the quality of
   // the trust region radius. However, when inner iterations are
   // being used, cost_change includes the contribution of the
-  // inner iterations and its not fair to credit it all to the
+  // inner iterations and it's not fair to credit it all to the
   // trust region algorithm. So we change the ratio to be
   //
   //                              cost_change