SOFA API  014b24ea
Open source framework for multi-physics simuation
sofa::helper::Polynomial_LD< Real, N > Class Template Reference

#include <Polynomial_LD.h>

A generic polynomial with N variables of type Real. A polynomial is a list composed of several monomials. More...

Detailed Description

template<typename Real, unsigned int N>
class sofa::helper::Polynomial_LD< Real, N >

A generic polynomial with N variables of type Real. A polynomial is a list composed of several monomials.

Public Attributes

unsigned int nbOfMonomial
 
MonomialsList listOfMonoMial
 

Public Member Functions

 Polynomial_LD ()
 Default constructor. More...
 
 Polynomial_LD (const Polynomial_LD< Real, N > &a)
 Copy constructor. More...
 
 Polynomial_LD (const Monomial_LD< Real, N > &a)
 
Polynomial_LD< Real, N > & operator= (const Polynomial_LD< Real, N > &b)
 Assign operator. More...
 
 Polynomial_LD (const unsigned int nbofTerm,...)
 setting of Polynomial More...
 
void Set (const unsigned int nbofTerm,...)
 
int degree ()
 
bool operator== (const Polynomial_LD< Real, N > &b) const
 Return true if a and b has the same powers. More...
 
bool operator!= (const Polynomial_LD< Real, N > &b) const
 
Polynomial_LD< Real, N > & operator*= (const Real &alpha)
 
Polynomial_LD< Real, N > & operator/= (const Real &alpha)
 
Polynomial_LD< Real, N > & operator+= (const Monomial_LD< Real, N > &b)
 
Polynomial_LD< Real, N > & operator+= (const Polynomial_LD< Real, N > &b)
 
Polynomial_LD< Real, N > & operator-= (const Polynomial_LD< Real, N > &b)
 
Polynomial_LD< Real, N > operator+ () const
 
Polynomial_LD< Real, N > operator- () const
 
Polynomial_LD< Real, N > & operator*= (const Polynomial_LD< Real, N > &b)
 
Polynomial_LD< Real, N > operator* (const Real &alpha)
 
Polynomial_LD< Real, N > operator/ (const Real &alpha)
 
Polynomial_LD< Real, N > operator+ (const Monomial_LD< Real, N > &a)
 
Polynomial_LD< Real, N > operator+ (const Polynomial_LD< Real, N > &a)
 
Polynomial_LD< Real, N > operator- (const Polynomial_LD< Real, N > &a)
 
Polynomial_LD< Real, N > operator* (const Polynomial_LD< Real, N > &a)
 
Real operator() (const RNpoint &x) const
 Evaluating. More...
 
Real operator() (const RNpoint &x, unsigned int idvar) const
 Evaluating first partial derivative by idvar-th variable. More...
 
Polynomial_LD< Real, N > d (const unsigned int &ideriv) const
 Evaluating partial derivative hight order by idvar-th variable in ideriv-th order. More...
 
void setnbOfMonomial (int m_nbofmonomial)
 
void writeToStream (std::ostream &stream) const
 
void readFromStream (std::istream &stream)
 
std::string getString () const
 
void sort ()
 

Protected Member Functions

void exchangeMonomial (unsigned int ithMono, unsigned int jthMono)
 The sort must be done after each constructor and each operation where monomials are inserted. More...
 
void sortByVar (unsigned int idVar)
 

Friends

template<typename FReal , unsigned int FN>
Polynomial_LD< FReal, FN > & operator* (const FReal &alpha, Polynomial_LD< FReal, FN > &r)
 
template<typename FReal , unsigned int FN>
Polynomial_LD< FReal, FN > & operator* (const Monomial_LD< FReal, FN > &a, Polynomial_LD< FReal, FN > &r)
 poly=poly+mono || mono + poly More...
 

Attribute details

template<typename Real , unsigned int N>
MonomialsList sofa::helper::Polynomial_LD< Real, N >::listOfMonoMial
template<typename Real , unsigned int N>
unsigned int sofa::helper::Polynomial_LD< Real, N >::nbOfMonomial

Constructor details

template<typename Real , unsigned int N>
sofa::helper::Polynomial_LD< Real, N >::Polynomial_LD ( )

Default constructor.

template<typename Real , unsigned int N>
sofa::helper::Polynomial_LD< Real, N >::Polynomial_LD ( const Polynomial_LD< Real, N > &  a)

Copy constructor.

template<typename Real , unsigned int N>
sofa::helper::Polynomial_LD< Real, N >::Polynomial_LD ( const Monomial_LD< Real, N > &  a)
template<typename Real , unsigned int N>
sofa::helper::Polynomial_LD< Real, N >::Polynomial_LD ( const unsigned int  nbofTerm,
  ... 
)

setting of Polynomial

Function details

template<typename Real , unsigned int N>
Polynomial_LD< Real, N > sofa::helper::Polynomial_LD< Real, N >::d ( const unsigned int ideriv) const

Evaluating partial derivative hight order by idvar-th variable in ideriv-th order.

Derivative operator alowing to write p1=p2.d(x);

template<typename Real , unsigned int N>
int sofa::helper::Polynomial_LD< Real, N >::degree ( )
template<typename Real , unsigned int N>
void sofa::helper::Polynomial_LD< Real, N >::exchangeMonomial ( unsigned int  ithMono,
unsigned int  jthMono 
)
protected

The sort must be done after each constructor and each operation where monomials are inserted.

template<typename Real , unsigned int N>
std::string sofa::helper::Polynomial_LD< Real, N >::getString ( ) const
template<typename Real , unsigned int N>
bool sofa::helper::Polynomial_LD< Real, N >::operator!= ( const Polynomial_LD< Real, N > &  b) const
inline
template<typename Real , unsigned int N>
Real sofa::helper::Polynomial_LD< Real, N >::operator() ( const RNpoint x) const

Evaluating.

template<typename Real , unsigned int N>
Real sofa::helper::Polynomial_LD< Real, N >::operator() ( const RNpoint x,
unsigned int  idvar 
) const

Evaluating first partial derivative by idvar-th variable.

template<typename Real , unsigned int N>
Polynomial_LD<Real,N> sofa::helper::Polynomial_LD< Real, N >::operator* ( const Real alpha)
inline
template<typename Real , unsigned int N>
Polynomial_LD<Real,N> sofa::helper::Polynomial_LD< Real, N >::operator* ( const Polynomial_LD< Real, N > &  a)
inline
template<typename Real , unsigned int N>
Polynomial_LD< Real, N > & sofa::helper::Polynomial_LD< Real, N >::operator*= ( const Real alpha)
template<typename Real , unsigned int N>
Polynomial_LD< Real, N > & sofa::helper::Polynomial_LD< Real, N >::operator*= ( const Polynomial_LD< Real, N > &  b)
template<typename Real , unsigned int N>
Polynomial_LD<Real,N> sofa::helper::Polynomial_LD< Real, N >::operator+ ( ) const
inline
template<typename Real , unsigned int N>
Polynomial_LD<Real,N> sofa::helper::Polynomial_LD< Real, N >::operator+ ( const Monomial_LD< Real, N > &  a)
inline
template<typename Real , unsigned int N>
Polynomial_LD<Real,N> sofa::helper::Polynomial_LD< Real, N >::operator+ ( const Polynomial_LD< Real, N > &  a)
inline
template<typename Real , unsigned int N>
Polynomial_LD< Real, N > & sofa::helper::Polynomial_LD< Real, N >::operator+= ( const Monomial_LD< Real, N > &  b)
template<typename Real , unsigned int N>
Polynomial_LD< Real, N > & sofa::helper::Polynomial_LD< Real, N >::operator+= ( const Polynomial_LD< Real, N > &  b)
template<typename Real , unsigned int N>
Polynomial_LD< Real, N > sofa::helper::Polynomial_LD< Real, N >::operator- ( ) const
template<typename Real , unsigned int N>
Polynomial_LD<Real,N> sofa::helper::Polynomial_LD< Real, N >::operator- ( const Polynomial_LD< Real, N > &  a)
inline
template<typename Real , unsigned int N>
Polynomial_LD< Real, N > & sofa::helper::Polynomial_LD< Real, N >::operator-= ( const Polynomial_LD< Real, N > &  b)
template<typename Real , unsigned int N>
Polynomial_LD<Real,N> sofa::helper::Polynomial_LD< Real, N >::operator/ ( const Real alpha)
inline
template<typename Real , unsigned int N>
Polynomial_LD< Real, N > & sofa::helper::Polynomial_LD< Real, N >::operator/= ( const Real alpha)
template<typename Real , unsigned int N>
Polynomial_LD<Real,N>& sofa::helper::Polynomial_LD< Real, N >::operator= ( const Polynomial_LD< Real, N > &  b)
inline

Assign operator.

template<typename Real , unsigned int N>
bool sofa::helper::Polynomial_LD< Real, N >::operator== ( const Polynomial_LD< Real, N > &  b) const

Return true if a and b has the same powers.

template<typename Real , unsigned int N>
void sofa::helper::Polynomial_LD< Real, N >::readFromStream ( std::istream &  stream)
template<typename Real , unsigned int N>
void sofa::helper::Polynomial_LD< Real, N >::Set ( const unsigned int  nbofTerm,
  ... 
)
template<typename Real , unsigned int N>
void sofa::helper::Polynomial_LD< Real, N >::setnbOfMonomial ( int  m_nbofmonomial)
template<typename Real , unsigned int N>
void sofa::helper::Polynomial_LD< Real, N >::sort ( )
template<typename Real , unsigned int N>
void sofa::helper::Polynomial_LD< Real, N >::sortByVar ( unsigned int  idVar)
protected
template<typename Real , unsigned int N>
void sofa::helper::Polynomial_LD< Real, N >::writeToStream ( std::ostream &  stream) const

Related details

template<typename Real , unsigned int N>
template<typename FReal , unsigned int FN>
Polynomial_LD<FReal,FN>& operator* ( const FReal &  alpha,
Polynomial_LD< FReal, FN > &  r 
)
friend

Comutativity of operator*(Real): Allowing to write p1=r*p2; or p1=p2*r; Polynomial_LD = Polynomial_LD*Real || Real*Polynomial_LD.

template<typename Real , unsigned int N>
template<typename FReal , unsigned int FN>
Polynomial_LD<FReal,FN>& operator* ( const Monomial_LD< FReal, FN > &  a,
Polynomial_LD< FReal, FN > &  r 
)
friend

poly=poly+mono || mono + poly