Documentation update.
Change-Id: Ica8681f4bb58c60349d0dae453c652f2522eebf6
diff --git a/examples/quadratic_auto_diff.cc b/examples/quadratic_auto_diff.cc
index ea7fae9..1e2f3ef 100644
--- a/examples/quadratic_auto_diff.cc
+++ b/examples/quadratic_auto_diff.cc
@@ -44,10 +44,11 @@
using ceres::Solver;
using ceres::Solve;
-// A templated cost function that implements the residual r = 10 - x. The method
-// Map is templated so that we can then use an automatic differentiation wrapper
-// around it to generate its derivatives.
-class QuadraticCostFunction {
+// A templated cost functor that implements the residual r = 10 -
+// x. The method operator() is templated so that we can then use an
+// automatic differentiation wrapper around it to generate its
+// derivatives.
+class QuadraticCostFunctor {
public:
template <typename T> bool operator()(const T* const x, T* residual) const {
residual[0] = T(10.0) - x[0];
@@ -69,8 +70,8 @@
// Set up the only cost function (also known as residual). This uses
// auto-differentiation to obtain the derivative (jacobian).
problem.AddResidualBlock(
- new AutoDiffCostFunction<QuadraticCostFunction, 1, 1>(
- new QuadraticCostFunction),
+ new AutoDiffCostFunction<QuadraticCostFunctor, 1, 1>(
+ new QuadraticCostFunctor),
NULL,
&x);
diff --git a/examples/quadratic_numeric_diff.cc b/examples/quadratic_numeric_diff.cc
index 8ec88ef..1082616 100644
--- a/examples/quadratic_numeric_diff.cc
+++ b/examples/quadratic_numeric_diff.cc
@@ -38,24 +38,16 @@
using ceres::NumericDiffCostFunction;
using ceres::CENTRAL;
-using ceres::SizedCostFunction;
using ceres::CostFunction;
using ceres::Problem;
using ceres::Solver;
using ceres::Solve;
-class ResidualWithNoDerivative
- : public SizedCostFunction<1 /* number of residuals */,
- 1 /* size of first parameter */> {
+// A cost functor that implements the residual r = 10 - x.
+class QuadraticCostFunctor {
public:
- virtual ~ResidualWithNoDerivative() {}
- virtual bool Evaluate(double const* const* parameters,
- double* residuals,
- double** jacobians) const {
- (void) jacobians; // Ignored; filled in by numeric differentiation.
-
- // f(x) = 10 - x.
- residuals[0] = 10 - parameters[0][0];
+ bool operator()(const double* const x, double* residual) const {
+ residual[0] = 10.0 - x[0];
return true;
}
};
@@ -71,8 +63,8 @@
// Set up the only cost function (also known as residual). This uses
// numeric differentiation to obtain the derivative (jacobian).
CostFunction* cost =
- new NumericDiffCostFunction<ResidualWithNoDerivative, CENTRAL, 1, 1> (
- new ResidualWithNoDerivative, ceres::TAKE_OWNERSHIP);
+ new NumericDiffCostFunction<QuadraticCostFunctor, CENTRAL, 1, 1> (
+ new QuadraticCostFunctor);
// Build the problem.
Problem problem;