Alexandria  2.16
Please provide a description of the project.
Public Member Functions | Private Attributes | List of all members
Euclid::MathUtils::Polynomial Class Reference

Represents a polynomial function. More...

#include <Polynomial.h>

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

Public Member Functions

 Polynomial (std::vector< double > coefficients)
 
virtual ~Polynomial ()=default
 Default destructor. More...
 
const std::vector< double > & getCoefficients () const
 Returns the coefficients of the polynomial. More...
 
double operator() (const double) const override
 Calculates the value of the polynomial for the given value. More...
 
std::unique_ptr< Functionclone () const override
 Creates a new polynomial with the same coefficients. More...
 
std::shared_ptr< Functionderivative () const override
 Returns the derivative of the polynomial. More...
 
std::shared_ptr< FunctionindefiniteIntegral () const override
 Returns the indefinite integral of the polynomial. More...
 
- Public Member Functions inherited from Euclid::MathUtils::Differentiable
virtual ~Differentiable ()
 Default destructor. More...
 
double integrate (const double x1, const double x2) const final
 
- Public Member Functions inherited from Euclid::MathUtils::Integrable
virtual ~Integrable ()=default
 Default destructor. More...
 
- Public Member Functions inherited from Euclid::MathUtils::Function
virtual ~Function ()=default
 Default destructor. More...
 

Private Attributes

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

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 33 of file Polynomial.cpp.

Referenced by clone().

◆ ~Polynomial()

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

Default destructor.

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::Function.

Definition at line 50 of file Polynomial.cpp.

References m_coef, and Polynomial().

Here is the call graph for this function:

◆ derivative()

std::shared_ptr< Function > Euclid::MathUtils::Polynomial::derivative ( ) const
overridevirtual

Returns the derivative of the polynomial.

Implements Euclid::MathUtils::Differentiable.

Definition at line 54 of file Polynomial.cpp.

References m_coef, and m_derivative.

◆ 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.

Referenced by Euclid::MathUtils::multiplyPolynomials().

◆ 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 65 of file Polynomial.cpp.

References m_coef, and m_indefIntegral.

◆ operator()()

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

Calculates the value of the polynomial for the given value.

Implements Euclid::MathUtils::Function.

Definition at line 40 of file Polynomial.cpp.

References m_coef.

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 77 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 79 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 81 of file Polynomial.h.

Referenced by indefiniteIntegral().


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