[GiNaC-list] Possible bug in csrc output format.

Richard B. Kreckel kreckel at ginac.de
Wed Sep 12 16:57:58 CEST 2012


Hi!

On 09/04/2012 05:58 PM, Javier Ros wrote:
> I've been exporting C code from GiNaC using "csrc_double" output format
> during a long time.
>
> Now we are dealing with rather long real expressions, that involve only
> +-*\ and pow. In a benchmark
> and for comparison purposes we've end up comparing
> the results of evaluate the same function through "dflt" (used to
> generate output for MATLAB) and csrc_double
> (used to generate same code for C).
>
> Numerical discrepancies where found and traced back to to small symbolic
> differences in the output obtained through both formats.
>
> To avoid the problem and due to the symbolical simplicity of our
> expressions (only +-*\ and pow) we've developed  our own -very simple-
> exporting format for C.
> Basically we derive our format from "dflt" and change the way in which
> natural numbers and powers are written (we append a .0 to natural numbers)
> and we change a^b with pow(a,b).
>
> Right now we are obtaining a correct behaviour the export based on our
> new format, coherent with "dflt" numerical results (in a particular
> case), and obtaining different
>   results with csrc_double (I think too with csrc alone).
>
> So I think I'm facing a bug in csrc output format.
>
> I wonder if anybody wants me to report further on this (I don't feel
> confident as to dig into GiNaC's implementation of crsc).
> If so please let me know the way in which I can report back the error
> (or what I think is an error) with the required detail.

You don't have to dig into GiNaC's implementation in order to find the 
reason why your compiler produces different numerical results. Most 
likely, the different results are due to cancellations in an 
ill-conditioned expression. On the other hand, if you can prove that 
GiNaC does produce wrong code, please be so kind and show us the 
expression where it occurs.

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


More information about the GiNaC-list mailing list