34template <
typename FloatingType>
53 Polynomial (
const FloatingType* coefficients,
int numCoefficients)
54 : coeffs (coefficients, numCoefficients)
75 template <
typename... Values>
94 for (
int i = coeffs.
size(); --i >= 0;)
103 return coeffs.
size() - 1;
112 for (
auto& c : result.coeffs)
121 if (coeffs.
size() < other.coeffs.size())
122 return other.getSumWith (*
this);
126 for (
int i = 0; i < other.coeffs.size(); ++i)
127 result[i] += other[i];
138 auto N1 = coeffs.
size();
139 auto N2 = other.coeffs.size();
140 auto Nmax = jmax (N1, N2);
142 auto N = N1 + N2 - 1;
144 for (
int i = 0; i < N; ++i)
146 FloatingType value (0);
148 for (
int j = 0; j < Nmax; ++j)
149 if (j >= 0 && j < N1 && i - j >= 0 && i - j < N2)
150 value = value + (*this)[j] * other[i - j];
152 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 & operator=(const Polynomial &)=default
Polynomial(Values... items)
FloatingType operator[](int index) const noexcept
Polynomial(const Polynomial &)=default
Polynomial< FloatingType > getSumWith(const Polynomial< FloatingType > &other) const
Polynomial< FloatingType > withGain(double gain) const
Polynomial(const FloatingType *coefficients, int numCoefficients)
Polynomial< FloatingType > getProductWith(const Polynomial< FloatingType > &other) const
Polynomial(Polynomial &&)=default
FloatingType operator()(FloatingType x) const noexcept