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 = random(10)->transpose > 0.5 [ [0] [0] [1] [0] [1] [1] [1] [0] [1] [0] ] and lets say that this is the origin matrix I want to dice: 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 46 47 48 49] ] I would like to have a result that has only the rows where the mask is marked with a 1, like this: $result = filter_somehow_from($target by $mask); [ [30 31 32 33 34] [35 36 37 38 39] [40 41 42 43 44] [45 46 47 48 49] ] so I can modify the result in-place, like square it: $result **= 2; [ 900 961 1024 1089 1156] [1225 1296 1369 1444 1521] [1600 1681 1764 1849 1936] [2025 2116 2209 2304 2401] so the `**= 2` will modify to the original matrix: [ [ 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] [ 900 961 1024 1089 1156] [1225 1296 1369 1444 1521] [1600 1681 1764 1849 1936] [2025 2116 2209 2304 2401] ] I know I could do something with ->slice to modify in-place, but ':,6:9' is not $mask: pdl> p $target->slice(':,6:9') **= 2 [ [ 900 961 1024 1089 1156] [1225 1296 1369 1444 1521] [1600 1681 1764 1849 1936] [2025 2116 2209 2304 2401] ] pdl> p $target [ [ 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] [ 900 961 1024 1089 1156] [1225 1296 1369 1444 1521] [1600 1681 1764 1849 1936] [2025 2116 2209 2304 2401] ] So $mask defines the rows I need to modify, and $mask could have 1's in any location, and those are the locations I need to twiddle. Ideas? Thanks for your help! -- Eric Wheeler _______________________________________________ pdl-general mailing list pdl-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-general