Drake
ExpressionAdd Class Reference

Symbolic expression representing an addition which is a sum of products. More...

#include <drake/common/symbolic_expression_cell.h>

Inheritance diagram for ExpressionAdd:
[legend]
Collaboration diagram for ExpressionAdd:
[legend]

Public Member Functions

 ExpressionAdd (double constant, const std::map< Expression, double > &expr_to_coeff_map)
 Constructs ExpressionAdd from constant_term and . More...
 
Variables GetVariables () const override
 Collects variables in expression. More...
 
bool EqualTo (const ExpressionCell &e) const override
 Checks structural equality. More...
 
bool Less (const ExpressionCell &e) const override
 Provides lexicographical ordering between expressions. More...
 
Polynomiald ToPolynomial () const override
 Returns a Polynomial representing this expression. More...
 
double Evaluate (const Environment &env) const override
 Evaluates under a given environment (by default, an empty environment). More...
 
Expression Expand () const override
 Expands out products and positive integer powers in expression. More...
 
Expression Substitute (const Substitution &s) const override
 Returns an Expression obtained by replacing all occurrences of the variables in s in the current expression cell with the corresponding expressions in s. More...
 
Expression Differentiate (const Variable &x) const override
 Differentiates this symbolic expression with respect to the variable var. More...
 
std::ostream & Display (std::ostream &os) const override
 Outputs string representation of expression into output stream os. More...
 
double get_constant () const
 Returns the constant. More...
 
const std::map< Expression, double > & get_expr_to_coeff_map () const
 Returns map from an expression to its coefficient. More...
 
- Public Member Functions inherited from ExpressionCell
ExpressionKind get_kind () const
 Returns expression kind. More...
 
size_t get_hash () const
 Returns hash value. More...
 
bool is_polynomial () const
 Checks if this symbolic expression is convertible to Polynomial. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ExpressionCell
 ExpressionCell ()=default
 Default constructor. More...
 
 ExpressionCell (ExpressionCell &&e)=default
 Move-constructs an ExpressionCell from an rvalue. More...
 
 ExpressionCell (const ExpressionCell &e)=default
 Copy-constructs an ExpressionCell from an lvalue. More...
 
ExpressionCelloperator= (ExpressionCell &&e)=delete
 Move-assigns (DELETED). More...
 
ExpressionCelloperator= (const ExpressionCell &e)=delete
 Copy-assigns (DELETED). More...
 
 ExpressionCell (ExpressionKind k, size_t hash, bool is_poly)
 Constructs ExpressionCell of kind k with hash and is_poly . More...
 
virtual ~ExpressionCell ()=default
 Default destructor. More...
 

Detailed Description

Symbolic expression representing an addition which is a sum of products.

\[ c_0 + \sum c_i * e_i \]

where \( c_i \) is a constant and \( e_i \) is a symbolic expression.

Internally this class maintains a member variable constant_ to represent \( c_0 \) and another member variable expr_to_coeff_map_ to represent a mapping from an expression \( e_i \) to its coefficient \( c_i \) of double.

Constructor & Destructor Documentation

ExpressionAdd ( double  constant,
const std::map< Expression, double > &  expr_to_coeff_map 
)

Constructs ExpressionAdd from constant_term and .

Here is the call graph for this function:

Member Function Documentation

Expression Differentiate ( const Variable x) const
overridevirtual

Differentiates this symbolic expression with respect to the variable var.

Exceptions
std::runtime_errorif it is not differentiable.

Implements ExpressionCell.

Here is the call graph for this function:

ostream & Display ( std::ostream &  os) const
overridevirtual

Outputs string representation of expression into output stream os.

Implements ExpressionCell.

bool EqualTo ( const ExpressionCell c) const
overridevirtual

Checks structural equality.

Implements ExpressionCell.

Here is the call graph for this function:

double Evaluate ( const Environment env) const
overridevirtual

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

Exceptions
std::runtime_errorif NaN is detected during evaluation.

Implements ExpressionCell.

Expression Expand ( ) const
overridevirtual

Expands out products and positive integer powers in expression.

Exceptions
std::runtime_errorif NaN is detected during expansion.

Implements ExpressionCell.

double get_constant ( ) const
inline

Returns the constant.

const std::map<Expression, double>& get_expr_to_coeff_map ( ) const
inline

Returns map from an expression to its coefficient.

Variables GetVariables ( ) const
overridevirtual

Collects variables in expression.

Implements ExpressionCell.

Here is the call graph for this function:

bool Less ( const ExpressionCell c) const
overridevirtual

Provides lexicographical ordering between expressions.

Implements ExpressionCell.

Here is the call graph for this function:

Expression Substitute ( const Substitution s) const
overridevirtual

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::runtime_errorif NaN is detected during substitution.

Implements ExpressionCell.

Polynomiald ToPolynomial ( ) const
overridevirtual

Returns a Polynomial representing this expression.

Note that the ID of a variable is preserved in this translation.

Precondition
is_polynomial() is true.

Implements ExpressionCell.

Here is the call graph for this function:


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