OpenMD 3.0
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< complex< Real > > FindRoots ()
 
std::vector< Real > FindRealRoots ()
 

Detailed Description

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

A generic Polynomial class.

Definition at line 83 of file Polynomial.hpp.

Member Typedef Documentation

◆ CoefficientType

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

Definition at line 87 of file Polynomial.hpp.

◆ const_iterator

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

Definition at line 90 of file Polynomial.hpp.

◆ ExponentType

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

Definition at line 86 of file Polynomial.hpp.

◆ iterator

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

Definition at line 89 of file Polynomial.hpp.

◆ PolynomialPairMap

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

Definition at line 88 of file Polynomial.hpp.

◆ PolynomialType

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

Definition at line 85 of file Polynomial.hpp.

Constructor & Destructor Documentation

◆ Polynomial() [1/2]

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

Definition at line 92 of file Polynomial.hpp.

◆ Polynomial() [2/2]

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

Definition at line 93 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 151 of file Polynomial.hpp.

References OpenMD::Polynomial< Real >::setCoefficient().

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

◆ begin() [1/2]

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

Definition at line 178 of file Polynomial.hpp.

◆ begin() [2/2]

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

Definition at line 179 of file Polynomial.hpp.

◆ CreateCompanion()

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

Definition at line 265 of file Polynomial.hpp.

◆ degree()

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

Definition at line 188 of file Polynomial.hpp.

◆ end() [1/2]

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

Definition at line 181 of file Polynomial.hpp.

◆ end() [2/2]

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

Definition at line 182 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 101 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 120 of file Polynomial.hpp.

◆ find()

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

Definition at line 184 of file Polynomial.hpp.

◆ FindRealRoots()

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

Definition at line 298 of file Polynomial.hpp.

◆ FindRoots()

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

Definition at line 282 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 168 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 248 of file Polynomial.hpp.

References OpenMD::Polynomial< Real >::setCoefficient().

◆ operator*=() [1/2]

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

Definition at line 214 of file Polynomial.hpp.

◆ operator*=() [2/2]

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

Definition at line 228 of file Polynomial.hpp.

◆ operator+=() [1/2]

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

Definition at line 196 of file Polynomial.hpp.

◆ operator+=() [2/2]

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

Definition at line 239 of file Polynomial.hpp.

◆ operator-=()

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

Definition at line 206 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 140 of file Polynomial.hpp.

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

◆ size()

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

Definition at line 186 of file Polynomial.hpp.


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