Drake
ChebyshevBasisElement Class Reference

Detailed Description

ChebyshevBasisElement represents an element of Chebyshev polynomial basis, written as the product of Chebyshev polynomials, in the form Tₚ₀(x₀)Tₚ₁(x₁)...Tₚₙ(xₙ), where each Tₚᵢ(xᵢ) is a (univariate) Chebyshev polynomial of degree pᵢ.

#include <drake/common/symbolic_chebyshev_basis_element.h>

Public Member Functions

 ChebyshevBasisElement ()
 Constructs a ChebyshevBasisElement equals to 1. More...
 
 ChebyshevBasisElement (const std::map< Variable, int > &var_to_degree_map)
 
 ChebyshevBasisElement (const Variable &var)
 Constructs a Chebyshev polynomial T₁(var). More...
 
 ChebyshevBasisElement (const Variable &var, int degree)
 Constructs a Chebyshev polynomial Tₙ(var) where n = degree. More...
 
 ChebyshevBasisElement (std::nullptr_t)
 Constructs a default value 1. More...
 
 ChebyshevBasisElement (const Eigen::Ref< const VectorX< Variable >> &vars, const Eigen::Ref< const Eigen::VectorXi > &degrees)
 
 ~ChebyshevBasisElement () override=default
 
bool operator< (const ChebyshevBasisElement &other) const
 Compares two ChebyshevBasisElement in lexicographic order. More...
 
std::map< ChebyshevBasisElement, double > Differentiate (const Variable &var) const
 Differentiates the ChebyshevBasisElement with respect to a variable. More...
 
std::map< ChebyshevBasisElement, double > Integrate (const Variable &var) const
 Integrates a ChebyshevBasisElement for a variable. More...
 
void MergeBasisElementInPlace (const ChebyshevBasisElement &other)
 Merges this Chebyshev basis element with another Chebyshev basis element other by merging their var_to_degree_map. More...
 
std::pair< double, ChebyshevBasisElementEvaluatePartial (const Environment &env) const
 Partially evaluates using a given environment env. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 ChebyshevBasisElement (const ChebyshevBasisElement &)=default
 
ChebyshevBasisElementoperator= (const ChebyshevBasisElement &)=default
 
 ChebyshevBasisElement (ChebyshevBasisElement &&)=default
 
ChebyshevBasisElementoperator= (ChebyshevBasisElement &&)=default
 
- Public Member Functions inherited from PolynomialBasisElement
 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 > &degrees)
 Constructs a polynomial basis, such that it contains the variable-to-degree map vars(i)→degrees(i). More...
 
virtual ~PolynomialBasisElement ()=default
 
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
 
PolynomialBasisElementoperator= (const PolynomialBasisElement &)=default
 
 PolynomialBasisElement (PolynomialBasisElement &&)=default
 
PolynomialBasisElementoperator= (PolynomialBasisElement &&)=default
 

Friends

template<class HashAlgorithm >
void hash_append (HashAlgorithm &hasher, const ChebyshevBasisElement &item) noexcept
 Implements the hash_append generic hashing concept. More...
 

Additional Inherited Members

- Protected Member Functions inherited from PolynomialBasisElement
bool lexicographical_compare (const PolynomialBasisElement &other) const
 Compares two PolynomialBasisElement using lexicographical order. More...
 
virtual bool EqualTo (const PolynomialBasisElement &other) const
 
void DoEvaluatePartial (const Environment &e, double *coeff, std::map< Variable, int > *new_basis_element) const
 
intget_mutable_total_degree ()
 
std::map< Variable, int > * get_mutable_var_to_degree_map ()
 
void DoMergeBasisElementInPlace (const PolynomialBasisElement &other)
 Merge this basis element with another basis element by merging their var_to_degree_map. More...
 

Constructor & Destructor Documentation

◆ ChebyshevBasisElement() [1/8]

◆ ChebyshevBasisElement() [2/8]

◆ ChebyshevBasisElement() [3/8]

Constructs a ChebyshevBasisElement equals to 1.

◆ ChebyshevBasisElement() [4/8]

ChebyshevBasisElement ( const std::map< Variable, int > &  var_to_degree_map)
explicit

◆ ChebyshevBasisElement() [5/8]

ChebyshevBasisElement ( const Variable var)
explicit

Constructs a Chebyshev polynomial T₁(var).

◆ ChebyshevBasisElement() [6/8]

ChebyshevBasisElement ( const Variable var,
int  degree 
)

Constructs a Chebyshev polynomial Tₙ(var) where n = degree.

◆ ChebyshevBasisElement() [7/8]

ChebyshevBasisElement ( std::nullptr_t  )
explicit

Constructs a default value 1.

This overload is used by Eigen when EIGEN_INITIALIZE_MATRICES_BY_ZERO is enabled.

◆ ChebyshevBasisElement() [8/8]

ChebyshevBasisElement ( const Eigen::Ref< const VectorX< Variable >> &  vars,
const Eigen::Ref< const Eigen::VectorXi > &  degrees 
)

◆ ~ChebyshevBasisElement()

~ChebyshevBasisElement ( )
overridedefault

Member Function Documentation

◆ Differentiate()

std::map<ChebyshevBasisElement, double> Differentiate ( const Variable var) const

Differentiates the ChebyshevBasisElement with respect to a variable.

We use the fact that

  • If n is even dTₙ(x)/dx = 2n ∑ⱼ Tⱼ(x), j is odd and 1 <= j <= n-1
  • If n is odd dTₙ(x)/dx = 2n ∑ⱼ Tⱼ(x) - n, j is even and 0 <= j <= n-1 We return result, a map from ChebyshevBasisElement to double, such that sum(result.key() * result[key]) is the differentiation of this w.r.t the variable. For example if n is even, dTₙ(x)Tₘ(y)/dx = 2n∑ⱼ Tⱼ(x)Tₘ(y), j is odd and 1 <= j <= n-1, then the returned result is {T₁(x)Tₘ(y), 2n}, {T₃(x)Tₘ(y), 2n}, ..., {T₂ₙ₋₁(x)Tₘ(y), 2n}. A special case is that var is not a variable in this, then we return an empty map.
    Parameters
    varA variable to differentiate with.

◆ EvaluatePartial()

std::pair<double, ChebyshevBasisElement> EvaluatePartial ( const Environment env) const

Partially evaluates using a given environment env.

The evaluation result is of type pair<double, ChebyshevBasisElement>. The first component (: double) represents the coefficient part while the second component represents the remaining parts of the ChebyshevBasisElement which was not evaluated, the product of the first and the second component is the result of the partial evaluation. For example, if this ChebyshevBasisElement is T₂(x)T₃(y)T₁(z), and env stores x→ 3, y→ 2, then the partial evaluation is T₂(3)*T₃(2)*T₁(z) = 17 * 26 * T₁(z) = 442*T₁(z), then we return the pair (442, T₁(z)).

◆ Integrate()

std::map<ChebyshevBasisElement, double> Integrate ( const Variable var) const

Integrates a ChebyshevBasisElement for a variable.

We use the fact that ∫ Tₙ(x)dx = 1/(2n+2)Tₙ₊₁(x) − 1/(2n−2)Tₙ₋₁(x) A special case is ∫ T₀(x)dx = T₁(x)

Parameters
varThe variable to integrate. If
varis not a variable in this ChebyshevBasisElement, then the integration result is *this * T₁(var).
Return values
resultsum(key * result[key]) is the integration result. For example, ∫ T₂(x)T₃(y)dx = 1/6*T₃(x)T₃(y) − 1/2 * T₁(x)T₃(y), then the result is the map containing {T₃(x)T₃(y), 1/6} and {T₁(x)T₃(y), -1/2}.

◆ MergeBasisElementInPlace()

void MergeBasisElementInPlace ( const ChebyshevBasisElement other)

Merges this Chebyshev basis element with another Chebyshev basis element other by merging their var_to_degree_map.

After merging, the degree of each variable is raised to the sum of the degree in each basis element (if a variable does not show up in either one of the basis element, we regard its degree to be 0). For example, merging T₁(x)T₃(y) and T₂(x)T₄(z) gets T₃(x)T₃(y)T₄(z).

◆ operator<()

bool operator< ( const ChebyshevBasisElement other) const

Compares two ChebyshevBasisElement in lexicographic order.

◆ operator=() [1/2]

ChebyshevBasisElement& operator= ( const ChebyshevBasisElement )
default

◆ operator=() [2/2]

ChebyshevBasisElement& operator= ( ChebyshevBasisElement &&  )
default

Friends And Related Function Documentation

◆ hash_append

void hash_append ( HashAlgorithm &  hasher,
const ChebyshevBasisElement item 
)
friend

Implements the hash_append generic hashing concept.


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