I recommend using PDL::NiceSlice in general but the
problem appears to be that you are trying to index a
slice using the string '$x' rather than the number you
want, i.e., "$x" which ends up as 1.
pdl> p $eigen_vec = floor(random(5,5)*10);
>
> [
> [9 9 3 6 5]
> [9 3 3 2 1]
> [7 3 5 8 8]
> [7 3 0 3 0]
> [7 1 3 2 9]
> ]
>
>
> pdl> $x = 0 ; $y = 3 ; $z = 4 ; # PDL uses zero-based indices
>
> pdl> p ':,$x'
> :,$x
>
> pdl> p ":,$x"
> :,0
>
> pdl> p $eigen_vec->slice(":,$x") # original slice(string) syntax
>
> [
> [9 9 3 6 5]
> ]
>
>
> pdl> p $eigen_vec(:,$x) # the nice NiceSlice syntax
>
> [
> [9 9 3 6 5]
> ]
>
>
>
>
On Wed, Jan 18, 2012 at 10:42 AM, ANJAN PURKAYASTHA <
[email protected]> wrote:
> Hello,
> I'm having problems with a rather simple problem.
> I have a set of eigenvectors in matrix form. I would like to extract 3 of
> these eigenvectors ( that correspond to the 3 largest eigenvalues). The
> eigenvectors are stored in rows 1, 4, and 5. I assign these row numbers
to
> three scalars: $x, $y, $z and enter the command:
> $ev_x= $eigen_vec->slice(':,$x');
> .....
>
> I get an error: Invalid slice str ':,$x': '$x' at XXXX.pl line 118, <F>
line
> 149.
>
> What is the correct command for extracting a row (or cloumn) from a PDL?
> Thanks
> Anjan
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl