Skip to content

Instantly share code, notes, and snippets.

@ahmadyan
Created November 12, 2018 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadyan/80e543ddfd11d8b37594dae400ffd0f3 to your computer and use it in GitHub Desktop.
Save ahmadyan/80e543ddfd11d8b37594dae400ffd0f3 to your computer and use it in GitHub Desktop.
Auto diff for Rosenbrock function using Ceres' Jets
auto rosenbrockCostFunction = new ceres::AutoDiffCostFunction<Rosenbrock, 1, 1, 1>(new Rosenbrock());
constexpr double x = 1, y = 3;
parameters[0][0] = x;
parameters[1][0] = y;
rosenbrockCostFunction->Evaluate(parameters, &residuals, jacobians);
cout << residuals << " df/dx=" << jacobians[0][0] << " df/dy" << jacobians[1][0] << "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment