Hi Luis,

Thanks for the great problem-finding and -tracking!

The difference between “pow” and “power” is that the latter is more 
sophisticated, and PDL-ish, and allows for mutations (such as with overloaded 
operators). The former is just the PDL-ised version of the “-lm” function. For 
sure, we’re stuck with keeping both now, for back-compat reasons.

I think that conceptually the idea of data-flow for complex types is very 
interesting, but has a fundamental problem for the C99-native types – in C 
terms, they are a single value, and so cannot be distinguished between the real 
and imaginary parts (I can imagine that it may be possible to try some pointer 
cleverness and casting to get at one or the other part but I cannot imagine it 
being portable, or a good idea). This is one use-case for the 
one-extra-dimensional PDL::Complex, probably. However, it is probably possible 
to do something like threading but with an additional “creal”/”cimag” to be 
done on data-access, so feel free to have a go and PR it!

The problem you identified is due to a logic error in the bifuncs in P::Ops – 
they weren’t handling complex inputs correctly because the code to do so was 
behind a check for unsigned-handling. Now that’s corrected, and there’s a test 
to guard against regressions. As soon as the tests have passed on the CI, there 
will be a 2.028 on its way to CPAN.

Best regards,
Ed

From: Luis Mochan<mailto:moc...@icf.unam.mx>
Sent: 06 March 2021 23:53
To: pdl-devel@lists.sourceforge.net<mailto:pdl-devel@lists.sourceforge.net>; 
perldl<mailto:pdl-gene...@lists.sourceforge.net>
Subject: Re: [Pdl-devel] PDL 2.027 released

Well, so far, I have found that ** invokes the function PDL::power
which seems not to work with the new complex types. I don't know the
reason for having both a 'pow' and a 'power' function.


On the other hand, would it be feasible to enable data flow back to
the real and imaginary parts of a new complex? (I understand it may go
against their philosophy)
pdl> $a=1+2*ci #make a new complex
pdl> p $a
1+2i
pdl> $b=$a->cimag
pdl> p $b
2
pdl> $b.=3 # modifying $b
pdl> p $a # doesn't modify the imaginary part of $a
1+2i

Best regards,
Luis



On Sat, Mar 06, 2021 at 05:12:40PM -0600, Luis Mochan wrote:
> And pow also works. So it seems the problem is related to the
> translation from the binary operator version '**'.
>
> pdl> p +(1+ci)->ipow(2)
> 0+2i
> pdl> p +(1+ci)->pow(2)
> 1.2246467991473532e-16+2i
> pdl> p +(1+ci)**2
> 1+0i
> pdl>
>
>
> On Sat, Mar 06, 2021 at 05:03:49PM -0600, Luis Mochan wrote:
> > > So powers of complex numbers are not working. I haven't looked yet at
> > > the P::Ops code. I'll try later.
> >
> > ipow does work though.
> >
> >
> > --
> >
> >                                                                   o
> > W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
> > Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
> > Av. Universidad s/n CP 62210         |                           (*)/\/  \
> > Cuernavaca, Morelos, México          | moc...@fis.unam.mx   /\_/\__/
> > GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB
> >
> >
> > _______________________________________________
> > pdl-devel mailing list
> > pdl-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/pdl-devel
>
> --
>
>                                                                   o
> W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
> Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
> Av. Universidad s/n CP 62210         |                           (*)/\/  \
> Cuernavaca, Morelos, México          | moc...@fis.unam.mx   /\_/\__/
> GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB
>
>
> _______________________________________________
> pdl-devel mailing list
> pdl-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pdl-devel

--

                                                                  o
W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
Av. Universidad s/n CP 62210         |                           (*)/\/  \
Cuernavaca, Morelos, México          | moc...@fis.unam.mx   /\_/\__/
GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB


_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

Reply via email to