Hi Ingo,

On Mon, Mar 08, 2021 at 03:35:36PM +0100, Ingo Schmid wrote:
> ...

> Now, looking into PDL::Ops you will see this warning:
>
>  Returns the complex number 0 + 1i.
>
> B<WARNING> because this is not defined as a constant (with empty
>  prototype), you must use it either as C<10*ci> or C<ci()*10>. If you
>  use it as C<ci*10> this will actually try to use 10 as a glob and pass
>  that to C<ci>, which will not do what you want.

Yes, I saw the warning. Nevertheless, having $x+ci!=$ci+$x would
surprise many. For this reason, I guess it would be a good idea in the
meantime, before the merge with PDL::Complex mentioned by Ed, to give
an explicit error or warning message whenever ci is called, most
probably inadvertently, with an actual non-null argument, or else, to promote
the use of a 'true' constant (maybe CI), similar to the 'i' of
PDL::Complex,  instead of the function ci.

Would
    use constant CI=>ci; # or sub CI () {state $i=ci; return $i;}
    my $z=$x+$y*CI; # ==$x+CI*$y
be more expensive than
    my $z=$x+$y*ci; # !=$x+ci*$x
?
If not, then the current ci could be hidden from the users and CI above
exported (maybe with a better choice of names).

Best regards,
Luis



>
> Ingo
>
>
> On 08.03.21 15:12, Luis Mochan wrote:
> > Hi Ingo,
> > On Mon, Mar 08, 2021 at 09:49:06AM +0100, Ingo Schmid wrote:
> > > ...
> > > is it not doing  ci() + $x (expected behaviour) rather than ci( +$x) ?
> > No. For example:
> >      $ pdl2
> >      ...
> >      pdl> $x=1+0*ci # initialize a complex variable with a real value
> >      pdl> p $x
> >      1+0i
> >      pdl> p ci()+$x # this works as expected
> >      1+1i
> >      pdl> p ci+$x # this doesn't
> >
> >      pdl> p $x # and the value of $x has been changed
> >      0+1i
> >
> > Curiously,
> >      pdl> p ci-$x
> > doesn't print anything either, but it doesn't change $x (I guess -$x
> > is assigned to a temporary variable and that is what gets modified by
> > ci; in ci+$x a temporary variable is not necessary so $x itself gets
> > modified).
> >
> > Regards,
> > Luis
> >
> > --
> >
> >                                                                    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          | [email protected]   /\_/\__/
> > GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB
> >
> >
> > _______________________________________________
> > pdl-general mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/pdl-general


> _______________________________________________
> pdl-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pdl-general


--

                                                                  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          | [email protected]   /\_/\__/
GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB


_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to