friend polynomial derivative(polynomial const& p) { int s = p.size(); if(s == 0) return {}; polynomial res; res.coeffs.resize(s-1); for(int n = 0; n < s-1; ++n) res.coeffs(n) = p.coeffs(n+1) * CoeffType(n+1); return res; }
friend polynomial antiderivative(polynomial const& p) { int s = p.size(); if(s == 0) return {}; polynomial res; res.coeffs.resize(s+1); res.coeffs(0) = CoeffType{}; for(int n = 1; n < s+1; ++n) res.coeffs(n) = p.coeffs(n-1) / CoeffType(n); return res; }