WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
slp::detail::GradientExpressionGraph< Scalar > Class Template Reference

This class is an adapter type that performs value updates of an expression graph, generates a gradient tree, or appends gradient triplets for creating a sparse matrix of gradients. More...

#include </home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/autodiff/gradient_expression_graph.hpp>

Public Member Functions

 GradientExpressionGraph (const Variable< Scalar > &root)
 Generates the gradient graph for the given expression.
void update_values ()
 Update the values of all nodes in this graph based on the values of their dependent nodes.
VariableMatrix< Scalar > generate_tree (const VariableMatrix< Scalar > &wrt) const
 Returns the variable's gradient tree.
void append_triplets (gch::small_vector< Eigen::Triplet< Scalar > > &triplets, int row, const VariableMatrix< Scalar > &wrt) const
 Updates the adjoints in the expression graph (computes the gradient) then appends the adjoints of wrt to the sparse matrix triplets.

Detailed Description

template<typename Scalar>
class slp::detail::GradientExpressionGraph< Scalar >

This class is an adapter type that performs value updates of an expression graph, generates a gradient tree, or appends gradient triplets for creating a sparse matrix of gradients.

Template Parameters
ScalarScalar type.

Constructor & Destructor Documentation

◆ GradientExpressionGraph()

template<typename Scalar>
slp::detail::GradientExpressionGraph< Scalar >::GradientExpressionGraph ( const Variable< Scalar > & root)
inlineexplicit

Generates the gradient graph for the given expression.

Parameters
rootThe root node of the expression.

Member Function Documentation

◆ append_triplets()

template<typename Scalar>
void slp::detail::GradientExpressionGraph< Scalar >::append_triplets ( gch::small_vector< Eigen::Triplet< Scalar > > & triplets,
int row,
const VariableMatrix< Scalar > & wrt ) const
inline

Updates the adjoints in the expression graph (computes the gradient) then appends the adjoints of wrt to the sparse matrix triplets.

Parameters
tripletsThe sparse matrix triplets.
rowThe row of wrt.
wrtVector of variables with respect to which to compute the Jacobian.

◆ generate_tree()

template<typename Scalar>
VariableMatrix< Scalar > slp::detail::GradientExpressionGraph< Scalar >::generate_tree ( const VariableMatrix< Scalar > & wrt) const
inline

Returns the variable's gradient tree.

This function lazily allocates variables, so elements of the returned VariableMatrix will be empty if the corresponding element of wrt had no adjoint. Ensure Variable::expr isn't nullptr before calling member functions.

Parameters
wrtVariables with respect to which to compute the gradient.
Returns
The variable's gradient tree.

◆ update_values()

template<typename Scalar>
void slp::detail::GradientExpressionGraph< Scalar >::update_values ( )
inline

Update the values of all nodes in this graph based on the values of their dependent nodes.


The documentation for this class was generated from the following file: