]> www.ginac.de Git - ginac.git/blobdiff - ginac/basic.cpp
* basic::collec() never worked correctly on non-polynomials till now.
[ginac.git] / ginac / basic.cpp
index 8040e4a0c12d9c104ce70521c5e3ed789c7aacd4..c649f64b0e6dfd6e74b2c41f11393d8249447b7d 100644 (file)
@@ -243,10 +243,11 @@ ex basic::coeff(const ex & s, int n) const
 ex basic::collect(const ex & s) const
 {
        ex x;
-       for (int n=this->ldegree(s); n<=this->degree(s); n++)
+       for (int n=this->ldegree(s); n<=this->degree(s); ++n)
                x += this->coeff(s,n)*power(s,n);
        
-       return x;
+       // correct for lost fractional arguments and return
+       return x + (*this - x).expand();
 }
 
 /** Perform automatic non-interruptive symbolic evaluation on expression. */