I'm using Perldl 2.4.3 under cygwin.

perldl> $z = zeroes(3,3)

perldl> $cz = &PDL::Complex::r2C($z);

perldl> print $cz

[
 [0+0i  0+0i  0+0i]
 [0+0i  0+0i  0+0i]
 [0+0i  0+0i  0+0i]
]

Fair enough, a 3 by 3 array of complex. Well, maybe.
perldl> print ref($cz)
PDL::Complex

So it knows it holds complex numbers.

perldl> print $cz->at(1,1)
Invalid position at /usr/lib/perl5/site_perl/5.10/i686-cygwin/PDL
/Core.pm line 2377.

So what does it think the dimensions are?

perldl> print $cz->dims()
2 3 3
perldl>

Now, complex numbers are supposed to interact correctly with "normal"
reals, but I can't access elements of arrays of Complex and arrays
of reals in the same way in the code, so I need two paths through my 
code.

Is there something like this (rough sketch) already?:

  package PDL::Complex;

  sub at {
    my $self = shift;
    my $x = shift;
    my $y = shift;

    return &PDL::at($self,0,$x,$y) + &PDL::at($self,1,$x,$y) * i;
  }

Is there a reason I would not want to add that to my code, if not?
Alternatively, why is my expectation on this wrong?  What should I
be looking for, to pluck a complex value from a 2D array of numbers,
in a complx/real agnostic way?

        Thank you,
        Hugh

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to