Enable support for dumping trust region minimizer problems.

This support was broken due to the TrustRegionMinimizer refactoring.
It is now enabled again, with the responsibilty for dumping the
problem shifted to the individual TrustRegionStrategy.

There is however one wrinkle, which is perhaps an indication of
poor design to start with. The LinearLeastSquaresProblemProto
carries in it num_eliminate_blocks, something which does not
exist anymore. More importantly, the TrustRegionStrategy does not
have access to this quantity anymore.

Dealing with this will be the subject of a future change.

Change-Id: I358adf6a2e386f4940b617bf950d6c7e87d2635d
diff --git a/internal/ceres/dogleg_strategy.cc b/internal/ceres/dogleg_strategy.cc
index a330ad2..03c0d78 100644
--- a/internal/ceres/dogleg_strategy.cc
+++ b/internal/ceres/dogleg_strategy.cc
@@ -34,6 +34,7 @@
 #include "Eigen/Dense"
 #include "ceres/array_utils.h"
 #include "ceres/internal/eigen.h"
+#include "ceres/linear_least_squares_problems.h"
 #include "ceres/linear_solver.h"
 #include "ceres/polynomial.h"
 #include "ceres/sparse_matrix.h"
@@ -127,7 +128,7 @@
   ComputeCauchyPoint(jacobian);
 
   LinearSolver::Summary linear_solver_summary =
-      ComputeGaussNewtonStep(jacobian, residuals);
+      ComputeGaussNewtonStep(per_solve_options, jacobian, residuals);
 
   TrustRegionStrategy::Summary summary;
   summary.residual_norm = linear_solver_summary.residual_norm;
@@ -507,6 +508,7 @@
 }
 
 LinearSolver::Summary DoglegStrategy::ComputeGaussNewtonStep(
+    const PerSolveOptions& per_solve_options,
     SparseMatrix* jacobian,
     const double* residuals) {
   const int n = jacobian->num_cols();
@@ -561,6 +563,21 @@
                                                   solve_options,
                                                   gauss_newton_step_.data());
 
+    if (per_solve_options.dump_format_type == CONSOLE ||
+        (per_solve_options.dump_format_type != CONSOLE &&
+         !per_solve_options.dump_filename_base.empty())) {
+      if (!DumpLinearLeastSquaresProblem(per_solve_options.dump_filename_base,
+                                         per_solve_options.dump_format_type,
+                                         jacobian,
+                                         solve_options.D,
+                                         residuals,
+                                         gauss_newton_step_.data(),
+                                         0)) {
+        LOG(ERROR) << "Unable to dump trust region problem."
+                   << " Filename base: " << per_solve_options.dump_filename_base;
+      }
+    }
+
     if (linear_solver_summary.termination_type == FAILURE ||
         !IsArrayValid(n, gauss_newton_step_.data())) {
       mu_ *= mu_increase_factor_;