Sleipnir C++ API
Loading...
Searching...
No Matches
slp::detail::IfElseExpression< Scalar > Struct Template Referencefinal

#include </home/runner/work/Sleipnir/Sleipnir/include/sleipnir/autodiff/expression_functions.hpp>

Inheritance diagram for slp::detail::IfElseExpression< Scalar >:
slp::detail::NonLeafExpression< IfElseExpression< Scalar >, Scalar, 4 > slp::detail::Expression< Scalar >

Public Member Functions

constexpr IfElseExpression (bool(*cond)(Scalar a, Scalar b), ExpressionPtr< Scalar > a, ExpressionPtr< Scalar > b, ExpressionPtr< Scalar > t, ExpressionPtr< Scalar > f)
 
- Public Member Functions inherited from slp::detail::NonLeafExpression< IfElseExpression< Scalar >, Scalar, 4 >
constexpr NonLeafExpression (Args &&... args)
 
void visit_args (function_ref< void(Expression< Scalar > *arg)> func) const final
 
Scalar value () const final
 
ExpressionType type () const final
 
std::string_view name () const final
 
void accumulate_adjoints () const final
 Accumulates the child adjoints as Scalars.
 
void accumulate_adjoints_expr () const final
 Accumulates the child adjoints as Expressions.
 
- Public Member Functions inherited from slp::detail::Expression< Scalar >
constexpr Expression ()=default
 Constructs a constant expression with a value of zero.
 
constexpr Expression (Scalar value)
 
SLEIPNIR_FORCE_INLINE constexpr bool is_constant (Scalar constant) const
 

Public Attributes

bool(* cond )(Scalar a, Scalar b)
 Condition evaluated on a and b.
 
- Public Attributes inherited from slp::detail::NonLeafExpression< IfElseExpression< Scalar >, Scalar, 4 >
std::array< ExpressionPtr< Scalar >, NumArgs > args
 The arguments in visit_args() order.
 
- Public Attributes inherited from slp::detail::Expression< Scalar >
Scalar val
 The value of the expression node.
 
Scalar adj
 The adjoint of the expression node, used during autodiff.
 
ExpressionPtr< Scalar > adj_expr
 
int32_t scratch
 
uint32_t ref_count
 Reference count for intrusive shared pointer.
 
uint32_t is_leaf
 

Static Public Attributes

static constexpr std::string_view NAME = "if-else"
 The expression's name.
 
- Static Public Attributes inherited from slp::detail::NonLeafExpression< IfElseExpression< Scalar >, Scalar, 4 >
static constexpr size_t NUM_ARGS
 The number of arguments.
 
static constexpr bool CONSTANT_PARTIALS
 Whether the partial derivatives are the same at every argument value.
 

Additional Inherited Members

- Public Types inherited from slp::detail::Expression< Scalar >
using Scalar = Scalar
 Scalar type alias.
 

Detailed Description

template<typename Scalar>
struct slp::detail::IfElseExpression< Scalar >

Derived expression type for if_else().

Returns t if cond(a, b) is true, otherwise f.

Template Parameters
ScalarScalar type.

Constructor & Destructor Documentation

◆ IfElseExpression()

template<typename Scalar >
constexpr slp::detail::IfElseExpression< Scalar >::IfElseExpression ( bool(*)(Scalar a, Scalar b)  cond,
ExpressionPtr< Scalar >  a,
ExpressionPtr< Scalar >  b,
ExpressionPtr< Scalar >  t,
ExpressionPtr< Scalar >  f 
)
inlineconstexpr

Constructs an if-else expression.

Parameters
condCondition evaluated on a and b.
aThe condition's first argument.
bThe condition's second argument.
tValue selected when cond(a, b) is true.
fValue selected when cond(a, b) is false.

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