Welcome to the list!
You can specify individual elements in a slice by omitting the colon. You can
also get the whole dimension with just a colon. Like this:
$B = slice $A, "0,0,:"; # 1 x 1 x N
If you are selecting an individual element that way, you can delete its
corresponding dimension by surrounding the selector with parentheses:
$C = slice $A, "(0),(0),:";
You might notice that the last slice (the whole dimension) is a no-op. If it's
on the end, you can just omit it. Then the threading engine
will give you a (scalar) slice of the first two dimensions of A, and
automatically iterate over any remaining dimensions (the last one).
$D = slice $A, "(0),(0)";
You probably also want to start using the NiceSlice formatting. Depending on
whether you're using a script or the interactive shell, you might have to say
"use PDL::NiceSlice;" somewhere up near the top of your script, but once you
have you can instead say:
$E = $A((0),(0));
All those expressions give you the same result.
On Nov 9, 2011, at 3:47 PM, Denis Gonzalez wrote:
> Hi everyone,
>
> I am beginner in PDL and I have troubles for extracting a 1D list from a big
> 3D matrix.
> For example, the matrix $A is a 3D pdl
>
> $A = zeroes($i,$j,$k);
>
> which is filled with different values from a file. So, now I need to obtain a
> list with all the $k values for a given couple $i,$j. For doing that, for
> example with $i=0, $j=0, I use the slice function
>
> $B = slice $A, "0:0,0:0,0:-1";
>
> print $B
> [
> [
> [6.3039387e-05]
> ]
> ....
> [
> [8.8720632e-05]
> ]
> ....
> [
> [0.00010826399]
> ]
> ]
>
> but I need to obtain something like
>
> $A = [
> 6.3039387e-05
> ...
> 8.8720632e-05
> ...
> 0.00010826399
> ]
>
> Is there some pdl or perl "function" for doing that?
> thanks,
> Denis.
> _______________________________________________
> 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