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

#include <expression_cell.h>

Inheritance diagram for smats::ExpressionVar< T >:
smats::ExpressionCell< T >

Public Member Functions

 NEW_OPERATOR_PARAMS (ExpressionVar, Variable v, v)
 
const Variablevariable () const
 
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
 
Expression< T > expand () const override
 
Expression< T > evaluate_partial (const Environment< T > &env) const override
 
Expression< T > substitute (const Substitution< T > &s) const override
 
Expression< T > differentiate (const Variable &x) const override
 
std::ostream & display (std::ostream &os) const override
 
- 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
 
void invalidate_cache ()
 

Static Public Attributes

static const ExpressionKind expression_kind = ExpressionKind::Var
 

Private Member Functions

void compute_variables (std::optional< Variables > &variables) const override
 
void compute_is_polynomial (std::optional< bool > &is_polynomial) const override
 

Private Attributes

const Variable var_
 Variable contained in the Expression. Cannot be a Boolean variable.
 

Additional Inherited Members

- Protected Member Functions inherited from smats::ExpressionCell< T >
 ExpressionCell (ExpressionKind kind, bool is_expanded)
 
 ExpressionCell (ExpressionKind kind, bool is_polynomial, bool is_expanded)
 

Detailed Description

template<class T>
class smats::ExpressionVar< T >

Symbolic expression representing a variable.

The expression holds a variable internally.

Template Parameters
Ttype of the expression evaluation

Member Function Documentation

◆ compute_is_polynomial()

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

◆ compute_variables()

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

◆ differentiate()

template<class T >
Expression< T > smats::ExpressionVar< T >::differentiate ( const Variable & x) const
nodiscardoverridevirtual

Differentiates this symbolic expression with respect to the variable var.

Parameters
xvariable
Exceptions
std::runtime_exceptionif it is not differentiable.

Implements smats::ExpressionCell< T >.

◆ display()

template<class T >
std::ostream & smats::ExpressionVar< T >::display ( std::ostream & os) const
overridevirtual

Displays the expression in a human-readable format.

Parameters
osoutput stream
Returns
updated output stream

Implements smats::ExpressionCell< T >.

◆ equal_to()

template<class T >
bool smats::ExpressionVar< 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::ExpressionVar< 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 >.

◆ evaluate_partial()

template<class T >
Expression< T > smats::ExpressionVar< T >::evaluate_partial ( const Environment< T > & env) const
nodiscardoverridevirtual

Returns an Expression obtained by replacing all occurrences of the variables in env in the current expression cell with the corresponding values in env.

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

Implements smats::ExpressionCell< T >.

◆ expand()

template<class T >
Expression< T > smats::ExpressionVar< T >::expand ( ) const
nodiscardoverridevirtual

Expands out products and positive integer powers in expression.

Exceptions
std::runtime_exceptionif NaN is detected during expansion.

Implements smats::ExpressionCell< T >.

◆ hash()

template<class T >
void smats::ExpressionVar< 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::ExpressionVar< 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 >.

◆ substitute()

template<class T >
Expression< T > smats::ExpressionVar< T >::substitute ( const Substitution< T > & s) const
nodiscardoverridevirtual

Returns an Expression obtained by replacing all occurrences of the variables in s in the current expression cell with the corresponding expressions in s.

Parameters
ssubstitution
Exceptions
std::runtime_exceptionif NaN is detected during substitution.

Implements smats::ExpressionCell< T >.

◆ variable()

template<class T >
const Variable & smats::ExpressionVar< T >::variable ( ) const
inlinenodiscard

Get read-only access to the variable of the variable expression.

Returns
variable of the variable expression

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