My personal NiceSlice favorite, the Smiley syntax: $B = $A(0, 0, : ;-)
This introduces less visual cruft compared with the nested parentheses notation. The difference between the Smiley notation and Matthew's is that ';-' means "drop dimensions of size 1" whereas ';_' means "flatten." For example, this will give you a 1d array $c = $A(1:5, 0, : ;_) and this will give you a 2d array: $d = $A(1:5, 0, : ;-) Clear as mud, right? ;-) David On Nov 9, 2011 5:15 PM, "Matthew Kenworthy" <[email protected]> wrote: > 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"; >> >> > You can also > > use PDL::NiceSlice; > $a = zeroes(5,5,5); > > $b = $a(0:0,0:0,0:-1); > > .... or simpler: > > $b = $a(0,0,); > > ...and to get rid of the brackets, what you need is 'flat' > > pdl> p $a(0,0,)->flat > > > ...and you can also do this with a concise NiceSlice syntax by adding ;_ > > p $a(0,0,;_) > > Hope this helps, > > Matt > > > -- > Matthew Kenworthy / Assistant Professor / Leiden Observatory > Niels Bohrweg 2 (#463) / P.O. Box 9513 / 2300 RA Leiden / NL > > > _______________________________________________ > 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
