diff --git a/examples/sampled_function.cc b/examples/sampled_function.cc index 44566f41f..03d84fbce 100644 --- a/examples/sampled_function.cc +++ b/examples/sampled_function.cc @@ -35,6 +35,7 @@ #include "ceres/cubic_interpolation.h" #include "glog/logging.h" +using ceres::Array1D; using ceres::CubicInterpolator; using ceres::AutoDiffCostFunction; using ceres::CostFunction; @@ -45,7 +46,8 @@ using ceres::Solve; // A simple cost functor that interfaces an interpolated table of // values with automatic differentiation. struct InterpolatedCostFunctor { - explicit InterpolatedCostFunctor(const CubicInterpolator& interpolator) + explicit InterpolatedCostFunctor( + const CubicInterpolator >& interpolator) : interpolator_(interpolator) { } @@ -53,13 +55,14 @@ struct InterpolatedCostFunctor { return interpolator_.Evaluate(*x, residuals); } - static CostFunction* Create(const CubicInterpolator& interpolator) { + static CostFunction* Create( + const CubicInterpolator >& interpolator) { return new AutoDiffCostFunction( new InterpolatedCostFunctor(interpolator)); } private: - const CubicInterpolator& interpolator_; + const CubicInterpolator >& interpolator_; }; int main(int argc, char** argv) { @@ -72,7 +75,8 @@ int main(int argc, char** argv) { values[i] = (i - 4.5) * (i - 4.5); } - CubicInterpolator interpolator(values, kNumSamples); + Array1D array(values, kNumSamples); + CubicInterpolator > interpolator(array); double x = 1.0; Problem problem;