Better error checking and reporting for linear solvers.

A lot of error checking cruft has accumulated over the years
in the various linear solvers. This change makes the error reporting
more robust and consistent across the various solvers.

Preconditioners are not covered by this change and will be the
subject of a future change.

Change-Id: Ibeb2572a1e67758953dde8d12e3abc6d1df9052d
diff --git a/internal/ceres/dense_qr_solver.cc b/internal/ceres/dense_qr_solver.cc
index d76d58b..fcc87d2 100644
--- a/internal/ceres/dense_qr_solver.cc
+++ b/internal/ceres/dense_qr_solver.cc
@@ -60,6 +60,7 @@
     return SolveUsingLAPACK(A, b, per_solve_options, x);
   }
 }
+
 LinearSolver::Summary DenseQRSolver::SolveUsingLAPACK(
     DenseSparseMatrix* A,
     const double* b,
@@ -100,21 +101,18 @@
     work_.resize(work_size);
   }
 
-  const int info = LAPACK::SolveUsingQR(lhs_.rows(),
-                                        lhs_.cols(),
-                                        lhs_.data(),
-                                        work_.rows(),
-                                        work_.data(),
-                                        rhs_.data());
-  event_logger.AddEvent("Solve");
-
   LinearSolver::Summary summary;
   summary.num_iterations = 1;
-  if (info == 0) {
+  summary.termination_type = LAPACK::SolveInPlaceUsingQR(lhs_.rows(),
+                                                         lhs_.cols(),
+                                                         lhs_.data(),
+                                                         work_.rows(),
+                                                         work_.data(),
+                                                         rhs_.data(),
+                                                         &summary.status);
+  event_logger.AddEvent("Solve");
+  if (summary.termination_type == TOLERANCE) {
     VectorRef(x, num_cols) = rhs_.head(num_cols);
-    summary.termination_type = TOLERANCE;
-  } else {
-    summary.termination_type = FAILURE;
   }
 
   event_logger.AddEvent("TearDown");
@@ -162,6 +160,7 @@
   LinearSolver::Summary summary;
   summary.num_iterations = 1;
   summary.termination_type = TOLERANCE;
+  summary.status = "Success.";
 
   event_logger.AddEvent("TearDown");
   return summary;