|XP is just a number|
Can't figure out simple transformation with PDLby wanna_code_perl (Pilgrim)
|on Mar 18, 2013 at 01:42 UTC||Need Help??|
wanna_code_perl has asked for the
wisdom of the Perl Monks concerning the following question:
I'm new to PDL, giving it a whirl to speed up some 2D matrix crunching at the heart of an algorithm that has been rigorously proven to be the most efficient
I'm having the most trouble fully wrapping my head around threading, specifically how to fetch adjacent cells in a 2D matrix which match an arbitrary boolean expression.
Below follow some (annotated) pdl> commands hopefully showing what I'm trying to accomplish.
What I need:
The above code gets me halfway to where I need to be; from the $pos + $xfrm line, I need to basically grep those elements which are a) valid (i.e., within the piddle dimensions), and b) match a given boolean expression. Hence I tried this (obviously broken) code:
I'm thinking this sort of thing must be a very common pattern, but I can't seem to find a workable example anywhere. What's the most concise and efficient way to iterate over adjacent cells matching a given boolean expression?