Re: [Pdl-general] How do you dice based on a boolean matrix?

2023-08-09 Thread Eric Wheeler
Hi Bryan and Luis, thanks for your quick response! Both suggestions look great and I learned a few things about PDL like which, whereND, and dice_axis that I hadn't before. Cheers, -- Eric Wheeler On Wed, 9 Aug 2023, Luis Mochan wrote: > > You could use whereND, as: > pdl> p

Re: [Pdl-general] How do you dice based on a boolean matrix?

2023-08-09 Thread Luis Mochan
You could use whereND, as: pdl> p $target=sequence(5,10) [ [ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14] [15 16 17 18 19] [20 21 22 23 24] [25 26 27 28 29] [30 31 32 33 34] [35 36 37 38 39] [40 41 42 43 44] [45

Re: [Pdl-general] How do you dice based on a boolean matrix?

2023-08-09 Thread Bryan Jurish
moin Eric, moin list, There may be a more elegant way to do this, but I'd use which($mask) to feed dice_axis() of $target. Using your $mask example above: pdl2> $mask = pdl([0,0,1,0,1,1,1,0,1,0])->slice("*1,") pdl2> p $selected = $target->dice_axis(1, $mask->flat->which) [ [10 11 12 13 14] [20

[Pdl-general] How do you dice based on a boolean matrix?

2023-08-09 Thread Eric Wheeler
Hello all! I would like to get a diced/sliced/indexed piddle that is derived from a larger matrix based on rows indicated by a mask. For example, lets say I have a mask and I want to dice a matrix's rows where the mask has a value of 1 (in any location): pdl> p $mask =