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

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

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

Public Member Functions

constexpr IfElseExpression (IfElseCondition cond, ExpressionPtr< Scalar > c, ExpressionPtr< Scalar > t, ExpressionPtr< Scalar > f)
 
- Public Member Functions inherited from slp::detail::NonLeafExpression< IfElseExpression, Scalar, Type, 3 >
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
 
bool has_constant_partials () 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
 

Static Public Member Functions

static bool satisfied (IfElseCondition cond, Scalar c)
 

Public Attributes

IfElseCondition cond
 The condition checked on c.
 
- Public Attributes inherited from slp::detail::NonLeafExpression< IfElseExpression, Scalar, Type, 3 >
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, Type, 3 >
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, ExpressionType Type>
struct slp::detail::IfElseExpression< Scalar, Type >

Derived expression type for if_else().

Returns t if c satisfies the condition, otherwise f.

Template Parameters
ScalarScalar type.
TypeExpression type.

Constructor & Destructor Documentation

◆ IfElseExpression()

template<typename Scalar , ExpressionType Type>
constexpr slp::detail::IfElseExpression< Scalar, Type >::IfElseExpression ( IfElseCondition  cond,
ExpressionPtr< Scalar >  c,
ExpressionPtr< Scalar >  t,
ExpressionPtr< Scalar >  f 
)
inlineconstexpr

Constructs an if-else expression.

Parameters
condThe condition checked on c.
cThe condition's argument.
tValue selected when c satisfies the condition.
fValue selected when c violates the condition.

Member Function Documentation

◆ satisfied()

template<typename Scalar , ExpressionType Type>
static bool slp::detail::IfElseExpression< Scalar, Type >::satisfied ( IfElseCondition  cond,
Scalar  c 
)
inlinestatic

Returns true if c satisfies the condition.

Parameters
condThe condition checked on c.
cThe condition's argument.
Returns
True if c satisfies the condition.

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