smats  0.0.1
Satisfability Modulo Arithmetic Theories Symbols
Loading...
Searching...
No Matches
smats::BinaryExpressionCell< T > Class Template Referenceabstract

#include <expression_cell.h>

Inheritance diagram for smats::BinaryExpressionCell< T >:
smats::ExpressionCell< T > smats::ExpressionDiv< T > smats::ExpressionPow< T >

Public Member Functions

void hash (DelegatingHasher &hasher) const override
 
bool equal_to (const ExpressionCell< T > &o) const override
 
bool less (const ExpressionCell< T > &o) const override
 
evaluate (const Environment< T > &env) const override
 
const Expression< T > & lhs () const
 
const Expression< T > & rhs () const
 
- Public Member Functions inherited from smats::ExpressionCell< T >
long use_count () const
 
ExpressionKind kind () const
 
const Variablesvariables () const
 
bool is_polynomial () const
 
bool is_expanded () const
 
void set_expanded ()
 
template<template< class > class E>
const E< T > & to () const
 
template<template< class > class E>
E< T > & to ()
 
Expression< T > to_expression () const
 
virtual Expression< T > expand () const =0
 
virtual Expression< T > evaluate_partial (const Environment< T > &env) const =0
 
virtual Expression< T > substitute (const Substitution< T > &s) const =0
 
virtual Expression< T > differentiate (const Variable &x) const =0
 
virtual std::ostream & display (std::ostream &os) const =0
 
void invalidate_cache ()
 

Protected Member Functions

 BinaryExpressionCell (ExpressionKind kind, Expression< T > e1, Expression< T > e2, bool is_expanded)
 
virtual T do_evaluate (const T &v1, const T &v2) const =0
 
void compute_variables (std::optional< Variables > &variables) const override
 
void compute_is_polynomial (std::optional< bool > &is_polynomial) const override
 
- Protected Member Functions inherited from smats::ExpressionCell< T >
 ExpressionCell (ExpressionKind kind, bool is_expanded)
 
 ExpressionCell (ExpressionKind kind, bool is_polynomial, bool is_expanded)
 

Private Attributes

const Expression< T > e1_
 The first argument of the binary expression.
 
const Expression< T > e2_
 The second argument of the binary expression.
 

Detailed Description

template<class T>
class smats::BinaryExpressionCell< T >

Symbolic expression used as a base for binary expressions.

The expression holds two other expressions internally. Some example include

\[ \min(x, y) \\ \max(x, y) \\ x^y \\ x \ y \\ \]

Template Parameters
Ttype of the expression evaluation

Constructor & Destructor Documentation

◆ BinaryExpressionCell()

template<class T >
smats::BinaryExpressionCell< T >::BinaryExpressionCell ( ExpressionKind kind,
Expression< T > e1,
Expression< T > e2,
bool is_expanded )
protected

Constructs BinaryExpressionCell of kind with e1, e2 is_polynomial, and is_expanded.

Parameters
kindkind of the expression
e1first expression
e2second expression
is_expandedwhether the expression is already expanded

BinaryExpressionCell

Member Function Documentation

◆ compute_is_polynomial()

template<class T >
void smats::BinaryExpressionCell< T >::compute_is_polynomial ( std::optional< bool > & is_polynomial) const
overrideprotectedvirtual

◆ compute_variables()

template<class T >
void smats::BinaryExpressionCell< T >::compute_variables ( std::optional< Variables > & variables) const
overrideprotectedvirtual

◆ do_evaluate()

template<class T >
virtual T smats::BinaryExpressionCell< T >::do_evaluate ( const T & v1,
const T & v2 ) const
nodiscardprotectedpure virtual

Evaluate the binary expression, given the two values v1 and v2 of the arguments.

Parameters
v1first value
v2second value
Returns
evaluation result

Implemented in smats::ExpressionDiv< T >, and smats::ExpressionPow< T >.

◆ equal_to()

template<class T >
bool smats::BinaryExpressionCell< T >::equal_to ( const ExpressionCell< T > & o) const
nodiscardoverridevirtual

Compare two expression cells to determine if they are equal.

Parameters
oother object to compare against
Returns
true the two object are equal
false if the two objects are different

Implements smats::ExpressionCell< T >.

◆ evaluate()

template<class T >
T smats::BinaryExpressionCell< T >::evaluate ( const Environment< T > & env) const
nodiscardoverridevirtual

Evaluates under a given environment (by default, an empty environment).

Parameters
envenvironment
Exceptions
std::runtime_exceptionif NaN is detected during evaluation.

Implements smats::ExpressionCell< T >.

◆ hash()

template<class T >
void smats::BinaryExpressionCell< T >::hash ( DelegatingHasher & ) const
overridevirtual

Sends all hash-relevant bytes for this ExpressionCell type into the given hasher, per the hash_append concept, except for kind(), because Expression already sends that.

Implements smats::ExpressionCell< T >.

◆ less()

template<class T >
bool smats::BinaryExpressionCell< T >::less ( const ExpressionCell< T > & o) const
nodiscardoverridevirtual

Compare two expression cells to determine the order between them.

Parameters
oother object to compare against
Returns
true if this object is less than the other object
false if this object is not less than the other object

Implements smats::ExpressionCell< T >.

◆ lhs()

template<class T >
const Expression< T > & smats::BinaryExpressionCell< T >::lhs ( ) const
inlinenodiscard

Get read-only access to the first argument of the binary expression.

Returns
first argument of the binary expression

◆ rhs()

template<class T >
const Expression< T > & smats::BinaryExpressionCell< T >::rhs ( ) const
inlinenodiscard

Get read-only access to the second argument of the binary expression.

Returns
second argument of the binary expression

The documentation for this class was generated from the following files: