5#ifndef OASIS_BOUNDEDUNARYEXPRESSION_HPP
6#define OASIS_BOUNDEDUNARYEXPRESSION_HPP
25template <
template <IExpression, IExpression, IExpression>
class DerivedT, IExpression OperandT, IExpression LowerBoundT = Expression, IExpression UpperBoundT = LowerBoundT>
28 using DerivedSpecialized = DerivedT<OperandT, LowerBoundT, UpperBoundT>;
29 using DerivedGeneralized = DerivedT<Expression, Expression, Expression>;
64 return this->
Generalize()->Differentiate(differentiationVariable);
82 return operand !=
nullptr;
98 operand = expr.Copy();
107 DerivedGeneralized substituted = DerivedGeneralized { operand, newLowerBound, newUpperBound };
108 return substituted.Copy();
113 void Serialize(SerializationVisitor& visitor)
const override
116 const auto& derivedGeneralized =
dynamic_cast<const DerivedGeneralized&
>(*generalized);
117 visitor.Serialize(derivedGeneralized);
A concept base class for both Unary and BoundedBinary expressions.
Definition BoundedExpression.hpp:23
auto GetLowerBound() const -> const LowerBoundT &
Definition BoundedExpression.hpp:51
auto GetUpperBound() const -> const UpperBoundT &
Definition BoundedExpression.hpp:57
auto HasLowerBound() const -> bool
Definition BoundedExpression.hpp:41
void SetLowerBound(const T &expr)
Definition BoundedExpression.hpp:65
auto HasUpperBound() const -> bool
Definition BoundedExpression.hpp:46
void SetUpperBound(const T &expr)
Definition BoundedExpression.hpp:76
A concept for an operand of a unary expression with bounds.
Definition BoundedUnaryExpression.hpp:26
void SetOperand(const T &expr)
Definition BoundedUnaryExpression.hpp:93
auto Copy() const -> std::unique_ptr< Expression > final
Copies this expression.
Definition BoundedUnaryExpression.hpp:51
BoundedUnaryExpression()=default
auto GetOperand() const -> const OperandT &
Definition BoundedUnaryExpression.hpp:85
auto Substitute(const Expression &var, const Expression &val) -> std::unique_ptr< Expression > override
Definition BoundedUnaryExpression.hpp:102
auto Copy(tf::Subflow &) const -> std::unique_ptr< Expression > final
Definition BoundedUnaryExpression.hpp:56
BoundedUnaryExpression(const BoundedUnaryExpression &other)
Definition BoundedUnaryExpression.hpp:34
auto operator=(const BoundedUnaryExpression &other) -> BoundedUnaryExpression &=default
auto HasOperand() const -> bool
Definition BoundedUnaryExpression.hpp:80
void Serialize(SerializationVisitor &visitor) const override
Definition BoundedUnaryExpression.hpp:113
auto Differentiate(const Expression &differentiationVariable) const -> std::unique_ptr< Expression > override
Tries to differentiate this function.
Definition BoundedUnaryExpression.hpp:62
BoundedUnaryExpression(const OperandT &operand, const LowerBoundT &lowerBound, const UpperBoundT &upperBound)
Definition BoundedUnaryExpression.hpp:44
auto Equals(const Expression &other) const -> bool final
Compares this expression to another expression for equality.
Definition BoundedUnaryExpression.hpp:67
An expression.
Definition Expression.hpp:62
virtual auto Generalize() const -> std::unique_ptr< Expression >
Converts this expression to a more general expression.
Definition Expression.cpp:225
Checks if type T is same as any of the provided types in U.
Definition Concepts.hpp:51