[GiNaC-devel] G_do_trafo: bug fix for sort operation

Stefan Weinzierl stefanw at thep.physik.uni-mainz.de
Fri Oct 10 23:45:06 CEST 2014


Hello,

Tobias Huber reported the following bug:
> G({-0.18784426860496276*I,-0.1579006477353911*I,+0.18784426860496276*I,-0.18784426860496276*I},1);
log_eval(): log(0)

The problem is the sorting operation in G_do_trafo.
This operation should
1) put the elements in increasing order of |x|
2) put equal elements next to each other (which then will avoid the 
log(0) problem).

The current code fails for goal 2) if we have complex numbers of equal 
absolute value, one number occuring more than once, in an initial order 
like in the example above:
Entries 1,3,4 of the list all have the same absolute value, entries 1 and 
4 are equal.
In the sorting operation 1 and 4 should be put next to each other.
Previously, the sorting operation would give 2,1,3,4. What we would like 
to have is either 2,1,4,3 or 2,3,1,4. 
It is clear, that the key for the sorting operation cannot be |x| alone.
In the case of |x1|=|x2| we have to use the phase information as well.

The patch implements this.

  Best wishes,

    Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polylog7.patch
Type: text/x-diff
Size: 1638 bytes
Desc: 
URL: <http://www.cebix.net/pipermail/ginac-devel/attachments/20141010/ac9eb1ba/attachment.bin>


More information about the GiNaC-devel mailing list