[GiNaC-list] real_part and imag_part
Richard B. Kreckel
kreckel at in.terlu.de
Wed Aug 9 10:30:09 CEST 2017
On 08/09/2017 09:12 AM, Vladimir V. Kisil wrote:
>>>>>> On Tue, 8 Aug 2017 20:15:07 +0200, Jan Rheinländer <jrheinlaender at gmx.de> said:
>
> JR> Hi, what is the logic here (example from ginsh)?
>
> >> real_part(sqrt(-3));
> JR> sqrt(-3)
> >> imag_part(sqrt(-3));
> JR> 0
>
> >> real_part(sqrt(-1));
> JR> 0
> >> imag_part(sqrt(-1));
> JR> 1
>
> The problems seems to be in CLN library, since for the
> GiNaC::numeric object sqrt(-3), real_part() and imag_part() are simply
> calling cln::realpart() and cln::imagpart().
sqrt(-1) straightly evaluates to I, which works. But sqrt(-3) isn't a
numeric object. Rather, it is a power(-3,1/2).
Seems to me like the logic in power::real_part() and power::imag_part()
can be improved:
https://www.ginac.de/ginac.git/?p=ginac.git;a=blob;f=ginac/power.cpp;h=2619492805b58ad5d635f2d8fd67bfa0706c1281;hb=HEAD#l667
-richy.
--
Richard B. Kreckel
<https://in.terlu.de/~kreckel/>
More information about the GiNaC-list
mailing list