Represents a monomial, a product of powers of variables with non-negative integer exponents.
Note that it does not include the coefficient part of a monomial.
|
| | Monomial ()=default |
| | Constructs a monomial equal to 1.
|
| | Monomial (std::nullptr_t) |
| | Constructs a default value.
|
| | Monomial (const std::map< Variable, int, Variable::CompareLess > &powers) |
| | Constructs a monomial from powers.
|
| | Monomial (const Eigen::Ref< const VectorX< Variable > > &vars, const Eigen::Ref< const Eigen::VectorXi > &exponents) |
| | Constructs a monomial from a vector of variables vars and their corresponding integer exponents exponents.
|
| | Monomial (const Expression &e) |
| | Converts an expression to a monomial if the expression is written as ∏ᵢpow(xᵢ, kᵢ), otherwise throws a runtime error.
|
| | Monomial (const Variable &var) |
| | Constructs a monomial from var.
|
| | Monomial (const Variable &var, int exponent) |
| | Constructs a monomial from var and exponent.
|
| int | degree (const Variable &v) const |
| | Returns the degree of this monomial in a variable v.
|
| int | total_degree () const |
| | Returns the total degree of this monomial.
|
| Variables | GetVariables () const |
| | Returns the set of variables in this monomial.
|
| const std::map< Variable, int, Variable::CompareLess > & | get_powers () const |
| | Returns the internal representation of Monomial, the map from a base (Variable) to its exponent (int).
|
| double | Evaluate (const Environment &env) const |
| | Evaluates under a given environment env.
|
| Eigen::VectorXd | Evaluate (const Eigen::Ref< const VectorX< symbolic::Variable > > &vars, const Eigen::Ref< const Eigen::MatrixXd > &vars_values) const |
| | Evaluates the monomial for a batch of data.
|
| std::pair< double, Monomial > | EvaluatePartial (const Environment &env) const |
| | Partially evaluates using a given environment env.
|
| Expression | ToExpression () const |
| | Returns a symbolic expression representing this monomial.
|
| bool | operator== (const Monomial &m) const |
| | Checks if this monomial and m represent the same monomial.
|
| bool | operator!= (const Monomial &m) const |
| | Checks if this monomial and m do not represent the same monomial.
|
| Monomial & | operator*= (const Monomial &m) |
| | Returns this monomial multiplied by m.
|
| Monomial & | pow_in_place (int p) |
| | Returns this monomial raised to p.
|
| std::string | to_string () const |
| | Returns the string representation of this monomial.
|
| | Monomial (const Monomial &)=default |
| Monomial & | operator= (const Monomial &)=default |
| | Monomial (Monomial &&)=default |
| Monomial & | operator= (Monomial &&)=default |
| Monomial |
( |
const Eigen::Ref< const VectorX< Variable > > & | vars, |
|
|
const Eigen::Ref< const Eigen::VectorXi > & | exponents ) |
Constructs a monomial from a vector of variables vars and their corresponding integer exponents exponents.
For example, Monomial([x, y, z], [2, 0, 1]) constructs a monomial x²z.
- Precondition
- The size of vars should be the same as the size of exponents.
- Exceptions
-
| std::exception | if exponents includes a negative integer. |
Partially evaluates using a given environment env.
The evaluation result is of type pair<double, Monomial>. The first component (a double) represents the coefficient part while the second component represents the remaining parts of the monomial which was not evaluated.
Example 1. Evaluate with a fully-specified environment (x³*y²).EvaluatePartial({{x, 2}, {y, 3}}) = (2³ * 3² = 8 * 9 = 72, Monomial{} = 1).
Example 2. Evaluate with a partial environment (x³*y²).EvaluatePartial({{x, 2}}) = (2³ = 8, y²).