Somewhat fictional given my time constraints at the moment but I was looking at wrapping single-function performance testing the way Bob wrapped single-function AD testing and there’s a bunch of code like this:
Eigen::VectorXd grad_ad;
double fx_ad;
gradient<F>(f, x, fx_ad, grad_ad);
expect_near("test_gradient fx = fx_ad", fx, fx_ad);
Using parameter packs and tuples in an implementation of gradient
this could instead look like:
auto g = gradient(f, ...);
Where ...
is whatever arguments f
normally takes and the return value g
is std::tuple<Eigen::VectorXd, double>
or similar. f
could also be a functor.
I think the main advantage would be avoiding the need to specify functors just to adapt stuff to the gradient/hessian functions.