42 for (
double coef :
m_coef) {
43 result += coef * xPow;
69 indefIntegCoef.push_back(
m_coef[i] / (i + 1));
Represents a polynomial function.
std::shared_ptr< Function > m_derivative
The function representing the derivative (uses lazy initialization)
std::shared_ptr< Function > indefiniteIntegral() const override
Returns the indefinite integral of the polynomial.
std::shared_ptr< Function > m_indefIntegral
The function representing the indefinite integral (uses lazy initialization)
Polynomial(std::vector< double > coefficients)
std::vector< double > m_coef
The vector where the polynomial coefficients are stored.
double operator()(const double) const override
Calculates the value of the polynomial for the given value.
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.
const std::vector< double > & getCoefficients() const
Returns the coefficients of the polynomial.