[GiNaC-devel] factorization and stuff

Richard B. Kreckel kreckel at ginac.de
Thu Aug 21 08:24:44 CEST 2008


Good morning Jens,

Jens Vollinga wrote:
> Richard B. Kreckel schrieb:
>> I hope I'm not being too pesky, but that square-free factorization keeps 
>>   attracting my mind. And now I am getting:
> 
> what is behind this curiosity? New feature in cln maybe? :-)

No, there's no code in the pipeline.

>>  > factor(expand((1-x+x^2-x^3)*x^2));
>> Internal error: statement in file ./float/division/cl_F_ceil1.cc, line 
>> 21 has been reached!!
>> Please send the authors of the program a description how you produced 
>> this error!
> 
> It is no problem of the sqrfree function. Actually, you can help me with 
>   this bug. The problematic line is
> 
> cl_I normmc = 
> ceiling1(the<cl_F>(cln::sqrt(ex_to<numeric>(maxcoeff).to_cl_N())));
> 
> maxcoeff is 4 in this case.
> 
> The line
> 
> cl_I normmc = 
> ceiling1(the<cl_I>(cln::sqrt(ex_to<numeric>(maxcoeff).to_cl_N())));
> 
> does work in this case (cl_F -> cl_I in the cast).
> 
> Why?!? It is just too late to read the manual ...

Each of the classes `cl_R', `cl_F', `cl_SF', `cl_FF', `cl_DF', `cl_LF'
defines `TYPE sqrt (const TYPE& x)'. `x' must be >= 0. This function 
returns the square root of `x', normalized to be >= 0. If `x' is the 
square of a rational number, `sqrt(x)' will be a rational number, else 
it will return a floating-point approximation.

So, cln::sqrt(cln::cl_N(4)) returns cl_N(2), an exact integer, but of 
static type cl_N. Casting that to cl_F, a float triggers the error. (You 
can't use the for constructing floating-point numbers, you should use 
the contructors.) But in your case, converting the<cl_R>(...) will 
convert to static type cl_R, which can at runtime be either integer or 
rational or floating-point, but not complex.

Indeed, it seems to fix things.

>> Sorry for being such a killjoy.
> 
> Well, I have to seriously warn you: any more bugs and the multivariate 
> factorization will be delayed even more! ;-)

I'm looking forward to testing the multivariate case, too!  :-)

nice day
   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: factor.patch
Type: text/x-patch
Size: 654 bytes
Desc: not available
Url : http://www.cebix.net/pipermail/ginac-devel/attachments/20080821/64dcf77c/attachment.patch 


More information about the GiNaC-devel mailing list