43 for (
double coef :
m_coef) {
44 result += coef * xPow;
56 std::vector<double> derivCoef {};
57 for (
size_t i = 1; i <
m_coef.size(); i++) {
58 derivCoef.push_back(i * this->
m_coef[i]);
67 std::vector<double> indefIntegCoef {};
68 indefIntegCoef.push_back(0.);
69 for (
size_t i = 0; i <
m_coef.size(); i++) {
70 indefIntegCoef.push_back(
m_coef[i] / (i+1));
std::shared_ptr< Function > m_indefIntegral
The function representing the indefinite integral (uses lazy initialization)
std::vector< double > m_coef
The vector where the polynomial coefficients are stored.
Polynomial(std::vector< double > coefficients)
std::shared_ptr< Function > derivative() const override
Returns the derivative of the polynomial.
Represents a polynomial function.
std::shared_ptr< Function > m_derivative
The function representing the derivative (uses lazy initialization)
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.
std::unique_ptr< Function > clone() const override
Creates a new polynomial with the same coefficients.
std::shared_ptr< Function > indefiniteIntegral() const override
Returns the indefinite integral of the polynomial.