Various minor fixes.

1. Unused variable warnings and fixes.
2. Minor documentation update.

Change-Id: I815588a5806df1030a7c8750f4fb594c503f8998
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eac5816..80d6f22 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -617,7 +617,7 @@
 # GCC is not strict enough by default, so enable most of the warnings.
 IF ("${UNIX}")
   SET(CMAKE_CXX_FLAGS
-      "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused -Wno-unused-parameter")
+      "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-return-type-c-linkage")
 ENDIF ("${UNIX}")
 
 ADD_SUBDIRECTORY(internal/ceres)
diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst
index 4e9e967..5df765b 100644
--- a/docs/source/introduction.rst
+++ b/docs/source/introduction.rst
@@ -60,11 +60,14 @@
          :ref:`chapter-tutorial`.
 
 .. [#f2] While there is some debate as to who invented the method of
-         Least Squares [Stigler]_, there is no debate that it was Carl
-         Friedrich brought it to the attention of the world. Using
-         just 22 observations of the newly discovered asteroid Ceres,
-         Gauss used the method of least squares to correctly predict
-         when and where the asteroid will emerge from behind the Sun
+         Least Squares [Stigler]_, there is no debate that it was
+         `Carl Friedrich Gauss
+         <http://en.wikipedia.org/wiki/Carl_Friedrich_Gauss>`_ who
+         brought it to the attention of the world. Using just 22
+         observations of the newly discovered asteroid `Ceres
+         <http://en.wikipedia.org/wiki/Ceres_(dwarf_planet)>`_, Gauss
+         used the method of least squares to correctly predict when
+         and where the asteroid will emerge from behind the Sun
          [TenenbaumDirector]_. We named our solver after Ceres to
          celebrate this seminal event in the history of astronomy,
          statistics and optimization.
diff --git a/docs/source/modeling.rst b/docs/source/modeling.rst
index 9235094..d8d73bf 100644
--- a/docs/source/modeling.rst
+++ b/docs/source/modeling.rst
@@ -988,30 +988,127 @@
 
 .. function:: ResidualBlockId Problem::AddResidualBlock(CostFunction* cost_function, LossFunction* loss_function, const vector<double*> parameter_blocks)
 
+   Add a residual block to the overall cost function. The cost
+   function carries with it information about the sizes of the
+   parameter blocks it expects. The function checks that these match
+   the sizes of the parameter blocks listed in parameter_blocks. The
+   program aborts if a mismatch is detected. loss_function can be
+   NULL, in which case the cost of the term is just the squared norm
+   of the residuals.
+
+   The user has the option of explicitly adding the parameter blocks
+   using AddParameterBlock. This causes additional correctness
+   checking; however, AddResidualBlock implicitly adds the parameter
+   blocks if they are not present, so calling AddParameterBlock
+   explicitly is not required.
+
+   The Problem object by default takes ownership of the
+   cost_function and loss_function pointers. These objects remain
+   live for the life of the Problem object. If the user wishes to
+   keep control over the destruction of these objects, then they can
+   do this by setting the corresponding enums in the Options struct.
+
+   Note: Even though the Problem takes ownership of cost_function
+   and loss_function, it does not preclude the user from re-using
+   them in another residual block. The destructor takes care to call
+   delete on each cost_function or loss_function pointer only once,
+   regardless of how many residual blocks refer to them.
+
+   Example usage:
+
+   .. code-block:: c++
+
+      double x1[] = {1.0, 2.0, 3.0};
+      double x2[] = {1.0, 2.0, 5.0, 6.0};
+      double x3[] = {3.0, 6.0, 2.0, 5.0, 1.0};
+
+      Problem problem;
+
+      problem.AddResidualBlock(new MyUnaryCostFunction(...), NULL, x1);
+      problem.AddResidualBlock(new MyBinaryCostFunction(...), NULL, x2, x1);
+
 
 .. function:: void Problem::AddParameterBlock(double* values, int size, LocalParameterization* local_parameterization)
-              void Problem::AddParameterBlock(double* values, int size)
+
+   Add a parameter block with appropriate size to the problem.
+   Repeated calls with the same arguments are ignored. Repeated calls
+   with the same double pointer but a different size results in
+   undefined behaviour.
+
+.. function:: void Problem::AddParameterBlock(double* values, int size)
+
+   Add a parameter block with appropriate size and parameterization to
+   the problem. Repeated calls with the same arguments are
+   ignored. Repeated calls with the same double pointer but a
+   different size results in undefined behaviour.
+
+.. function:: void Problem::RemoveResidualBlock(ResidualBlockId residual_block)
+
+   Remove a parameter block from the problem. The parameterization of
+   the parameter block, if it exists, will persist until the deletion
+   of the problem (similar to cost/loss functions in residual block
+   removal). Any residual blocks that depend on the parameter are also
+   removed, as described above in RemoveResidualBlock().  If
+   Problem::Options::enable_fast_parameter_block_removal is true, then
+   the removal is fast (almost constant time). Otherwise, removing a
+   parameter block will incur a scan of the entire Problem object.
+
+   WARNING: Removing a residual or parameter block will destroy the
+   implicit ordering, rendering the jacobian or residuals returned
+   from the solver uninterpretable. If you depend on the evaluated
+   jacobian, do not use remove! This may change in a future release.
+
+.. function:: void Problem::RemoveResidualBlock(ResidualBlockId residual_block)
+
+   Remove a residual block from the problem. Any parameters that the residual
+   block depends on are not removed. The cost and loss functions for the
+   residual block will not get deleted immediately; won't happen until the
+   problem itself is deleted.
+
+   WARNING: Removing a residual or parameter block will destroy the implicit
+   ordering, rendering the jacobian or residuals returned from the solver
+   uninterpretable. If you depend on the evaluated jacobian, do not use
+   remove! This may change in a future release.
+   Hold the indicated parameter block constant during optimization.
 
 
 .. function:: void Problem::SetParameterBlockConstant(double* values)
 
+   Hold the indicated parameter block constant during optimization.
+
 .. function:: void Problem::SetParameterBlockVariable(double* values)
 
+   Allow the indicated parameter to vary during optimization.
+
 
 .. function:: void Problem::SetParameterization(double* values, LocalParameterization* local_parameterization)
 
+   Set the local parameterization for one of the parameter blocks.
+   The local_parameterization is owned by the Problem by default. It
+   is acceptable to set the same parameterization for multiple
+   parameters; the destructor is careful to delete local
+   parameterizations only once. The local parameterization can only be
+   set once per parameter, and cannot be changed once set.
 
 .. function:: int Problem::NumParameterBlocks() const
 
+   Number of parameter blocks in the problem. Always equals
+   parameter_blocks().size() and parameter_block_sizes().size().
 
 .. function:: int Problem::NumParameters() const
 
+   The size of the parameter vector obtained by summing over the sizes
+   of all the parameter blocks.
 
 .. function:: int Problem::NumResidualBlocks() const
 
+   Number of residual blocks in the problem. Always equals
+   residual_blocks().size().
 
 .. function:: int Problem::NumResiduals() const
 
+   The size of the residual vector obtained by summing over the sizes
+   of all of the residual blocks.
 
 
 ``rotation.h``
diff --git a/docs/source/version_history.rst b/docs/source/version_history.rst
index dbfc758..8de716c 100644
--- a/docs/source/version_history.rst
+++ b/docs/source/version_history.rst
@@ -9,6 +9,10 @@
 
 New Features
 ------------
+#. Problem now supports removal of ParameterBlocks and
+   ResidualBlocks. There is a space/time tradeoff in doing this which
+   is controlled by
+   ``Problem::Options::enable_fast_parameter_block_removal`.
 
 #. Ceres now supports Line search based optimization algorithms in
    addition to trust region algorithms. Currently there is support for
@@ -39,11 +43,13 @@
 #. Automatic differenatiation with a dynamic number of parameter
    blocks. (Based on an idea by Thad Hughes).
 
-#. Speeded up problem construction destruction.
+#. Speeded up problem construction and destruction.
 
 #. Added matrix adapters to ``rotation.h`` so that the rotation matrix
    routines can work with row and column major matrices. (Markus Moll)
 
+#. ``SCHUR_JACOBI`` can now be used without ``SuiteSparse``.
+
 Bug Fixes
 ---------
 
diff --git a/internal/ceres/dogleg_strategy_test.cc b/internal/ceres/dogleg_strategy_test.cc
index 9e2ed9f..24c526e 100644
--- a/internal/ceres/dogleg_strategy_test.cc
+++ b/internal/ceres/dogleg_strategy_test.cc
@@ -206,10 +206,7 @@
   DoglegStrategy strategy(options_);
   TrustRegionStrategy::PerSolveOptions pso;
 
-  TrustRegionStrategy::Summary summary = strategy.ComputeStep(pso,
-                                                              jacobian_.get(),
-                                                              residual_.data(),
-                                                              x_.data());
+  strategy.ComputeStep(pso, jacobian_.get(), residual_.data(), x_.data());
 
   // Check if the basis is orthonormal.
   const Matrix basis = strategy.subspace_basis();
@@ -288,4 +285,3 @@
 
 }  // namespace internal
 }  // namespace ceres
-
diff --git a/internal/ceres/schur_complement_solver_test.cc b/internal/ceres/schur_complement_solver_test.cc
index 71c6cfd..1820bc9 100644
--- a/internal/ceres/schur_complement_solver_test.cc
+++ b/internal/ceres/schur_complement_solver_test.cc
@@ -75,20 +75,12 @@
 
     // Gold standard solutions using dense QR factorization.
     DenseSparseMatrix dense_A(triplet_A);
-    LinearSolver::Summary summary1 =
-        qr->Solve(&dense_A,
-                  b.get(),
-                  LinearSolver::PerSolveOptions(),
-                  sol.get());
+    qr->Solve(&dense_A, b.get(), LinearSolver::PerSolveOptions(), sol.get());
 
     // Gold standard solution with appended diagonal.
     LinearSolver::PerSolveOptions per_solve_options;
     per_solve_options.D = D.get();
-    LinearSolver::Summary summary2 =
-        qr->Solve(&dense_A,
-                  b.get(),
-                  per_solve_options,
-                  sol_d.get());
+    qr->Solve(&dense_A, b.get(), per_solve_options, sol_d.get());
   }
 
   void ComputeAndCompareSolutions(
diff --git a/internal/ceres/solver_impl.cc b/internal/ceres/solver_impl.cc
index c6ee86a..803b711 100644
--- a/internal/ceres/solver_impl.cc
+++ b/internal/ceres/solver_impl.cc
@@ -490,9 +490,6 @@
 
     double post_process_start_time = WallTimeInSeconds();
 
-
-
-
     // Evaluate the final cost, residual vector and the jacobian
     // matrix if requested by the user.
     if (options.return_final_residuals ||
@@ -820,6 +817,8 @@
 
     // Ensure the program state is set to the user parameters on the way out.
     original_program->SetParameterBlockStatePtrsToUserStatePtrs();
+    summary->postprocessor_time_in_seconds =
+        WallTimeInSeconds() - post_process_start_time;
     return;
   }
 
@@ -886,6 +885,9 @@
       summary->termination_type = NUMERICAL_FAILURE;
       summary->error = "Unable to evaluate the final cost.";
       LOG(ERROR) << summary->error;
+
+      summary->postprocessor_time_in_seconds =
+          WallTimeInSeconds() - post_process_start_time;
       return;
     }
   }
@@ -901,9 +903,6 @@
   summary->jacobian_evaluation_time_in_seconds =
       FindWithDefault(evaluator_time_statistics, "Evaluator::Jacobian", 0.0);
 
-  summary->postprocessor_time_in_seconds =
-      WallTimeInSeconds() - post_process_start_time;
-
   // Stick a fork in it, we're done.
   summary->postprocessor_time_in_seconds =
       WallTimeInSeconds() - post_process_start_time;