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

This class calculates the gradient of a variable with respect to a vector of variables. More...

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

Public Member Functions

 Gradient (Variable< Scalar > variable, Variable< Scalar > wrt)
 Constructs a Gradient object.
 Gradient (Variable< Scalar > variable, SleipnirMatrixLike< Scalar > auto wrt)
 Constructs a Gradient object.
VariableMatrix< Scalar > get () const
 Returns the gradient as a VariableMatrix.
const Eigen::SparseVector< Scalar > & value ()
 Evaluates the gradient at wrt's value.

Detailed Description

template<typename Scalar>
class slp::Gradient< Scalar >

This class calculates the gradient of a variable with respect to a vector of variables.

The gradient is only recomputed if the variable expression is quadratic or higher order.

Template Parameters
ScalarScalar type.

Constructor & Destructor Documentation

◆ Gradient() [1/2]

template<typename Scalar>
slp::Gradient< Scalar >::Gradient ( Variable< Scalar > variable,
Variable< Scalar > wrt )
inline

Constructs a Gradient object.

Parameters
variableVariable of which to compute the gradient.
wrtVariable with respect to which to compute the gradient.

◆ Gradient() [2/2]

template<typename Scalar>
slp::Gradient< Scalar >::Gradient ( Variable< Scalar > variable,
SleipnirMatrixLike< Scalar > auto wrt )
inline

Constructs a Gradient object.

Parameters
variableVariable of which to compute the gradient.
wrtVector of variables with respect to which to compute the gradient.

Member Function Documentation

◆ get()

template<typename Scalar>
VariableMatrix< Scalar > slp::Gradient< Scalar >::get ( ) const
inline

Returns the gradient as a VariableMatrix.

This is useful when constructing optimization problems with derivatives in them.

Returns
The gradient as a VariableMatrix.

◆ value()

template<typename Scalar>
const Eigen::SparseVector< Scalar > & slp::Gradient< Scalar >::value ( )
inline

Evaluates the gradient at wrt's value.

Returns
The gradient at wrt's value.

The documentation for this class was generated from the following file:
  • /home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/autodiff/gradient.hpp