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

#include <expression_cell.h>

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

Public Types

using ExpressionMap = std::map<Expression<T>, Expression<T>>
 

Public Member Functions

 NEW_OPERATOR_PARAMS (ExpressionMul, PARAMS(T constant, ExpressionMap expr_to_coeff_map), PARAMS(constant, expr_to_coeff_map))
 
void hash (DelegatingHasher &) 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 > evaluate_partial (const Environment< T > &env) const override
 
Expression< T > expand () 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
 
const T & constant () const
 
T & m_constant ()
 
const ExpressionMap & base_to_exponent_map () const
 
ExpressionMap & m_base_to_exponent_map ()
 
- 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::Mul
 

Private Member Functions

void compute_variables (std::optional< Variables > &variables) const override
 
void compute_is_polynomial (std::optional< bool > &is_polynomial) const override
 
std::ostream & display_term (std::ostream &os, bool print_mul, const Expression< T > &base, const Expression< T > &exponent) const
 

Static Private Member Functions

static Variables extract_variables (const ExpressionMap &base_to_exponent_map)
 

Private Attributes

const T constant_
 Constant term of the multiplication.
 
const ExpressionMap base_to_exponent_map_
 Map from expressions to their exponent.
 

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::ExpressionMul< T >

Symbolic expression representing a multiplication of powers.

The expression holds a constant term and a map from expressions to their coefficients. Let \( k \) be the constant term and \( E \) be the set of pairs \((b, e)\) where \( b \) is the base and \( e \) is the exponent. The ExpressionMul cell represents the following expression:

\[ k \cdot \prod_{(b, e) \in E} b^e \]

Member Function Documentation

◆ base_to_exponent_map()

template<class T >
const ExpressionMap & smats::ExpressionMul< T >::base_to_exponent_map ( ) const
inlinenodiscard

Get read-only access to the map of the multiplication expression.

Returns
map of the multiplication expression

◆ compute_is_polynomial()

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

◆ compute_variables()

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

◆ constant()

template<class T >
const T & smats::ExpressionMul< T >::constant ( ) const
inlinenodiscard

Get read-only access to the constant of the multiplication expression.

Returns
constant of the multiplication expression

◆ differentiate()

template<class T >
Expression< T > smats::ExpressionMul< 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::ExpressionMul< 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 >.

◆ display_term()

template<class T >
std::ostream & smats::ExpressionMul< T >::display_term ( std::ostream & os,
bool print_mul,
const Expression< T > & base,
const Expression< T > & exponent ) const
private

Utility function used to display a single term in a pretty format.

Parameters
osoutput stream
print_mulwhether to print a multiplication symbol at the beginning
basebase of the term
exponentexponent of the term
Returns
updated output stream

◆ equal_to()

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

◆ m_base_to_exponent_map()

template<class T >
ExpressionMul< T >::ExpressionMap & smats::ExpressionMul< T >::m_base_to_exponent_map ( )

Get read-write access to the map of the multiplication expression.

Returns
map of the multiplication expression

◆ m_constant()

template<class T >
T & smats::ExpressionMul< T >::m_constant ( )

Get read-write access to the constant of the multiplication expression.

Returns
constant of the multiplication expression

◆ substitute()

template<class T >
Expression< T > smats::ExpressionMul< 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 >.


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