Check that the Dogleg Solver uses a direct solver.

Change-Id: I7947361542aecded0adc0ca775b5b0011ce9fb23
diff --git a/internal/ceres/solver_impl.cc b/internal/ceres/solver_impl.cc
index 877a5af..ca35adc 100644
--- a/internal/ceres/solver_impl.cc
+++ b/internal/ceres/solver_impl.cc
@@ -452,6 +452,16 @@
 
 LinearSolver* SolverImpl::CreateLinearSolver(Solver::Options* options,
                                              string* error) {
+  if (options->trust_region_strategy_type == DOGLEG) {
+    if (options->linear_solver_type == ITERATIVE_SCHUR ||
+        options->linear_solver_type == CGNR) {
+      *error = "DOGLEG only supports exact factorization based linear "
+               "solvers. If you want to use an iterative solver please "
+               "use LEVENBERG_MARQUARDT as the trust_region_strategy_type";
+      return NULL;
+    }
+  }
+
 #ifdef CERES_NO_SUITESPARSE
   if (options->linear_solver_type == SPARSE_NORMAL_CHOLESKY &&
       options->sparse_linear_algebra_library == SUITE_SPARSE) {