WPILibC++ 2025.1.1
|
An autodiff expression node. More...
Public Types | |
using | BinaryFuncDouble = double (*)(double, double) |
Binary function taking two doubles and returning a double. | |
using | TrinaryFuncDouble = double (*)(double, double, double) |
Trinary function taking three doubles and returning a double. | |
using | TrinaryFuncExpr |
Trinary function taking three expressions and returning an expression. | |
Public Member Functions | |
constexpr | Expression ()=default |
Constructs a constant expression with a value of zero. | |
constexpr | Expression (double value, ExpressionType type=ExpressionType::kConstant) |
Constructs a nullary expression (an operator with no arguments). | |
constexpr | Expression (ExpressionType type, BinaryFuncDouble valueFunc, TrinaryFuncDouble lhsGradientValueFunc, TrinaryFuncExpr lhsGradientFunc, ExpressionPtr lhs) |
Constructs an unary expression (an operator with one argument). | |
constexpr | Expression (ExpressionType type, BinaryFuncDouble valueFunc, TrinaryFuncDouble lhsGradientValueFunc, TrinaryFuncDouble rhsGradientValueFunc, TrinaryFuncExpr lhsGradientFunc, TrinaryFuncExpr rhsGradientFunc, ExpressionPtr lhs, ExpressionPtr rhs) |
Constructs a binary expression (an operator with two arguments). | |
constexpr bool | IsConstant (double constant) const |
Returns true if the expression is the given constant. | |
Public Attributes | |
double | value = 0.0 |
The value of the expression node. | |
double | adjoint = 0.0 |
The adjoint of the expression node used during autodiff. | |
uint32_t | duplications = 0 |
Tracks the number of instances of this expression yet to be encountered in an expression tree. | |
int32_t | row = -1 |
This expression's row in wrt for autodiff gradient, Jacobian, or Hessian. | |
ExpressionPtr | adjointExpr |
The adjoint of the expression node used during gradient expression tree generation. | |
ExpressionType | type = ExpressionType::kConstant |
Expression argument type. | |
uint32_t | refCount = 0 |
Reference count for intrusive shared pointer. | |
BinaryFuncDouble | valueFunc = nullptr |
Either nullary operator with no arguments, unary operator with one argument, or binary operator with two arguments. | |
std::array< TrinaryFuncDouble, 2 > | gradientValueFuncs {nullptr, nullptr} |
Functions returning double adjoints of the children expressions. | |
std::array< TrinaryFuncExpr, 2 > | gradientFuncs {nullptr, nullptr} |
Functions returning Variable adjoints of the children expressions. | |
std::array< ExpressionPtr, 2 > | args {nullptr, nullptr} |
Expression arguments. | |
Friends | |
SLEIPNIR_DLLEXPORT ExpressionPtr | operator* (const ExpressionPtr &lhs, const ExpressionPtr &rhs) |
Expression-Expression multiplication operator. | |
SLEIPNIR_DLLEXPORT ExpressionPtr | operator/ (const ExpressionPtr &lhs, const ExpressionPtr &rhs) |
Expression-Expression division operator. | |
SLEIPNIR_DLLEXPORT ExpressionPtr | operator+ (const ExpressionPtr &lhs, const ExpressionPtr &rhs) |
Expression-Expression addition operator. | |
SLEIPNIR_DLLEXPORT ExpressionPtr | operator- (const ExpressionPtr &lhs, const ExpressionPtr &rhs) |
Expression-Expression subtraction operator. | |
SLEIPNIR_DLLEXPORT ExpressionPtr | operator- (const ExpressionPtr &lhs) |
Unary minus operator. | |
SLEIPNIR_DLLEXPORT ExpressionPtr | operator+ (const ExpressionPtr &lhs) |
Unary plus operator. | |
An autodiff expression node.
using sleipnir::detail::Expression::BinaryFuncDouble = double (*)(double, double) |
Binary function taking two doubles and returning a double.
using sleipnir::detail::Expression::TrinaryFuncDouble = double (*)(double, double, double) |
Trinary function taking three doubles and returning a double.
Trinary function taking three expressions and returning an expression.
|
constexprdefault |
Constructs a constant expression with a value of zero.
|
inlineexplicitconstexpr |
Constructs a nullary expression (an operator with no arguments).
value | The expression value. |
type | The expression type. It should be either constant (the default) or linear. |
|
inlineconstexpr |
Constructs an unary expression (an operator with one argument).
|
inlineconstexpr |
Constructs a binary expression (an operator with two arguments).
type | The expression's type. |
valueFunc | Unary operator that produces this expression's value. |
lhsGradientValueFunc | Gradient with respect to the left operand. |
rhsGradientValueFunc | Gradient with respect to the right operand. |
lhsGradientFunc | Gradient with respect to the left operand. |
rhsGradientFunc | Gradient with respect to the right operand. |
lhs | Binary operator's left operand. |
rhs | Binary operator's right operand. |
|
inlineconstexpr |
Returns true if the expression is the given constant.
constant | The constant. |
|
friend |
Expression-Expression multiplication operator.
lhs | Operator left-hand side. |
rhs | Operator right-hand side. |
|
friend |
Unary plus operator.
lhs | Operand of unary plus. |
|
friend |
Expression-Expression addition operator.
lhs | Operator left-hand side. |
rhs | Operator right-hand side. |
|
friend |
Unary minus operator.
lhs | Operand of unary minus. |
|
friend |
Expression-Expression subtraction operator.
lhs | Operator left-hand side. |
rhs | Operator right-hand side. |
|
friend |
Expression-Expression division operator.
lhs | Operator left-hand side. |
rhs | Operator right-hand side. |
double sleipnir::detail::Expression::adjoint = 0.0 |
The adjoint of the expression node used during autodiff.
ExpressionPtr sleipnir::detail::Expression::adjointExpr |
The adjoint of the expression node used during gradient expression tree generation.
std::array<ExpressionPtr, 2> sleipnir::detail::Expression::args {nullptr, nullptr} |
Expression arguments.
uint32_t sleipnir::detail::Expression::duplications = 0 |
Tracks the number of instances of this expression yet to be encountered in an expression tree.
std::array<TrinaryFuncExpr, 2> sleipnir::detail::Expression::gradientFuncs {nullptr, nullptr} |
Functions returning Variable adjoints of the children expressions.
Parameters:
std::array<TrinaryFuncDouble, 2> sleipnir::detail::Expression::gradientValueFuncs {nullptr, nullptr} |
Functions returning double adjoints of the children expressions.
Parameters:
uint32_t sleipnir::detail::Expression::refCount = 0 |
Reference count for intrusive shared pointer.
int32_t sleipnir::detail::Expression::row = -1 |
ExpressionType sleipnir::detail::Expression::type = ExpressionType::kConstant |
Expression argument type.
double sleipnir::detail::Expression::value = 0.0 |
The value of the expression node.
BinaryFuncDouble sleipnir::detail::Expression::valueFunc = nullptr |
Either nullary operator with no arguments, unary operator with one argument, or binary operator with two arguments.
This operator is used to update the node's value.