Use Ridders' method in GradientChecker.

Using Ridders' method gives orders of magnitude more accuracy compared
to central differences. This will make things slower, but this is
primarily a testing/debugging feature and the speed hit is not a
concern. This should also reduce the false positive rates when users
enable check_gradients. This is reflected the increased sensitivity of
the tests for GradientChecker.

https://github.com/ceres-solver/ceres-solver/issues/554

Change-Id: I6b871c72df55be1c31175ba062cf3c1e94e4b662
diff --git a/internal/ceres/gradient_checker.cc b/internal/ceres/gradient_checker.cc
index 411a67f..ef56666 100644
--- a/internal/ceres/gradient_checker.cc
+++ b/internal/ceres/gradient_checker.cc
@@ -130,9 +130,9 @@
     local_parameterizations_.resize(function->parameter_block_sizes().size(),
                                     NULL);
   }
-  DynamicNumericDiffCostFunction<CostFunction, CENTRAL>*
+  DynamicNumericDiffCostFunction<CostFunction, RIDDERS>*
       finite_diff_cost_function =
-      new DynamicNumericDiffCostFunction<CostFunction, CENTRAL>(
+      new DynamicNumericDiffCostFunction<CostFunction, RIDDERS>(
           function, DO_NOT_TAKE_OWNERSHIP, options);
   finite_diff_cost_function_.reset(finite_diff_cost_function);
 
diff --git a/internal/ceres/gradient_checker_test.cc b/internal/ceres/gradient_checker_test.cc
index cd194a7..b2dd35e 100644
--- a/internal/ceres/gradient_checker_test.cc
+++ b/internal/ceres/gradient_checker_test.cc
@@ -48,6 +48,7 @@
 namespace internal {
 
 using std::vector;
+const double kTolerance = 1e-12;
 
 // We pick a (non-quadratic) function whose derivative are easy:
 //
@@ -154,7 +155,7 @@
         if (jacobians[j]) {
           for (int u = 0; u < parameter_block_sizes()[j]; ++u) {
             // See comments before class.
-            jacobians[j][u] = -f * a_[j][u] + 0.001;
+            jacobians[j][u] = -f * a_[j][u] + kTolerance;
           }
         }
       }
@@ -168,7 +169,7 @@
   vector<vector<double>> a_;  // our vectors.
 };
 
-const double kTolerance = 1e-6;
+
 
 static void CheckDimensions(const GradientChecker::ProbeResults& results,
                             const std::vector<int>& parameter_sizes,