Controlpp
Loading...
Searching...
No Matches
controlpp::FixedPolynom< T, Order > Class Template Reference

Describes a mathematical polynomial of fixed size. More...

#include <controlpp/Polynom.hpp>

Public Types

using value_type = T
 
using vector_type = Eigen::Vector< T, Order+1 >
 

Public Member Functions

 FixedPolynom ()=default
 decault constructs the polynomials with the default values of their data type
 
 FixedPolynom (const FixedPolynom &)=default
 Copy constructor.
 
template<std::convertible_to< T > U>
 FixedPolynom (const U &value)
 
template<int M>
requires (M < Order)
 FixedPolynom (const FixedPolynom< T, M > &other)
 
FixedPolynomoperator= (const FixedPolynom &)=default
 Copy assignment operator.
 
template<int M>
requires (M < Order)
FixedPolynomoperator= (const FixedPolynom< T, M > &other)
 
 FixedPolynom (const T(&values)[Order+1])
 Constructs a polynomial from an array.
 
template<int M>
requires (M < Order+1)
 FixedPolynom (const T(&values)[M])
 
 FixedPolynom (const Eigen::Vector< T, Order+1 > &vector)
 Constructs a polynomial from a vector.
 
template<int M>
requires (M < Order+1)
 FixedPolynom (const Eigen::Vector< T, M > &vector)
 
FixedPolynomoperator= (const T(&values)[Order+1])
 
template<int M>
requires (M < Order+1)
FixedPolynomoperator= (const T(&values)[M])
 
 FixedPolynom (const Polynom< T, Order > &poly)
 
template<int M>
requires (M < Order)
 FixedPolynom (const Polynom< T, M > &poly)
 
 operator Polynom< T, Order > () const
 
FixedPolynomoperator= (const Eigen::Vector< T, Order+1 > &vector)
 Assigns the values of a vector to this polynomial.
 
template<int M>
requires (M < Order+1)
FixedPolynomoperator= (const Eigen::Vector< T, M > &vector)
 
const T & operator[] (size_t i) const
 Access elements at the i-th position.
 
T & operator[] (size_t i)
 Access elements at the i-th position.
 
const T & at (size_t i) const
 Access elements at the i-th position.
 
T & at (size_t i)
 Access elements at the i-th position.
 
vector_typevector ()
 Returns the underlying vector that holds the values.
 
const vector_typevector () const
 Returns the underlying vector that holds the values.
 
size_t size () const
 returns the size of the polynomial
 
size_t order () const
 returns the order of the polynomial
 
void setZero ()
 sets all entries to zero
 
void print (std::ostream &stream, std::string_view var="x") const
 prints polynomial to an output character stream with a variale
 
template<int M>
requires (M <= Order)
FixedPolynomoperator+= (const FixedPolynom< T, M > &other)
 
template<int M>
requires (M <= Order)
FixedPolynomoperator-= (const FixedPolynom< T, M > &other)
 

Friends

std::ostream & operator<< (std::ostream &stream, const FixedPolynom &poly)
 prints the polynomial (pretty) to an output stream with "x" as the symbol name of the variable
 

Detailed Description

template<class T, int Order>
class controlpp::FixedPolynom< T, Order >

Describes a mathematical polynomial of fixed size.

Does not grow in size like its sibling controlpp::Polynom as a result of operations.

Describes polynomials in the form of:

\[ a_1 + a_2 x + a_3 x^2 .. \]

, where indices correspond to the parameter number and the potence

Template Parameters
TThe datatype of the polynomial parameters (e.g: float, double, complex)
NThe size of the polynomial, aka. number of parameters, aka. max order plus one
AutoGrowIf true for at least one polynomial of an operation the resulting polynomial will grow automatically in size to contain all values. Usually set false if one needs to sum over polynomials in a loop.

Member Typedef Documentation

◆ value_type

template<class T , int Order>
using controlpp::FixedPolynom< T, Order >::value_type = T

◆ vector_type

template<class T , int Order>
using controlpp::FixedPolynom< T, Order >::vector_type = Eigen::Vector<T, Order+1>

Constructor & Destructor Documentation

◆ FixedPolynom() [1/10]

template<class T , int Order>
controlpp::FixedPolynom< T, Order >::FixedPolynom ( )
default

decault constructs the polynomials with the default values of their data type

◆ FixedPolynom() [2/10]

template<class T , int Order>
controlpp::FixedPolynom< T, Order >::FixedPolynom ( const FixedPolynom< T, Order > &  )
default

Copy constructor.

◆ FixedPolynom() [3/10]

template<class T , int Order>
template<std::convertible_to< T > U>
controlpp::FixedPolynom< T, Order >::FixedPolynom ( const U &  value)
inline

◆ FixedPolynom() [4/10]

template<class T , int Order>
template<int M>
requires (M < Order)
controlpp::FixedPolynom< T, Order >::FixedPolynom ( const FixedPolynom< T, M > &  other)
inline

◆ FixedPolynom() [5/10]

template<class T , int Order>
controlpp::FixedPolynom< T, Order >::FixedPolynom ( const T(&)  values[Order+1])
inlineexplicit

Constructs a polynomial from an array.

Parameters
valuesthe values to be assigned to the polynomial

◆ FixedPolynom() [6/10]

template<class T , int Order>
template<int M>
requires (M < Order+1)
controlpp::FixedPolynom< T, Order >::FixedPolynom ( const T(&)  values[M])
inlineexplicit

◆ FixedPolynom() [7/10]

template<class T , int Order>
controlpp::FixedPolynom< T, Order >::FixedPolynom ( const Eigen::Vector< T, Order+1 > &  vector)
inlineexplicit

Constructs a polynomial from a vector.

Parameters
vectorEigen::Vector object

◆ FixedPolynom() [8/10]

template<class T , int Order>
template<int M>
requires (M < Order+1)
controlpp::FixedPolynom< T, Order >::FixedPolynom ( const Eigen::Vector< T, M > &  vector)
inlineexplicit

◆ FixedPolynom() [9/10]

template<class T , int Order>
controlpp::FixedPolynom< T, Order >::FixedPolynom ( const Polynom< T, Order > &  poly)
inlineexplicit

◆ FixedPolynom() [10/10]

template<class T , int Order>
template<int M>
requires (M < Order)
controlpp::FixedPolynom< T, Order >::FixedPolynom ( const Polynom< T, M > &  poly)
inlineexplicit

Member Function Documentation

◆ at() [1/2]

template<class T , int Order>
T & controlpp::FixedPolynom< T, Order >::at ( size_t  i)
inline

Access elements at the i-th position.

Parameters
ithe value index to be accessed. Indices correspond to the order of the parameter
Returns
a mutable reference to the element

◆ at() [2/2]

template<class T , int Order>
const T & controlpp::FixedPolynom< T, Order >::at ( size_t  i) const
inline

Access elements at the i-th position.

Parameters
ithe value index to be accessed. Indices correspond to the order of the parameter
Returns
an immutable reference to the element

◆ operator Polynom< T, Order >()

template<class T , int Order>
controlpp::FixedPolynom< T, Order >::operator Polynom< T, Order > ( ) const
inline

◆ operator+=()

template<class T , int Order>
template<int M>
requires (M <= Order)
FixedPolynom & controlpp::FixedPolynom< T, Order >::operator+= ( const FixedPolynom< T, M > &  other)
inline

◆ operator-=()

template<class T , int Order>
template<int M>
requires (M <= Order)
FixedPolynom & controlpp::FixedPolynom< T, Order >::operator-= ( const FixedPolynom< T, M > &  other)
inline

◆ operator=() [1/6]

template<class T , int Order>
template<int M>
requires (M < Order+1)
FixedPolynom & controlpp::FixedPolynom< T, Order >::operator= ( const Eigen::Vector< T, M > &  vector)
inline

◆ operator=() [2/6]

template<class T , int Order>
FixedPolynom & controlpp::FixedPolynom< T, Order >::operator= ( const Eigen::Vector< T, Order+1 > &  vector)
inline

Assigns the values of a vector to this polynomial.

Parameters
vectorAn Eigen::Vector holding the values to be assigned to this polynomia

◆ operator=() [3/6]

template<class T , int Order>
FixedPolynom & controlpp::FixedPolynom< T, Order >::operator= ( const FixedPolynom< T, Order > &  )
default

Copy assignment operator.

◆ operator=() [4/6]

template<class T , int Order>
template<int M>
requires (M < Order)
FixedPolynom & controlpp::FixedPolynom< T, Order >::operator= ( const FixedPolynom< T, M > &  other)
inline

◆ operator=() [5/6]

template<class T , int Order>
template<int M>
requires (M < Order+1)
FixedPolynom & controlpp::FixedPolynom< T, Order >::operator= ( const T(&)  values[M])
inline

◆ operator=() [6/6]

template<class T , int Order>
FixedPolynom & controlpp::FixedPolynom< T, Order >::operator= ( const T(&)  values[Order+1])
inline

◆ operator[]() [1/2]

template<class T , int Order>
T & controlpp::FixedPolynom< T, Order >::operator[] ( size_t  i)
inline

Access elements at the i-th position.

Parameters
ithe value index to be accessed. Indices correspond to the order of the parameter
Returns
a mutable reference to the element

◆ operator[]() [2/2]

template<class T , int Order>
const T & controlpp::FixedPolynom< T, Order >::operator[] ( size_t  i) const
inline

Access elements at the i-th position.

Parameters
ithe value index to be accessed. Indices correspond to the order of the parameter
Returns
an immutable reference to the element

◆ order()

template<class T , int Order>
size_t controlpp::FixedPolynom< T, Order >::order ( ) const
inline

returns the order of the polynomial

the order can maxially be one smaller then the size of the polynomial. Takes zero data entries size_to account.

Returns
an size_teger value holding the order of the polynomial

◆ print()

template<class T , int Order>
void controlpp::FixedPolynom< T, Order >::print ( std::ostream &  stream,
std::string_view  var = "x" 
) const
inline

prints polynomial to an output character stream with a variale

Parameters
streamthe stream to be printed to
varthe symbol name of the variable

◆ setZero()

template<class T , int Order>
void controlpp::FixedPolynom< T, Order >::setZero ( )
inline

sets all entries to zero

◆ size()

template<class T , int Order>
size_t controlpp::FixedPolynom< T, Order >::size ( ) const
inline

returns the size of the polynomial

Note that the size is one larger than the order of the polynomial (assuming non-zero entries)

Returns
an size_teger value holding the size

◆ vector() [1/2]

template<class T , int Order>
vector_type & controlpp::FixedPolynom< T, Order >::vector ( )
inline

Returns the underlying vector that holds the values.

Returns
A mutable reference to an Eigen::Vector object holding the values

◆ vector() [2/2]

template<class T , int Order>
const vector_type & controlpp::FixedPolynom< T, Order >::vector ( ) const
inline

Returns the underlying vector that holds the values.

Returns
An immutable reference to an Eigen::Vector object holding the values

Friends And Related Symbol Documentation

◆ operator<<

template<class T , int Order>
std::ostream & operator<< ( std::ostream &  stream,
const FixedPolynom< T, Order > &  poly 
)
friend

prints the polynomial (pretty) to an output stream with "x" as the symbol name of the variable

Parameters
streama reference to the output stream printed to
polythe polynomial to be printed
Returns
retuns the reference of the output stream

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