collect() eats fractions
Pearu Peterson
pearu at cens.ioc.ee
Sat Apr 14 13:15:03 CEST 2001
Sorry to bother you again but my previous fix didn't work.
Below is given a working version. Any ideas how to optimize it?
Btw, I have noticed that you use frequently
for (int n=this->ldegree(s); n<=this->degree(s); n++)
instead of more efficient
for (int n=this->ldegree(s), m=this->degree(s); n<=m; ++n)
that saves repeated calling of the degree() method.
On Fri, 13 Apr 2001, Pearu Peterson wrote:
> As a fix, the collect function should be
ex basic::collect(const ex & s) const
{
ex x;
for (int n=this->ldegree(s); n<=this->degree(s); n++)
x += this->coeff(s,n)*power(s,n);
x += (*this - x).expand();
return x;
}
Regards,
Pearu
More information about the GiNaC-devel
mailing list