Something changed with the Hessian calculations in the last version or two of Stan Math and now the StanHeaders vignette will not build with it.
The line in question is
and the relevant parts of the compiler errors are:
file19611604473d.cpp:41:62: required from ‘H(Eigen::VectorXd, Eigen::VectorXd)::<lambda(auto:36)> [with auto:36 = Eigen::Matrix<stan::math::fvarstan::math::var, -1, 1>]’
/tmp/Rtmp6OO1UC/Rinst184f61b2d181/StanHeaders/include/stan/math/mix/functor/hessian.hpp:61:26: required from ‘void stan::math::hessian(const F&, const Eigen::Matrix<double, -1, 1>&, double&, Eigen::Matrix<double, -1, 1>&, Eigen::Matrix<double, -1, -1>&) [with F = H(Eigen::VectorXd, Eigen::VectorXd)::<lambda(auto:36)>]’
file19611604473d.cpp:42:40: required from here
/home/ben/r-devel/library/RcppEigen/include/Eigen/src/Core/functors/BinaryFunctors.h:324:95: error: no type named ‘ReturnType’ in ‘struct Eigen::ScalarBinaryOpTraits<stan::math::fvarstan::math::var, double, Eigen::internal::scalar_difference_op<stan::math::fvarstan::math::var, double> >’
typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_difference_op>::ReturnType result_type;
^~~~~~~~~~~
file19611604473d.cpp:41:53: error: invalid use of void expression
stan::math::hessian([&a](auto x) { return dot_self(subtract(x, a)); },
~~~~~~~^
In file included from file19611604473d.cpp:5:
/tmp/Rtmp6OO1UC/Rinst184f61b2d181/StanHeaders/include/stan/math/mix/functor/hessian.hpp: In instantiation of ‘void stan::math::hessian(const F&, const Eigen::Matrix<double, -1, 1>&, double&, Eigen::Matrix<double, -1, 1>&, Eigen::Matrix<double, -1, -1>&) [with F = H(Eigen::VectorXd, Eigen::VectorXd)::<lambda(auto:36)>]’:
file19611604473d.cpp:42:40: required from here
/tmp/Rtmp6OO1UC/Rinst184f61b2d181/StanHeaders/include/stan/math/mix/functor/hessian.hpp:61:26: error: conversion from ‘void’ to non-scalar type ‘stan::math::fvarstan::math::var’ requested
fvar fx_fvar = f(x_fvar);
~^~~~~~~~
Does anyone know how about this?