DiFfRG
Loading...
Searching...
No Matches
polynomials.hh
Go to the documentation of this file.
1#pragma once
2
3// standard library
4#include <cmath>
5#include <vector>
6
7// DiFfRG
9
10namespace DiFfRG
11{
16 {
17 public:
22 Polynomial(const std::vector<double> &coefficients);
23
27 const double &operator[](const uint &i) const;
28
32 double &operator[](const uint &i);
33
37 double operator()(const double &x) const;
38
42 void operator*=(const double &scalar);
43
47 void operator*=(const Polynomial &other);
48
57 Polynomial anti_derivative(const double &integration_constant) const;
58
67
75 double integral(const double &x_min, const double &x_max) const;
76
83
84 private:
85 std::vector<double> coefficients;
86 };
87} // namespace DiFfRG
A class representing a polynomial.
Definition polynomials.hh:16
double operator()(const double &x) const
Evaluate the polynomial at a given point x.
Polynomial derivative() const
Compute the derivative of the polynomial.
void operator*=(const double &scalar)
Multiply the polynomial by a scalar.
const double & operator[](const uint &i) const
Access the i-th coefficient of the polynomial.
double integral(const double &x_min, const double &x_max) const
Compute the integral of the polynomial between two points.
std::vector< double > coefficients
Definition polynomials.hh:85
Polynomial anti_derivative(const double &integration_constant) const
Compute the antiderivative of the polynomial. An integration constant is given as an argument.
Polynomial square_argument() const
A utility function to obtain from this polynomial P(x) the polynomial Q(x) = P(x^2)
Polynomial(const std::vector< double > &coefficients)
Construct a new Polynomial object from a list of coefficients. The coefficients are ordered from the ...
double & operator[](const uint &i)
Access the i-th coefficient of the polynomial.
void operator*=(const Polynomial &other)
Multiply the polynomial by another polynomial.
Definition complex_math.hh:14
unsigned int uint
Definition utils.hh:22