Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
Represents a polynomial function. More...
#include <Polynomial.h>
Public Member Functions | |
Polynomial (std::vector< double > coefficients) | |
virtual | ~Polynomial ()=default |
Default destructor. | |
const std::vector< double > & | getCoefficients () const |
Returns the coefficients of the polynomial. | |
double | operator() (const double) const override |
Calculates the value of the polynomial for the given value. | |
void | operator() (const std::vector< double > &xs, std::vector< double > &out) const override |
Calculates the value of the polynomial for the given values. | |
std::unique_ptr< Function > | clone () const override |
Creates a new polynomial with the same coefficients. | |
std::shared_ptr< Function > | derivative () const override |
Returns the derivative of the polynomial. | |
std::shared_ptr< Function > | indefiniteIntegral () const override |
Returns the indefinite integral of the polynomial. | |
![]() | |
virtual | ~Differentiable ()=default |
Default destructor. | |
double | integrate (const double x1, const double x2) const final |
![]() | |
virtual | ~Integrable ()=default |
Default destructor. | |
Private Attributes | |
std::vector< double > | m_coef |
The vector where the polynomial coefficients are stored. | |
std::shared_ptr< Function > | m_derivative {} |
The function representing the derivative (uses lazy initialization) | |
std::shared_ptr< Function > | m_indefIntegral {} |
The function representing the indefinite integral (uses lazy initialization) | |
Represents a polynomial function.
Definition at line 43 of file Polynomial.h.
|
explicit |
Constructs a new Polynomial function with the given coefficients. The index of the coefficients in the given vector corresponds to the degree of the coefficient.
coefficients | the polynomial coefficients |
Definition at line 34 of file Polynomial.cpp.
|
virtualdefault |
Default destructor.
References Euclid::MathUtils::derivative().
|
overridevirtual |
Creates a new polynomial with the same coefficients.
Implements Euclid::MathUtils::NAryFunction< N >.
Definition at line 55 of file Polynomial.cpp.
References m_coef.
|
overridevirtual |
Returns the derivative of the polynomial.
Implements Euclid::MathUtils::Differentiable.
Definition at line 59 of file Polynomial.cpp.
References m_coef, m_derivative, std::move(), and std::vector< T >::size().
const std::vector< double > & Euclid::MathUtils::Polynomial::getCoefficients | ( | ) | const |
Returns the coefficients of the polynomial.
Definition at line 36 of file Polynomial.cpp.
References m_coef.
|
overridevirtual |
Returns the indefinite integral of the polynomial.
Implements Euclid::MathUtils::Differentiable.
Definition at line 70 of file Polynomial.cpp.
References m_coef, m_indefIntegral, std::move(), and std::vector< T >::size().
Calculates the value of the polynomial for the given value.
Definition at line 40 of file Polynomial.cpp.
References m_coef.
|
override |
Calculates the value of the polynomial for the given values.
Definition at line 50 of file Polynomial.cpp.
References std::vector< T >::begin(), std::array< T >::begin(), std::array< T >::end(), std::vector< T >::resize(), std::array< T >::size(), and std::transform().
|
private |
The vector where the polynomial coefficients are stored.
Definition at line 78 of file Polynomial.h.
Referenced by clone(), derivative(), getCoefficients(), indefiniteIntegral(), and operator()().
|
mutableprivate |
The function representing the derivative (uses lazy initialization)
Definition at line 80 of file Polynomial.h.
Referenced by derivative().
|
mutableprivate |
The function representing the indefinite integral (uses lazy initialization)
Definition at line 82 of file Polynomial.h.
Referenced by indefiniteIntegral().