From c62bb845cd2e66a7def39f54f2345f78fd23098a Mon Sep 17 00:00:00 2001 From: Sameer Agarwal Date: Sun, 8 Feb 2015 10:53:37 -0800 Subject: [PATCH] Fix sampled_function.cc to use the new CubicInterpolator API. Change-Id: I1b2063505dc2296c141989c93a939175d5dba7e1 --- examples/sampled_function.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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;