10#include <autodiff/forward/dual.hpp>
11#include <autodiff/forward/dual/eigen.hpp>
34template <
typename Fun,
typename... Vars,
typename... Args,
typename U,
typename G,
typename H>
35void hessianN(
const Fun& f,
const autodiff::Wrt<Vars...>& wrt,
const autodiff::At<Args...>& at, U& u,
36 std::array<G, U::RowsAtCompileTime>& g, std::array<H, U::RowsAtCompileTime>& h) {
37 static_assert(
sizeof...(Vars) >= 1);
38 static_assert(
sizeof...(Args) >= 1);
40 auto fEntry = [&](
auto& I) {
return [&](
const auto&) {
return std::apply(f, at.args)[I]; }; };
41 for (
int i = 0; i < U::RowsAtCompileTime; ++i)
42 hessian(fEntry(i), wrt, at, u[i], g[i], h[i]);
void hessianN(const Fun &f, const autodiff::Wrt< Vars... > &wrt, const autodiff::At< Args... > &at, U &u, std::array< G, U::RowsAtCompileTime > &g, std::array< H, U::RowsAtCompileTime > &h)
Computes the Hessian matrix for each parameter of a given function.The Hessian matrix represents the ...
Definition: autodiffhelper.hh:35
Definition: algorithms.hh:17