11#ifndef EIGEN_AUTODIFF_JACOBIAN_H
12#define EIGEN_AUTODIFF_JACOBIAN_H
15#include "./InternalHeaderCheck.h"
19template <
typename Functor>
20class AutoDiffJacobian :
public Functor {
22 AutoDiffJacobian() : Functor() {}
23 AutoDiffJacobian(
const Functor& f) : Functor(f) {}
26 template <
typename... T>
27 AutoDiffJacobian(
const T&... Values) : Functor(Values...) {}
29 using InputType =
typename Functor::InputType;
30 using ValueType =
typename Functor::ValueType;
31 using Scalar =
typename ValueType::Scalar;
33 enum { InputsAtCompileTime = InputType::RowsAtCompileTime, ValuesAtCompileTime = ValueType::RowsAtCompileTime };
35 using JacobianType = Matrix<Scalar, ValuesAtCompileTime, InputsAtCompileTime>;
36 using Index =
typename JacobianType::Index;
38 using DerivativeType = Matrix<Scalar, InputsAtCompileTime, 1>;
39 using ActiveScalar = AutoDiffScalar<DerivativeType>;
41 using ActiveInput = Matrix<ActiveScalar, InputsAtCompileTime, 1>;
42 using ActiveValue = Matrix<ActiveScalar, ValuesAtCompileTime, 1>;
46 EIGEN_STRONG_INLINE
void operator()(
const InputType& x, ValueType* v)
const { this->operator()(x, v, 0); }
47 template <
typename... ParamsType>
48 void operator()(
const InputType& x, ValueType* v, JacobianType* _jac,
const ParamsType&... Params)
const {
52 Functor::operator()(x, v, Params...);
56 JacobianType& jac = *_jac;
58 ActiveInput ax = x.template cast<ActiveScalar>();
59 ActiveValue av(jac.rows());
61 EIGEN_IF_CONSTEXPR (InputsAtCompileTime == Dynamic)
62 for (Index j = 0; j < jac.rows(); j++) av[j].derivatives().resize(x.rows());
64 for (Index i = 0; i < jac.cols(); i++) ax[i].derivatives() = DerivativeType::Unit(x.rows(), i);
66 Functor::operator()(ax, &av, Params...);
68 for (Index i = 0; i < jac.rows(); i++) {
69 (*v)[i] = av[i].value();
70 jac.row(i) = av[i].derivatives();
Namespace containing all symbols from the Eigen library.