OpenMD 3.2
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
OpenMD::Polynomial< Real > Class Template Reference

A generic Polynomial class. More...

#include "math/Polynomial.hpp"

Public Types

using PolynomialType = Polynomial<Real>
using ExponentType = int
using CoefficientType = Real
using PolynomialPairMap = std::map<ExponentType, CoefficientType>
using iterator = typename PolynomialPairMap::iterator
using const_iterator = typename PolynomialPairMap::const_iterator

Public Member Functions

 Polynomial (Real v)
Real evaluate (const Real &x)
 Calculates the value of this Polynomial evaluated at the given x value.
Real evaluateDerivative (const Real &x)
 Returns the first derivative of this polynomial.
void setCoefficient (int exponent, const Real &coefficient)
 Set the coefficent of the specified exponent, if the coefficient is already there, it will be overwritten.
void addCoefficient (int exponent, const Real &coefficient)
 Set the coefficent of the specified exponent.
Real getCoefficient (ExponentType exponent)
 Returns the coefficient associated with the given power for this Polynomial.
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
iterator find (ExponentType exponent)
size_t size ()
int degree ()
PolynomialType & operator+= (const PolynomialType &p)
PolynomialType & operator-= (const PolynomialType &p)
PolynomialType & operator*= (const PolynomialType &p)
PolynomialType & operator*= (const Real v)
PolynomialType & operator+= (const Real v)
PolynomialType * getDerivative ()
 Returns the first derivative of this polynomial.
DynamicRectMatrix< Real > CreateCompanion ()
std::vector< std::complex< Real > > FindRoots ()
std::vector< Real > FindRealRoots ()

Detailed Description

template<typename Real>
class OpenMD::Polynomial< Real >

A generic Polynomial class.

Definition at line 86 of file Polynomial.hpp.

Member Typedef Documentation

◆ CoefficientType

template<typename Real>
using OpenMD::Polynomial< Real >::CoefficientType = Real

Definition at line 90 of file Polynomial.hpp.

◆ const_iterator

template<typename Real>
using OpenMD::Polynomial< Real >::const_iterator = typename PolynomialPairMap::const_iterator

Definition at line 93 of file Polynomial.hpp.

◆ ExponentType

template<typename Real>
using OpenMD::Polynomial< Real >::ExponentType = int

Definition at line 89 of file Polynomial.hpp.

◆ iterator

template<typename Real>
using OpenMD::Polynomial< Real >::iterator = typename PolynomialPairMap::iterator

Definition at line 92 of file Polynomial.hpp.

◆ PolynomialPairMap

template<typename Real>
using OpenMD::Polynomial< Real >::PolynomialPairMap = std::map<ExponentType, CoefficientType>

Definition at line 91 of file Polynomial.hpp.

◆ PolynomialType

template<typename Real>
using OpenMD::Polynomial< Real >::PolynomialType = Polynomial<Real>

Definition at line 88 of file Polynomial.hpp.

Constructor & Destructor Documentation

◆ Polynomial() [1/2]

template<typename Real>
OpenMD::Polynomial< Real >::Polynomial ( )
inline

Definition at line 95 of file Polynomial.hpp.

◆ Polynomial() [2/2]

template<typename Real>
OpenMD::Polynomial< Real >::Polynomial ( Real v)
inline

Definition at line 96 of file Polynomial.hpp.

Member Function Documentation

◆ addCoefficient()

template<typename Real>
void OpenMD::Polynomial< Real >::addCoefficient ( int exponent,
const Real & coefficient )
inline

Set the coefficent of the specified exponent.

If the coefficient is already there, just add the new coefficient to the old one, otherwise, just call setCoefficent

Parameters
exponentexponent of a term in this Polynomial
coefficientmultiplier of a term in this Polynomial

Definition at line 154 of file Polynomial.hpp.

Referenced by OpenMD::operator*(), OpenMD::operator+(), and OpenMD::operator-().

◆ begin() [1/2]

template<typename Real>
iterator OpenMD::Polynomial< Real >::begin ( )
inline

Definition at line 181 of file Polynomial.hpp.

◆ begin() [2/2]

template<typename Real>
const_iterator OpenMD::Polynomial< Real >::begin ( ) const
inline

Definition at line 182 of file Polynomial.hpp.

◆ CreateCompanion()

template<typename Real>
DynamicRectMatrix< Real > OpenMD::Polynomial< Real >::CreateCompanion ( )
inline

Definition at line 268 of file Polynomial.hpp.

◆ degree()

template<typename Real>
int OpenMD::Polynomial< Real >::degree ( )
inline

Definition at line 191 of file Polynomial.hpp.

◆ end() [1/2]

template<typename Real>
iterator OpenMD::Polynomial< Real >::end ( )
inline

Definition at line 184 of file Polynomial.hpp.

◆ end() [2/2]

template<typename Real>
const_iterator OpenMD::Polynomial< Real >::end ( ) const
inline

Definition at line 185 of file Polynomial.hpp.

◆ evaluate()

template<typename Real>
Real OpenMD::Polynomial< Real >::evaluate ( const Real & x)
inline

Calculates the value of this Polynomial evaluated at the given x value.

Returns
The value of this Polynomial evaluates at the given x value
Parameters
xthe value of the independent variable for this Polynomial function

Definition at line 104 of file Polynomial.hpp.

◆ evaluateDerivative()

template<typename Real>
Real OpenMD::Polynomial< Real >::evaluateDerivative ( const Real & x)
inline

Returns the first derivative of this polynomial.

Returns
the first derivative of this polynomial
Parameters
x

Definition at line 123 of file Polynomial.hpp.

◆ find()

template<typename Real>
iterator OpenMD::Polynomial< Real >::find ( ExponentType exponent)
inline

Definition at line 187 of file Polynomial.hpp.

◆ FindRealRoots()

template<typename Real>
std::vector< Real > OpenMD::Polynomial< Real >::FindRealRoots ( )
inline

Definition at line 301 of file Polynomial.hpp.

◆ FindRoots()

template<typename Real>
std::vector< std::complex< Real > > OpenMD::Polynomial< Real >::FindRoots ( )
inline

Definition at line 285 of file Polynomial.hpp.

◆ getCoefficient()

template<typename Real>
Real OpenMD::Polynomial< Real >::getCoefficient ( ExponentType exponent)
inline

Returns the coefficient associated with the given power for this Polynomial.

Returns
the coefficient associated with the given power for this Polynomial
Parameters
exponentexponent of any term in this Polynomial

Definition at line 171 of file Polynomial.hpp.

◆ getDerivative()

template<typename Real>
PolynomialType * OpenMD::Polynomial< Real >::getDerivative ( )
inline

Returns the first derivative of this polynomial.

Returns
the first derivative of this polynomial

Definition at line 251 of file Polynomial.hpp.

◆ operator*=() [1/2]

template<typename Real>
PolynomialType & OpenMD::Polynomial< Real >::operator*= ( const PolynomialType & p)
inline

Definition at line 217 of file Polynomial.hpp.

◆ operator*=() [2/2]

template<typename Real>
PolynomialType & OpenMD::Polynomial< Real >::operator*= ( const Real v)
inline

Definition at line 231 of file Polynomial.hpp.

◆ operator+=() [1/2]

template<typename Real>
PolynomialType & OpenMD::Polynomial< Real >::operator+= ( const PolynomialType & p)
inline

Definition at line 199 of file Polynomial.hpp.

◆ operator+=() [2/2]

template<typename Real>
PolynomialType & OpenMD::Polynomial< Real >::operator+= ( const Real v)
inline

Definition at line 242 of file Polynomial.hpp.

◆ operator-=()

template<typename Real>
PolynomialType & OpenMD::Polynomial< Real >::operator-= ( const PolynomialType & p)
inline

Definition at line 209 of file Polynomial.hpp.

◆ setCoefficient()

template<typename Real>
void OpenMD::Polynomial< Real >::setCoefficient ( int exponent,
const Real & coefficient )
inline

Set the coefficent of the specified exponent, if the coefficient is already there, it will be overwritten.

Parameters
exponentexponent of a term in this Polynomial
coefficientmultiplier of a term in this Polynomial

Definition at line 143 of file Polynomial.hpp.

Referenced by OpenMD::Polynomial< RealType >::addCoefficient(), OpenMD::getDerivative(), and OpenMD::Polynomial< RealType >::getDerivative().

◆ size()

template<typename Real>
size_t OpenMD::Polynomial< Real >::size ( )
inline

Definition at line 189 of file Polynomial.hpp.


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