本文整理汇总了C++中Polynomial::remove_zeros方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::remove_zeros方法的具体用法?C++ Polynomial::remove_zeros怎么用?C++ Polynomial::remove_zeros使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::remove_zeros方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: quotient_coefficients
inline void Polynomial<T, Structure>::divide(const Polynomial<T, Structure>& divisor, Polynomial<T, Structure>& quotient, Polynomial<T, Structure>& remainder) const
{
if (deg() < divisor.deg()) {
remainder = *this;
quotient = zero();
return;
}
size_type divisor_deg = divisor.deg();
size_type new_deg = deg() - divisor_deg;
remainder = *this;
if (deg() < divisor_deg) {
quotient = one();
return;
}
coefficient_list quotient_coefficients (new_deg + 1);
const T divisor_first_digit = divisor.m_coefficients[divisor_deg];
for (size_type i = new_deg + 1; i > 0;) {
--i;
quotient_coefficients[i] = remainder.m_coefficients[i + divisor_deg] / divisor_first_digit;
Polynomial<T, Structure> factor (m_structure, quotient_coefficients[i], i);
Polynomial<T, Structure> back_calculated = factor * divisor;
remainder.subtract(back_calculated);
}
remainder.remove_zeros();
quotient = Polynomial<T, Structure>(m_structure, quotient_coefficients);
}
示例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;
}