37 template <
typename FloatingType>
56 Polynomial (
const FloatingType* coefficients,
int numCoefficients)
57 : coeffs (coefficients, numCoefficients)
78 template <
typename... Values>
97 for (
int i = coeffs.
size(); --i >= 0;)
106 return coeffs.
size() - 1;
115 for (
auto& c : result.coeffs)
124 if (coeffs.
size() < other.coeffs.
size())
129 for (
int i = 0; i < other.coeffs.
size(); ++i)
130 result[i] += other[i];
141 auto N1 = coeffs.
size();
142 auto N2 = other.coeffs.
size();
143 auto Nmax = jmax (N1, N2);
145 auto N = N1 + N2 - 1;
147 for (
int i = 0; i < N; ++i)
149 FloatingType value (0);
151 for (
int j = 0; j < Nmax; ++j)
152 if (j >= 0 && j < N1 && i - j >= 0 && i - j < N2)
153 value = value + (*this)[j] * other[i - j];
155 result.coeffs.
add (value);
ElementType getUnchecked(int index) const
bool isEmpty() const noexcept
int size() const noexcept
void add(const ElementType &newElement)
ElementType & getReference(int index) noexcept
Polynomial< FloatingType > getProductWith(const Polynomial< FloatingType > &other) const
Polynomial< FloatingType > withGain(double gain) const
Polynomial(Values... items)
FloatingType operator[](int index) const noexcept
Polynomial(const Polynomial &)=default
Polynomial< FloatingType > getSumWith(const Polynomial< FloatingType > &other) const
Polynomial & operator=(const Polynomial &)=default
Polynomial(const FloatingType *coefficients, int numCoefficients)
Polynomial(Polynomial &&)=default
FloatingType operator()(FloatingType x) const noexcept