[GiNaC-devel] [PATCH] {add, power}::eval(): convert terms into primitive polynomials when possible.

Richard B. Kreckel kreckel at ginac.de
Thu Jul 12 23:23:02 CEST 2007


Hi Alexei!

Alexei Sheplyakov wrote:
> The following transformations are done automagically now:
> (-x+y)*(x-y) -> -(x-y)^2
> (3*x+y)/(6*x+2*y)^2 -> 1/4*(y+3*x)^(-1)
> 
> Please note: exam_series13() from check/exam_pseries.cpp fails due to
> this patch, because the expression 1/x*(-(1+x)/(1-x)) + (1+x)/x/(1-x)
> gets evaluated to zero.

This patch appears to come with a slight performance hit. On my machine, 
14x14 Vandermonde matrix determinants degrades from 19s to 32s, 
Lewis-Wester test O1 from 7.5s to 11s, and Lewis-Wester test A from 
0.055s to 0.22s. (I'm seriously surprised by the latter since it only 
involves integers, but it's reproducible.)

Looking at the code it appears to me like mul::eval recurses now. 
Wouldn't it be faster to collect the coefficients in one sweep? Well, I 
recognize that most terms will be trivial in the following recursions, 
but still.

Also, you write that "in some very unlucky event it can even loop 
forever". I don't quite understand. Do you have an example for this?

Best wishes
   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>


More information about the GiNaC-devel mailing list