Further to this, an obvious approach for e.g. “conj” is to add “PMCode” that 
simply does “return $self if $self->type->real;” first, with the obvious 
“topdl” bit first to setup $self.

From: Ed .<mailto:ej...@hotmail.com>
Sent: 27 September 2021 15:23
To: Luis Mochan<mailto:moc...@icf.unam.mx>; 
perldl<mailto:pdl-gene...@lists.sourceforge.net>; 
perldl<mailto:pdl-devel@lists.sourceforge.net>
Subject: Re: [Pdl-devel] native complex and PDL::LinearAlgebra

That’s not very surprising, unfortunately.

Probably the correct approach is to make everything be correct for native 
complex, which should also do the right thing for real types (e.g. obviously 
the complex conjugate of a real number is itself). If you can PR on PDL::LA 
with failing tests and maybe also fixes, that would be incredibly helpful!

I wouldn’t be surprised if this also reveals gaps in the native complex stuff; 
e.g. currently “conj” only takes complex types, so would silently upgrade real 
to complex. That probably wants fixing to take, and do the right thing with, 
real types too. PR-ing of tests on main PDL would also be very helpful!

Best regards,
Ed

From: Luis Mochan<mailto:moc...@icf.unam.mx>
Sent: 27 September 2021 01:41
To: perldl<mailto:pdl-gene...@lists.sourceforge.net>; 
perldl<mailto:pdl-devel@lists.sourceforge.net>
Subject: Re: [Pdl-devel] native complex and PDL::LinearAlgebra

Thanks!

I started looking around PDL::LinearAlgebra, and, as I suspected, many
of the routines should be modified to accomodate the native
complex'es.  For example, consider a 1x1 complex square matrix:

pdl> use PDL::LinearAlgebra
pdl> $a=pdl([[i()]])
pdl> p $a
[
 [i]
]
pdl> p $a->t
[
 [i]
]
pdl> p $a->issym
1

pdl> use PDL::Complex
Subroutine sumover redefined...
pdl> $b=pdl([[1]])*i()
pdl> p $b
[
 [i]
]
pdl> p $b->t
[
 [-i]
]
pdl> p $b->issym
0
pdl>



Thus, the 't' method transposes the matrix if it uses native complex
numbers, but transposes it *and* conjugates it (by default) if it uses
PDL::Complex numbers. Similarly, the issym function tests for symmetry
when acting on PDL's (even native complex ones), but test for Hermiticity
when acting on PDL::Complex's. The same happens for most other
routines that act differently on complex than on real numbers, but treat
PDL's as real and only PDL::Complex's as complex.

Regards,
Luis



On Sat, Sep 25, 2021 at 06:51:48PM +0000, Ed . wrote:
> Thank you. Now merged your change (thanks for adding tests too) and released 
> 0.23.
>
> From: Luis Mochan<mailto:moc...@icf.unam.mx>
> Sent: 25 September 2021 18:49
> To: perldl<mailto:pdl-gene...@lists.sourceforge.net>; 
> perldl<mailto:pdl-devel@lists.sourceforge.net>
> Subject: Re: [Pdl-devel] native complex and PDL::LinearAlgebra
>
> On Sat, Sep 25, 2021 at 03:33:29PM +0000, Ed . wrote:
> > Hi Luis,
> >
> > I’ll take a look shortly (in the final stages of getting the multi-C to 
> > work). Can you confirm whether this worked according to your expectation in 
> > 2.057?
>
> This failed in 2.057.
>
> Best regards,
> Luis
>
>
> > From: Luis Mochan<mailto:moc...@icf.unam.mx>
> > Sent: 25 September 2021 15:49
> > To: perldl<mailto:pdl-gene...@lists.sourceforge.net>; 
> > perldl<mailto:pdl-devel@lists.sourceforge.net>
> > Subject: [Pdl-devel] native complex and PDL::LinearAlgebra
> >
> >
> > Hi,
> >
> > Congrats on the new release.
> >
> > I found an error in PDL::LinearAlgebra.
> >
> >     pdl> use PDL::LinearAlgebra
> >     pdl> $a=(1+sequence(2,2))*i()
> >     pdl> p $a
> >     [
> >      [ i 2i]
> >      [3i 4i]
> >     ]
> >     pdl> p $a->mdet
> >     0    # instead of 2
> >
>
>
> --
>
>                                                                   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