Sturm  0.0.0
Computing Sturm sequences in C++
Loading...
Searching...
No Matches
Sturm::Poly< Real > Class Template Reference

Polynomial class. More...

#include <Poly.hh>

Inherits Eigen::Vector< Real, Eigen::Dynamic >.

Public Types

using Vector

Public Member Functions

 Poly ()
 Class constructor from a vector.
 Poly (Integer order)
 Class constructor from a vector.
 Poly (const Poly &c)
 Class constructor from a vector.
 Poly (const Vector &c)
 Class constructor from a vector.
const Vectorto_eigen () const
 Access to the Eigen const class.
void set_order (Integer order)
 Set the order of the polynomial.
void set_degree (Integer degree)
 Set the degree of the polynomial.
Polyset_scalar (Real s)
 Set the polynomial to a scalar value.
Polyset_monomial (Real a)
 Set the polynomial to a monomial with a given coefficient.
Vector coeffs () const
 Get the coefficients of the polynomial.
Integer degree () const
 Get the degree of the polynomial.
Integer order () const
 Get the order of the polynomial.
std::string to_string () const
 Convert the polynomial to a string representation.
Real evaluate (Real x) const
 Evaluate the polynomial at a given point.
Real evaluate_derivative (Real x) const
 Evaluate the derivative of the polynomial at a given point.
void evaluate (Real x, Real &p, Real &Dp) const
 Evaluate the polynomial and its derivative at a given point.
Real leading_coeff () const
 Get the leading coefficient of the polynomial.
void derivative (Poly &res) const
 Compute the derivative of the polynomial.
void integral (Poly &res) const
 Compute the integral of the polynomial.
void integral (Poly &res, Real c) const
 Compute the integral of the polynomial with a given constant.
Real normalize ()
 Normalize the polynomial.
void purge (const Real eps)
 Purge small coefficients.
void adjust_degree ()
 Adjust the degree of the polynomial and remove leading zeros.
Integer sign_variations () const
 Count the number of sign variations.
void make_monic ()
 Normalize the polynomial to monic form.
Polyoperator= (const Poly &p)
 Define the assignment with another polynomial.
Poly operator- ()
 Define the negation of the polynomial.
Polyoperator+= (const Poly &p)
 Define the addition with another polynomial.
Polyoperator-= (const Poly &p)
 Define the subtraction with another polynomial.
Polyoperator*= (const Poly &p)
 Define the multiplication with another polynomial.
Polyoperator+= (Real s)
 Define the addition with a scalar.
Polyoperator-= (Real s)
 Define the subtraction with a scalar.
Polyoperator*= (Real s)
 Define the multiplication with a scalar.

Static Public Attributes

static constexpr const Real EPSILON

Private Member Functions

Vectorto_eigen ()
 Access to the Eigen class.

Private Attributes

Integer m_order

Detailed Description

template<typename Real>
class Sturm::Poly< Real >

This class implements a polynomial of the form \( p(x) = \sum_{i=0}^n a_i x^i \).

Template Parameters
RealScalar number type.

Member Typedef Documentation

◆ Vector

template<typename Real>
using Sturm::Poly< Real >::Vector
Initial value:
Eigen::Vector<Real, Eigen::Dynamic>

Vector of real numbers.

Constructor & Destructor Documentation

◆ Poly() [1/4]

template<typename Real>
Sturm::Poly< Real >::Poly ( )
inline

◆ Poly() [2/4]

template<typename Real>
Sturm::Poly< Real >::Poly ( Integer order)
inlineexplicit
Parameters
[in]orderOrder of the polynomial.

◆ Poly() [3/4]

template<typename Real>
Sturm::Poly< Real >::Poly ( const Poly< Real > & c)
inline
Parameters
[in]cVector of coefficients.

◆ Poly() [4/4]

template<typename Real>
Sturm::Poly< Real >::Poly ( const Vector & c)
inlineexplicit
Parameters
[in]cVector of coefficients.

Member Function Documentation

◆ adjust_degree()

template<typename Real>
void Sturm::Poly< Real >::adjust_degree ( )
inline

Adjust the degree of the polynomial to ensure the leading coefficient is non-zero.

◆ coeffs()

template<typename Real>
Vector Sturm::Poly< Real >::coeffs ( ) const
inline
Returns
Coefficients at the given index.

◆ degree()

template<typename Real>
Integer Sturm::Poly< Real >::degree ( ) const
inline
Returns
Degree of the polynomial.

◆ derivative()

template<typename Real>
void Sturm::Poly< Real >::derivative ( Poly< Real > & res) const
inline
Parameters
[out]resPolynomial representing the derivative.

◆ evaluate() [1/2]

template<typename Real>
Real Sturm::Poly< Real >::evaluate ( Real x) const
inline
Parameters
[in]xPoint at which to evaluate the polynomial.
Returns
Value of the polynomial at the given point.

◆ evaluate() [2/2]

template<typename Real>
void Sturm::Poly< Real >::evaluate ( Real x,
Real & p,
Real & Dp ) const
inline
Parameters
[in]xPoint at which to evaluate.
[out]pValue of the polynomial at the given point.
[out]DpValue of the derivative at the given point.

◆ evaluate_derivative()

template<typename Real>
Real Sturm::Poly< Real >::evaluate_derivative ( Real x) const
inline
Parameters
[in]xPoint at which to evaluate the derivative.
Returns
Value of the derivative at the given point.

◆ integral() [1/2]

template<typename Real>
void Sturm::Poly< Real >::integral ( Poly< Real > & res) const
inline
Parameters
[out]resPolynomial representing the integral.

◆ integral() [2/2]

template<typename Real>
void Sturm::Poly< Real >::integral ( Poly< Real > & res,
Real c ) const
inline
Parameters
[out]resPolynomial representing the integral.
[in]cConstant value for the integral.

◆ leading_coeff()

template<typename Real>
Real Sturm::Poly< Real >::leading_coeff ( ) const
inline
Returns
Leading coefficient.

◆ make_monic()

template<typename Real>
void Sturm::Poly< Real >::make_monic ( )
inline

Scales all coefficients such that the leading coefficient becomes 1. After this operation, the polynomial satisfies \( p(x) = x^n + \sum_{i=0}^{n-1} a_i x^i \), where \( n \) is the polynomial degree.

Precondition
The leading coefficient must be non-zero.

◆ normalize()

template<typename Real>
Real Sturm::Poly< Real >::normalize ( )
inline

Normalize the polynomial such that the maximum absolute coefficient is 1.

Returns
Scaling value used for normalization.

◆ operator*=() [1/2]

template<typename Real>
Poly & Sturm::Poly< Real >::operator*= ( const Poly< Real > & p)
inline
Parameters
[in]pPolynomial to multiply.
Returns
Reference to the polynomial.

◆ operator*=() [2/2]

template<typename Real>
Poly & Sturm::Poly< Real >::operator*= ( Real s)
inline
Parameters
[in]sScalar to multiply.
Returns
Reference to the polynomial.

◆ operator+=() [1/2]

template<typename Real>
Poly & Sturm::Poly< Real >::operator+= ( const Poly< Real > & p)
inline
Parameters
[in]pPolynomial to add.
Returns
Reference to the polynomial.

◆ operator+=() [2/2]

template<typename Real>
Poly & Sturm::Poly< Real >::operator+= ( Real s)
inline
Parameters
[in]sScalar to add.
Returns
Reference to the polynomial.

◆ operator-()

template<typename Real>
Poly Sturm::Poly< Real >::operator- ( )
inline
Returns
Negated polynomial.

◆ operator-=() [1/2]

template<typename Real>
Poly & Sturm::Poly< Real >::operator-= ( const Poly< Real > & p)
inline
Parameters
[in]pPolynomial to subtract.
Returns
Reference to the polynomial.

◆ operator-=() [2/2]

template<typename Real>
Poly & Sturm::Poly< Real >::operator-= ( Real s)
inline
Parameters
[in]sScalar to subtract.
Returns
Reference to the polynomial.

◆ operator=()

template<typename Real>
Poly & Sturm::Poly< Real >::operator= ( const Poly< Real > & p)
inline
Parameters
[in]pPolynomial to assign from.
Returns
Reference to the polynomial.

◆ order()

template<typename Real>
Integer Sturm::Poly< Real >::order ( ) const
inline
Returns
Order of the polynomial.

◆ purge()

template<typename Real>
void Sturm::Poly< Real >::purge ( const Real eps)
inline

Purge (set to 0) coefficients that are smaller than or equal to a given epsilon.

Parameters
[in]epsEpsilon value for purging coefficients.

◆ set_degree()

template<typename Real>
void Sturm::Poly< Real >::set_degree ( Integer degree)
inline
Parameters
[in]degreeDegree of the polynomial.

◆ set_monomial()

template<typename Real>
Poly & Sturm::Poly< Real >::set_monomial ( Real a)
inline
Parameters
[in]aCoefficient of the monomial.
Returns
Reference to the polynomial.

◆ set_order()

template<typename Real>
void Sturm::Poly< Real >::set_order ( Integer order)
inline
Parameters
[in]orderOrder of the polynomial.

◆ set_scalar()

template<typename Real>
Poly & Sturm::Poly< Real >::set_scalar ( Real s)
inline
Parameters
[in]sScalar value.
Returns
Reference to the polynomial.

◆ sign_variations()

template<typename Real>
Integer Sturm::Poly< Real >::sign_variations ( ) const
inline

Count the number of sign variations in the polynomial coefficients.

Returns
Number of sign variations.

◆ to_eigen() [1/2]

template<typename Real>
Vector & Sturm::Poly< Real >::to_eigen ( )
inlineprivate
Returns
The Eigen class.

◆ to_eigen() [2/2]

template<typename Real>
const Vector & Sturm::Poly< Real >::to_eigen ( ) const
inline
Returns
The Eigen const class.

◆ to_string()

template<typename Real>
std::string Sturm::Poly< Real >::to_string ( ) const
inline
Returns
String representation of the polynomial.

Member Data Documentation

◆ EPSILON

template<typename Real>
const Real Sturm::Poly< Real >::EPSILON
staticconstexpr
Initial value:
{
std::numeric_limits<Real>::epsilon()}

Machine epsilon.

◆ m_order

template<typename Real>
Integer Sturm::Poly< Real >::m_order
private

Polynomial order.


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