本文整理汇总了C++中Polynomial::get_degree方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::get_degree方法的具体用法?C++ Polynomial::get_degree怎么用?C++ Polynomial::get_degree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::get_degree方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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>());
}
示例2: while
void Polynomial::operator/=(const Polynomial& p)
{
Polynomial Q = *this;
while(Q.get_degree()>=p.get_degree())
{
Q-=p*p(p.get_degree())*Q(Q.get_degree());
Q.remove_zeros();
}
*this = Q;
}
示例3:
Polynomial Polynomial::operator =(const Polynomial &p) {
if (this != &p) {
degree = p.get_degree();
delete[] coefficients;
coefficients = new ComplexNumber[degree + 1];
for (int i = 0; i < p.get_degree() + 1; i++) {
coefficients[i] = p.get_coefficients()[i];
}
}
return *this;
}
示例4: result
// Overloaded operator +
Polynomial operator+(const Polynomial &polya, const int b)
{
Polynomial result(polya.get_degree());
for (int i = 0; i < polya.get_degree() + 1; i++) {
if (i == 0) {
result.set_coeff(i, polya.get_coeff(i) + b);
} else {
result.set_coeff(i, polya.get_coeff(i));
}
}
return result;
}
示例5:
Polynomial::Polynomial(const Polynomial &poly)
{
// cout << "copy constructor\n";
degree = poly.get_degree();
coeff = new double[degree+1];
for (int i = 0; i <= degree; i++)
{
coeff[i] = poly.get_coeff(i);
}
}
示例6: equal
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());
}
}