本文整理汇总了C++中Polynomial::coeff方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::coeff方法的具体用法?C++ Polynomial::coeff怎么用?C++ Polynomial::coeff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::coeff方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void Polynomial<int>::pseudo_div(
const Polynomial<int>& f, const Polynomial<int>& g,
Polynomial<int>& q, Polynomial<int>& r, int& D)
{
CGAL_NEF_TRACEN("pseudo_div "<<f<<" , "<< g);
int fd=f.degree(), gd=g.degree();
if ( fd<gd )
{ q = Polynomial<int>(0); r = f; D = 1;
CGAL_postcondition(Polynomial<int>(D)*f==q*g+r); return;
}
// now we know fd >= gd and f>=g
int qd=fd-gd, delta=qd+1, rd=fd;
{ q = Polynomial<int>( std::size_t(delta) ); }; // workaround for SUNPRO
int G = g[gd]; // highest order coeff of g
D = G; while (--delta) D*=G; // D = G^delta
Polynomial<int> res = Polynomial<int>(D)*f;
CGAL_NEF_TRACEN(" pseudo_div start "<<res<<" "<<qd<<" "<<q.degree());
while (qd >= 0) {
int F = res[rd]; // highest order coeff of res
int t = F/G; // ensured to be integer by multiplication of D
q.coeff(qd) = t; // store q coeff
res.minus_offsetmult(g,t,qd);
if (res.is_zero()) break;
rd = res.degree();
qd = rd - gd;
}
r = res;
CGAL_postcondition(Polynomial<int>(D)*f==q*g+r);
CGAL_NEF_TRACEN(" returning "<<q<<", "<<r<<", "<< D);
}