34template <
typename FloatingType>
53 Polynomial (
const FloatingType* coefficients,
int numCoefficients)
54 : coeffs (coefficients, numCoefficients)
56 jassert (! coeffs.isEmpty());
75 template <
typename... Values>
78 jassert (! coeffs.isEmpty());
83 FloatingType
operator[] (
int index)
const noexcept {
return coeffs.getUnchecked (index); }
86 FloatingType&
operator[] (
int index)
noexcept {
return coeffs.getReference (index); }
94 for (
int i = coeffs.size(); --i >= 0;)
95 y = (x * y) + coeffs.getUnchecked (i);
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);
void add(const ElementType &newElement)
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