void Polynomial::operator-=(const Polynomial& p) { unsigned dp = p.get_degree(); unsigned dthis = get_degree(); auto p_coeffs = p.get_coeffs(); if(dthis<dp) coefficients.resize(p.get_degree()+1, 0.0f); std::transform(coefficients.cbegin(), coefficients.cbegin()+dp+1, p_coeffs.cbegin(), coefficients.begin(), std::minus<float>()); }
bool Polynomial::operator==(const Polynomial& p) const { if(this->get_degree()!=p.get_degree()) return false; else { const std::vector<float>& coeffs1 = this->get_coeffs(); const std::vector<float>& coeffs2 = p.get_coeffs(); return std::equal(coeffs1.begin(), coeffs1.end(), coeffs2.begin()); } }