Drake
Drake C++ Documentation
Loading...
Searching...
No Matches
ExpressionCell Class Referenceabstract

Detailed Description

Represents an abstract class which is the base of concrete symbolic-expression classes.

Note
It provides virtual function, ExpressionCell::Display, because operator<< is not allowed to be a virtual function.

#include <drake/common/symbolic/expression/expression_cell.h>

Public Member Functions

virtual ~ExpressionCell ()
std::atomic< int > & use_count () const
 Returns the intrusive use count (ala boost::intrusive_ptr).
ExpressionKind get_kind () const
 Returns expression kind.
virtual void HashAppendDetail (DelegatingHasher *) const =0
 Sends all hash-relevant bytes for this ExpressionCell type into the given hasher, per the hash_append generic hashing concept – except for get_kind(), because Expression already sends that.
virtual Variables GetVariables () const =0
 Collects variables in expression.
virtual bool EqualTo (const ExpressionCell &c) const =0
 Checks structural equality.
virtual bool Less (const ExpressionCell &c) const =0
 Provides lexicographical ordering between expressions.
bool is_polynomial () const
 Checks if this symbolic expression is convertible to Polynomial.
bool is_expanded () const
 Checks if this symbolic expression is already expanded.
void set_expanded ()
 Sets this symbolic expression as already expanded.
virtual double Evaluate (const Environment &env) const =0
 Evaluates under a given environment (by default, an empty environment).
virtual Expression Expand () const =0
 Expands out products and positive integer powers in expression.
virtual Expression EvaluatePartial (const Environment &env) const =0
 Returns an Expression obtained by replacing all occurrences of the variables in env in the current expression cell with the corresponding values in env.
virtual Expression Substitute (const Substitution &s) const =0
 Returns an Expression obtained by replacing all occurrences of the variables in s in the current expression cell with the corresponding expressions in s.
virtual Expression Differentiate (const Variable &x) const =0
 Differentiates this symbolic expression with respect to the variable var.
virtual std::ostream & Display (std::ostream &os) const =0
 Outputs string representation of expression into output stream os.
Does not allow copy, move, or assignment
 ExpressionCell (const ExpressionCell &)=delete
ExpressionCelloperator= (const ExpressionCell &)=delete
 ExpressionCell (ExpressionCell &&)=delete
ExpressionCelloperator= (ExpressionCell &&)=delete

Protected Member Functions

 ExpressionCell (ExpressionKind k, bool is_poly, bool is_expanded)
 Constructs ExpressionCell of kind k with is_poly and is_expanded, with a use_count of zero.

Constructor & Destructor Documentation

◆ ExpressionCell() [1/3]

ExpressionCell ( const ExpressionCell & )
delete

◆ ExpressionCell() [2/3]

◆ ~ExpressionCell()

virtual ~ExpressionCell ( )
virtual

◆ ExpressionCell() [3/3]

ExpressionCell ( ExpressionKind k,
bool is_poly,
bool is_expanded )
protected

Constructs ExpressionCell of kind k with is_poly and is_expanded, with a use_count of zero.

Member Function Documentation

◆ Differentiate()

virtual Expression Differentiate ( const Variable & x) const
nodiscardpure virtual

◆ Display()

◆ EqualTo()

virtual bool EqualTo ( const ExpressionCell & c) const
nodiscardpure virtual

◆ Evaluate()

virtual double Evaluate ( const Environment & env) const
nodiscardpure virtual

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

Exceptions
std::exceptionif NaN is detected during evaluation.

Implemented in BinaryExpressionCell, ExpressionAdd, ExpressionIfThenElse, ExpressionMul, ExpressionNaN, ExpressionUninterpretedFunction, ExpressionVar, and UnaryExpressionCell.

◆ EvaluatePartial()

virtual Expression EvaluatePartial ( const Environment & env) const
nodiscardpure virtual

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

Exceptions
std::exceptionif NaN is detected during substitution.

Implemented in ExpressionAbs, ExpressionAcos, ExpressionAdd, ExpressionAsin, ExpressionAtan2, ExpressionAtan, ExpressionCeiling, ExpressionCos, ExpressionCosh, ExpressionDiv, ExpressionExp, ExpressionFloor, ExpressionIfThenElse, ExpressionLog, ExpressionMax, ExpressionMin, ExpressionMul, ExpressionNaN, ExpressionPow, ExpressionSin, ExpressionSinh, ExpressionSqrt, ExpressionTan, ExpressionTanh, ExpressionUninterpretedFunction, and ExpressionVar.

◆ Expand()

◆ get_kind()

ExpressionKind get_kind ( ) const
nodiscard

Returns expression kind.

◆ GetVariables()

virtual Variables GetVariables ( ) const
nodiscardpure virtual

◆ HashAppendDetail()

virtual void HashAppendDetail ( DelegatingHasher * ) const
pure virtual

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

Implemented in BinaryExpressionCell, ExpressionAdd, ExpressionIfThenElse, ExpressionMul, ExpressionNaN, ExpressionUninterpretedFunction, ExpressionVar, and UnaryExpressionCell.

◆ is_expanded()

bool is_expanded ( ) const
nodiscard

Checks if this symbolic expression is already expanded.

◆ is_polynomial()

bool is_polynomial ( ) const
nodiscard

Checks if this symbolic expression is convertible to Polynomial.

◆ Less()

virtual bool Less ( const ExpressionCell & c) const
nodiscardpure virtual

◆ operator=() [1/2]

ExpressionCell & operator= ( const ExpressionCell & )
delete

◆ operator=() [2/2]

ExpressionCell & operator= ( ExpressionCell && )
delete

◆ set_expanded()

void set_expanded ( )

Sets this symbolic expression as already expanded.

◆ Substitute()

virtual Expression Substitute ( const Substitution & s) const
nodiscardpure virtual

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

Exceptions
std::exceptionif NaN is detected during substitution.

Implemented in ExpressionAbs, ExpressionAcos, ExpressionAdd, ExpressionAsin, ExpressionAtan2, ExpressionAtan, ExpressionCeiling, ExpressionCos, ExpressionCosh, ExpressionDiv, ExpressionExp, ExpressionFloor, ExpressionIfThenElse, ExpressionLog, ExpressionMax, ExpressionMin, ExpressionMul, ExpressionNaN, ExpressionPow, ExpressionSin, ExpressionSinh, ExpressionSqrt, ExpressionTan, ExpressionTanh, ExpressionUninterpretedFunction, and ExpressionVar.

◆ use_count()

std::atomic< int > & use_count ( ) const

Returns the intrusive use count (ala boost::intrusive_ptr).


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