Sleipnir C++ API
Loading...
Searching...
No Matches
slp::Gradient< Scalar > Class Template Reference

#include <sleipnir/autodiff/gradient.hpp>

Public Member Functions

 Gradient (Variable< Scalar > variable, Variable< Scalar > wrt)
 
 Gradient (Variable< Scalar > variable, SleipnirMatrixLike< Scalar > auto wrt)
 
VariableMatrix< Scalar > get () const
 
const Eigen::SparseVector< Scalar > & 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: