[GiNaC-devel] expairseq::conjugate

Richard B. Kreckel kreckel at ginac.de
Wed May 11 00:13:18 CEST 2011


Hi Burcin,

On 05/08/2011 09:42 PM, Burcin Erocal wrote:
> the following problem (in Sage syntax) was reported to the Sage issue
> tracker [1]:
>
> ginsh - GiNaC Interactive Shell (ginac V1.5.8)
> <snip>
>> conjugate(I*sqrt(-3));
> -I*sqrt(-3)

Indeed. The patch I committed a year ago to make the branch cut 
tranformations less aggressive forgets about complex conjugation of mul 
objects containing roots.

Of course, the imaginary I in the example above is not relevant. Here is 
another way (and a good regression test, BTW) to see it fail. In ginsh:

 > subs(conjugate(a*sqrt(-2))-a*conjugate(sqrt(-2)), a==1);
-conjugate(sqrt(-2))+sqrt(-2)

> [1] http://trac.sagemath.org/sage_trac/ticket/10964
>
> The problem seems to be the expair::conjugate() method which is called
> from the conjugateepvector() function in expairseq.cpp. This function
> is called from the pseries class as well. So, moving the latter in the
> expairseq class to use the virtual functions recombine_pair_to_ex()
> etc. does not work.
>
> Any ideas for a clean solution to this?

Ah, I see that you already got very close to fixing it. Well, what 
remains to be done is to ensure that the code dispatches to the right 
recombine_pair_to_ex()/split_ex_to_pair() methods. For this, it needs 
the vptr of the expairseq object. It doesn't have to be a member 
function, though: We can pass it as an extra argument to 
conjugateepvector(), in order to retain binary compatibility.

I'ld propose to fix it similar to the patch attached. It passes GiNaC's 
regression tests and works as expected:

 > subs(conjugate(a*sqrt(-2))-a*conjugate(sqrt(-2)), a==1);
0

What do you think?

I'll clean it up a bit and push it to the GiNaC repository later, when 
I'm less sleepy.

(:|
   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ginac.patch
Type: text/x-patch
Size: 2015 bytes
Desc: not available
URL: <http://www.cebix.net/pipermail/ginac-devel/attachments/20110511/1464f16c/attachment.patch>


More information about the GiNaC-devel mailing list