WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
slp::detail::Expression Struct Referenceabstract

An autodiff expression node. More...

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

Inheritance diagram for slp::detail::Expression:
slp::detail::AbsExpression slp::detail::AcosExpression slp::detail::AsinExpression slp::detail::Atan2Expression slp::detail::AtanExpression slp::detail::BinaryMinusExpression< T > slp::detail::BinaryPlusExpression< T > slp::detail::ConstExpression slp::detail::CosExpression slp::detail::CoshExpression slp::detail::DecisionVariableExpression slp::detail::DivExpression< T > slp::detail::ErfExpression slp::detail::ExpExpression slp::detail::HypotExpression slp::detail::Log10Expression slp::detail::LogExpression slp::detail::MultExpression< T > slp::detail::PowExpression< T > slp::detail::SignExpression slp::detail::SinExpression slp::detail::SinhExpression slp::detail::SqrtExpression slp::detail::TanExpression slp::detail::TanhExpression slp::detail::UnaryMinusExpression< T >

Public Member Functions

constexpr Expression ()=default
 Constructs a constant expression with a value of zero.
 
constexpr Expression (double value)
 Constructs a nullary expression (an operator with no arguments).
 
constexpr Expression (ExpressionPtr lhs)
 Constructs an unary expression (an operator with one argument).
 
constexpr Expression (ExpressionPtr lhs, ExpressionPtr rhs)
 Constructs a binary expression (an operator with two arguments).
 
virtual ~Expression ()=default
 
constexpr bool is_constant (double constant) const
 Returns true if the expression is the given constant.
 
virtual double value (double lhs, double rhs) const =0
 Either nullary operator with no arguments, unary operator with one argument, or binary operator with two arguments.
 
virtual ExpressionType type () const =0
 Returns the type of this expression (constant, linear, quadratic, or nonlinear).
 
virtual double grad_l (double lhs, double rhs, double parent_adjoint) const
 Returns double adjoint of the left child expression.
 
virtual double grad_r (double lhs, double rhs, double parent_adjoint) const
 Returns double adjoint of the right child expression.
 
virtual ExpressionPtr grad_expr_l (const ExpressionPtr &lhs, const ExpressionPtr &rhs, const ExpressionPtr &parent_adjoint) const
 Returns Expression adjoint of the left child expression.
 
virtual ExpressionPtr grad_expr_r (const ExpressionPtr &lhs, const ExpressionPtr &rhs, const ExpressionPtr &parent_adjoint) const
 Returns Expression adjoint of the right child expression.
 

Public Attributes

double val = 0.0
 The value of the expression node.
 
double adjoint = 0.0
 The adjoint of the expression node used during autodiff.
 
uint32_t incoming_edges = 0
 Counts incoming edges for this node.
 
int32_t col = -1
 This expression's column in a Jacobian, or -1 otherwise.
 
ExpressionPtr adjoint_expr
 The adjoint of the expression node used during gradient expression tree generation.
 
uint32_t ref_count = 0
 Reference count for intrusive shared pointer.
 
std::array< ExpressionPtr, 2 > args {nullptr, nullptr}
 Expression arguments.
 

Friends

ExpressionPtr operator* (const ExpressionPtr &lhs, const ExpressionPtr &rhs)
 Expression-Expression multiplication operator.
 
ExpressionPtr operator/ (const ExpressionPtr &lhs, const ExpressionPtr &rhs)
 Expression-Expression division operator.
 
ExpressionPtr operator+ (const ExpressionPtr &lhs, const ExpressionPtr &rhs)
 Expression-Expression addition operator.
 
ExpressionPtr operator+= (ExpressionPtr &lhs, const ExpressionPtr &rhs)
 Expression-Expression compound addition operator.
 
ExpressionPtr operator- (const ExpressionPtr &lhs, const ExpressionPtr &rhs)
 Expression-Expression subtraction operator.
 
ExpressionPtr operator- (const ExpressionPtr &lhs)
 Unary minus operator.
 
ExpressionPtr operator+ (const ExpressionPtr &lhs)
 Unary plus operator.
 

Detailed Description

An autodiff expression node.

Constructor & Destructor Documentation

◆ Expression() [1/4]

slp::detail::Expression::Expression ( )
constexprdefault

Constructs a constant expression with a value of zero.

◆ Expression() [2/4]

slp::detail::Expression::Expression ( double value)
inlineexplicitconstexpr

Constructs a nullary expression (an operator with no arguments).

Parameters
valueThe expression value.

◆ Expression() [3/4]

slp::detail::Expression::Expression ( ExpressionPtr lhs)
inlineexplicitconstexpr

Constructs an unary expression (an operator with one argument).

Parameters
lhsUnary operator's operand.

◆ Expression() [4/4]

slp::detail::Expression::Expression ( ExpressionPtr lhs,
ExpressionPtr rhs )
inlineconstexpr

Constructs a binary expression (an operator with two arguments).

Parameters
lhsBinary operator's left operand.
rhsBinary operator's right operand.

◆ ~Expression()

virtual slp::detail::Expression::~Expression ( )
virtualdefault

Member Function Documentation

◆ grad_expr_l()

◆ grad_expr_r()

virtual ExpressionPtr slp::detail::Expression::grad_expr_r ( const ExpressionPtr & lhs,
const ExpressionPtr & rhs,
const ExpressionPtr & parent_adjoint ) const
inlinevirtual

Returns Expression adjoint of the right child expression.

Parameters
lhsLeft argument to binary operator.
rhsRight argument to binary operator.
parent_adjointAdjoint of parent expression.
Returns
The Expression adjoint of the right child expression.

Reimplemented in slp::detail::Atan2Expression, slp::detail::BinaryMinusExpression< T >, slp::detail::BinaryPlusExpression< T >, slp::detail::DivExpression< T >, slp::detail::HypotExpression, slp::detail::MultExpression< T >, and slp::detail::PowExpression< T >.

◆ grad_l()

◆ grad_r()

virtual double slp::detail::Expression::grad_r ( double lhs,
double rhs,
double parent_adjoint ) const
inlinevirtual

Returns double adjoint of the right child expression.

Parameters
lhsLeft argument to binary operator.
rhsRight argument to binary operator.
parent_adjointAdjoint of parent expression.
Returns
The double adjoint of the right child expression.

Reimplemented in slp::detail::Atan2Expression, slp::detail::BinaryMinusExpression< T >, slp::detail::BinaryPlusExpression< T >, slp::detail::DivExpression< T >, slp::detail::HypotExpression, slp::detail::MultExpression< T >, and slp::detail::PowExpression< T >.

◆ is_constant()

bool slp::detail::Expression::is_constant ( double constant) const
inlineconstexpr

Returns true if the expression is the given constant.

Parameters
constantThe constant.
Returns
True if the expression is the given constant.

◆ type()

◆ value()

Friends And Related Symbol Documentation

◆ operator*

ExpressionPtr operator* ( const ExpressionPtr & lhs,
const ExpressionPtr & rhs )
friend

Expression-Expression multiplication operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator+ [1/2]

ExpressionPtr operator+ ( const ExpressionPtr & lhs)
friend

Unary plus operator.

Parameters
lhsOperand of unary plus.

◆ operator+ [2/2]

ExpressionPtr operator+ ( const ExpressionPtr & lhs,
const ExpressionPtr & rhs )
friend

Expression-Expression addition operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator+=

ExpressionPtr operator+= ( ExpressionPtr & lhs,
const ExpressionPtr & rhs )
friend

Expression-Expression compound addition operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator- [1/2]

ExpressionPtr operator- ( const ExpressionPtr & lhs)
friend

Unary minus operator.

Parameters
lhsOperand of unary minus.

◆ operator- [2/2]

ExpressionPtr operator- ( const ExpressionPtr & lhs,
const ExpressionPtr & rhs )
friend

Expression-Expression subtraction operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator/

ExpressionPtr operator/ ( const ExpressionPtr & lhs,
const ExpressionPtr & rhs )
friend

Expression-Expression division operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

Member Data Documentation

◆ adjoint

double slp::detail::Expression::adjoint = 0.0

The adjoint of the expression node used during autodiff.

◆ adjoint_expr

ExpressionPtr slp::detail::Expression::adjoint_expr

The adjoint of the expression node used during gradient expression tree generation.

◆ args

std::array<ExpressionPtr, 2> slp::detail::Expression::args {nullptr, nullptr}

Expression arguments.

◆ col

int32_t slp::detail::Expression::col = -1

This expression's column in a Jacobian, or -1 otherwise.

◆ incoming_edges

uint32_t slp::detail::Expression::incoming_edges = 0

Counts incoming edges for this node.

◆ ref_count

uint32_t slp::detail::Expression::ref_count = 0

Reference count for intrusive shared pointer.

◆ val

double slp::detail::Expression::val = 0.0

The value of the expression node.


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