42template <base::concepts::dense_vector VectorType>
55 using diff_type =
typename variable_type::diff_type;
57 static_assert(std::is_same_v<typename diff_type::Scalar, value_type>);
61 variable_vector_type::RowsAtCompileTime, diff_type::RowsAtCompileTime,
62 Eigen::ColMajor, variable_vector_type::MaxRowsAtCompileTime,
63 diff_type::MaxRowsAtCompileTime>;
82 return vector_(row).diff()(col);
99template <base::concepts::dense_vector VectorType>
101 const Eigen::MatrixBase<VectorType>& vector)
102 -> Eigen::CwiseNullaryOp<impl::make_jacobian_functor<VectorType>,
108 "differentiate function requires a vector as the argument.");
110 "differentiate function requires a vector with at least two "
113 for (
index_type i = 0; i < vector.rows(); ++i) {
116 const auto result_rows = vector.rows();
117 const auto result_cols = vector(0).diff().rows();
119 return result_type::NullaryExpr(result_rows, result_cols,
Definition of assertion macros.
#define NUM_COLLECT_ASSERT(CONDITION)
Macro to check whether a condition is satisfied.
Class of functor to make Jacobian.
typename variable_vector_type::Scalar variable_type
Type of variables.
make_jacobian_functor(const variable_vector_type &vector)
Constructor.
Eigen::Matrix< value_type, variable_vector_type::RowsAtCompileTime, diff_type::RowsAtCompileTime, Eigen::ColMajor, variable_vector_type::MaxRowsAtCompileTime, diff_type::MaxRowsAtCompileTime > result_type
Type of resulting matrix.
VectorType variable_vector_type
Type of vectors of variables.
typename variable_type::diff_type diff_type
Type of differential coefficients.
const variable_vector_type & vector_
Vector of variables.
auto operator()(index_type row, index_type col) const -> value_type
Get an element of Jacobian.
typename variable_type::value_type value_type
Type of values.
Definition of dense_vector concept.
Definition of exceptions.
Definition of index_type type.
Definition of macros for logging.
Namespace of forward-mode automatic differentiation.
auto make_jacobian(const Eigen::MatrixBase< VectorType > &vector) -> Eigen::CwiseNullaryOp< impl::make_jacobian_functor< VectorType >, typename impl::make_jacobian_functor< VectorType >::result_type >
Make Jacobian from a vector of variables.
std::ptrdiff_t index_type
Type of indices in this library.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.