MonomialBasisElement represents a monomial, a product of powers of variables with non-negative integer exponents.
Note that it doesn't not include the coefficient part of a monomial. So x, x³y, xy²z are all valid MonomialBasisElement instances, but 1+x or 2xy²z are not. TODO(hongkai.dai): deprecate Monomial class and replace Monomial class with MonomialBasisElement class. For more information regarding the motivation of this class, please see Drake github issue #13602 and #13803.
|
| | MonomialBasisElement () |
| | Constructs a monomial equal to 1. More...
|
| |
| | MonomialBasisElement (std::nullptr_t) |
| | Constructs a default value. More...
|
| |
| | MonomialBasisElement (const std::map< Variable, int > &var_to_degree_map) |
| | Constructs a MonomialBasisElement from variable to degree map. More...
|
| |
| | MonomialBasisElement (const Expression &e) |
| | Converts an expression to a monomial if the expression is written as ∏ᵢpow(xᵢ, kᵢ), otherwise throws a runtime error. More...
|
| |
| | MonomialBasisElement (const Eigen::Ref< const VectorX< Variable >> &vars, const Eigen::Ref< const Eigen::VectorXi > °rees) |
| | Constructs a Monomial from a vector of variables vars and their corresponding integer degrees degrees. More...
|
| |
| | MonomialBasisElement (const Variable &var) |
| | Constructs a monomial basis element with only one variable, and the degree is 1. More...
|
| |
| | MonomialBasisElement (const Variable &var, int degree) |
| | Constructs a monomial basis element with only one variable, and the degree of that variable is given by degree. More...
|
| |
| | ~MonomialBasisElement () override |
| |
| std::pair< double, MonomialBasisElement > | EvaluatePartial (const Environment &env) const |
| | Partially evaluates using a given environment env. More...
|
| |
| MonomialBasisElement & | pow_in_place (int p) |
| | Returns this monomial raised to p. More...
|
| |
| bool | operator< (const MonomialBasisElement &other) const |
| | Compares two MonomialBasisElement in lexicographic order. More...
|
| |
| std::map< MonomialBasisElement, double > | Differentiate (const Variable &var) const |
| | Differentiates this MonomialBasisElement. More...
|
| |
| std::map< MonomialBasisElement, double > | Integrate (const Variable &var) const |
| | Integrates this MonomialBasisElement on a variable. More...
|
| |
| void | MergeBasisElementInPlace (const MonomialBasisElement &other) |
| | Merges this basis element with another basis element other by merging their var_to_degree_map. More...
|
| |
| std::map< ChebyshevBasisElement, double > | ToChebyshevBasis () const |
| | Converts this monomial to Chebyshev polynomial basis. More...
|
| |
| template<typename BasisElement > |
| std::map< BasisElement, double > | ToBasis () const |
| | Converts this monomial to a weighted sum of basis elements of type BasisElement. More...
|
| |
|
| | MonomialBasisElement (const MonomialBasisElement &)=default |
| |
| MonomialBasisElement & | operator= (const MonomialBasisElement &)=default |
| |
| | MonomialBasisElement (MonomialBasisElement &&)=default |
| |
| MonomialBasisElement & | operator= (MonomialBasisElement &&)=default |
| |
| | PolynomialBasisElement ()=default |
| | Constructs a polynomial basis with empty var_to_degree map. More...
|
| |
| | PolynomialBasisElement (const std::map< Variable, int > &var_to_degree_map) |
| | Constructs a polynomial basis given the variable and the degree of that variable. More...
|
| |
| | PolynomialBasisElement (const Eigen::Ref< const VectorX< Variable >> &vars, const Eigen::Ref< const Eigen::VectorXi > °rees) |
| | Constructs a polynomial basis, such that it contains the variable-to-degree map vars(i)→degrees(i). More...
|
| |
| virtual | ~PolynomialBasisElement () |
| |
| const std::map< Variable, int > & | var_to_degree_map () const |
| |
| const std::map< Variable, int > & | get_powers () const |
| | Returns variable to degree map. More...
|
| |
| int | total_degree () const |
| | Returns the total degree of a polynomial basis. More...
|
| |
| int | degree (const Variable &v) const |
| | Returns the degree of this PolynomialBasisElement in a variable v. More...
|
| |
| Variables | GetVariables () const |
| |
| double | Evaluate (const Environment &env) const |
| | Evaluates under a given environment env. More...
|
| |
| bool | operator== (const PolynomialBasisElement &other) const |
| |
| bool | operator!= (const PolynomialBasisElement &other) const |
| |
| Expression | ToExpression () const |
| |
| | PolynomialBasisElement (const PolynomialBasisElement &)=default |
| |
| PolynomialBasisElement & | operator= (const PolynomialBasisElement &)=default |
| |
| | PolynomialBasisElement (PolynomialBasisElement &&)=default |
| |
| PolynomialBasisElement & | operator= (PolynomialBasisElement &&)=default |
| |
Partially evaluates using a given environment env.
The evaluation result is of type pair<double, MonomialBasisElement>. The first component (: double) represents the coefficient part while the second component represents the remaining parts of the MonomialBasisElement which was not evaluated.
Example 1. Evaluate with a fully-specified environment (x³*y²).EvaluatePartial({{x, 2}, {y, 3}}) = (2³ * 3² = 8 * 9 = 72, MonomialBasisElement{} = 1).
Example 2. Evaluate with a partial environment (x³*y²).EvaluatePartial({{x, 2}}) = (2³ = 8, y²).
Converts this monomial to Chebyshev polynomial basis.
For example,
- For x², it returns 0.5T₂(x) + 0.5T₀(x).
- For x²y³, it returns 1/8T₂(x)T₃(y) + 3/8T₂(x)T₁(y) + 1/8T₀(x)T₃(y) + 3/8T₀(x)T₁(y).
We return the map from each ChebyshevBasisElement to its coefficient. For example, when this = x², it returns {[T₂(x)⇒0.5], [T₀(x)⇒0.5]}. When this = x²y³, it returns {[T₂(x)T₃(y)⇒1/8], [T₂(x)T₁(y)⇒3/8], [T₀(x)T₃(y)⇒1/8], [T₀(x)T₁(y)⇒3/8]}.