What’s the function signature need to look like for the first argument of stan::math::hessian?
I have a signature like:
template <typename T_x>
inline const return_type_t<T_x>
f2(const std::vector<T_x> &x)
and the compiler doesn’t like the first argument, gives:
<unresolved overloaded function type>.
How should I define
const F &, the first argument for stan::math::hessian?
This depends whether you are including
math/mix/functor/hessian.hpp, but both of their requirements are documented in the doxygen comment on the function.
For the mix method, you need a function which satisfies:
fvar<var> operator()(const Eigen::Matrix<fvar<var>, Eigen::Dynamic, 1>&)
I think your
f2 would work if changed from using std::vectors to Eigen vectors
Not working, additional advice?
I’m looking in the test cases, there’s probably some instantiation there, or at least there should be.
Yeah there’s no tests for this?
The general autodiff framework uses the
hessian function and tests it against finite differences for nearly every function in the Math library:
Not quite a unit test for the function itself, but if it was wrong this would certainly notice
There’s also an example in the StanHeaders vignette: Using the Stan Math C++ Library
Under the Higher-order functions section