Пример #1
0
Polynom Polynom::operator *(const Polynom &original)
{
	Polynom w(0.0,degree() + original.degree());
	int i,j;
	for(i=0;i<nn;i++)
		for(j=0;j<original.nn;j++)
			w[i+j]+=v[i]*original[j];
	return w;
}
Пример #2
0
	Polynom add(const Polynom& rhs) const {
		Polynom res(std::max(rhs.degree(), degree()));
		std::copy(this->begin(), this->end(), res.begin());
		for (size_t i = 0; i < rhs.size(); ++i) {
			res[i] += rhs[i];
		}
		res.normalize();
		return res;
	}
Пример #3
0
	Polynom multiply(const Polynom& rhs) const {
		Polynom res(rhs.degree() + degree());
		for (size_t i = 0; i < this->size(); ++i) {
			for (size_t j = 0; j < rhs.size(); ++j) {
				res[i + j] += this->data()[i] * rhs[j];
			}
		}
		res.normalize();
		return res;
	}