Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Euclid::MathUtils::Polynomial Class Referencefinal

Represents a polynomial function. More...

#include <Polynomial.h>

Inheritance diagram for Euclid::MathUtils::Polynomial:
Inheritance graph
[legend]
Collaboration diagram for Euclid::MathUtils::Polynomial:
Collaboration graph
[legend]

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< Functionclone () const override
 Creates a new polynomial with the same coefficients.
 
std::shared_ptr< Functionderivative () const override
 Returns the derivative of the polynomial.
 
std::shared_ptr< FunctionindefiniteIntegral () const override
 Returns the indefinite integral of the polynomial.
 
- Public Member Functions inherited from Euclid::MathUtils::Differentiable
virtual ~Differentiable ()=default
 Default destructor.
 
double integrate (const double x1, const double x2) const final
 
- Public Member Functions inherited from Euclid::MathUtils::Integrable
virtual ~Integrable ()=default
 Default destructor.
 

Private Attributes

std::vector< doublem_coef
 The vector where the polynomial coefficients are stored.
 
std::shared_ptr< Functionm_derivative {}
 The function representing the derivative (uses lazy initialization)
 
std::shared_ptr< Functionm_indefIntegral {}
 The function representing the indefinite integral (uses lazy initialization)
 

Detailed Description

Represents a polynomial function.

Definition at line 43 of file Polynomial.h.

Constructor & Destructor Documentation

◆ Polynomial()

Euclid::MathUtils::Polynomial::Polynomial ( std::vector< double coefficients)
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.

Parameters
coefficientsthe polynomial coefficients

Definition at line 34 of file Polynomial.cpp.

◆ ~Polynomial()

virtual Euclid::MathUtils::Polynomial::~Polynomial ( )
virtualdefault

Default destructor.

References Euclid::MathUtils::derivative().

Here is the call graph for this function:

Member Function Documentation

◆ clone()

std::unique_ptr< Function > Euclid::MathUtils::Polynomial::clone ( ) const
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.

◆ derivative()

std::shared_ptr< Function > Euclid::MathUtils::Polynomial::derivative ( ) const
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().

Here is the call graph for this function:

◆ getCoefficients()

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.

◆ indefiniteIntegral()

std::shared_ptr< Function > Euclid::MathUtils::Polynomial::indefiniteIntegral ( ) const
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().

Here is the call graph for this function:

◆ operator()() [1/2]

double Euclid::MathUtils::Polynomial::operator() ( const double  x) const
override

Calculates the value of the polynomial for the given value.

Definition at line 40 of file Polynomial.cpp.

References m_coef.

◆ operator()() [2/2]

void Euclid::MathUtils::Polynomial::operator() ( const std::vector< double > &  xs,
std::vector< double > &  out 
) const
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().

Here is the call graph for this function:

Member Data Documentation

◆ m_coef

std::vector<double> Euclid::MathUtils::Polynomial::m_coef
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()().

◆ m_derivative

std::shared_ptr<Function> Euclid::MathUtils::Polynomial::m_derivative {}
mutableprivate

The function representing the derivative (uses lazy initialization)

Definition at line 80 of file Polynomial.h.

Referenced by derivative().

◆ m_indefIntegral

std::shared_ptr<Function> Euclid::MathUtils::Polynomial::m_indefIntegral {}
mutableprivate

The function representing the indefinite integral (uses lazy initialization)

Definition at line 82 of file Polynomial.h.

Referenced by indefiniteIntegral().


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