Function Signature for stan::math::hessian, first arg

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/fwd/functor/hessian.hpp or 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

1 Like