|Welcome to the Monastery|
Hash-type lookup in PDLby andye (Curate)
|on Jan 05, 2007 at 13:26 UTC||Need Help??|
andye has asked for the
wisdom of the Perl Monks concerning the following question:
I'm using PDL (the Perl Data Language, pdl.perl.org) to manipulate a Very Large dataset.
I'm having quite a bit of trouble with the correct syntax for threading, can't seem to get it right.
Right now I'm doing a lookup, where an old value gets turned into a new value. There's a one-to-one relationship between old values and new values. Currently I'm doing this using a normal hash, like this:
I'd like to do this using PDL threading if I can, because I want it to go quicker (there are a lot of values), but I can't find the right way to do it.
but sadly that doesn't work. I've tried using $pdl_oldvals->thread(0) and $pdl_oldvals->dummy(0) but they don't work either.
I've also tried turning the hash into a two-row pdl, with keys on one row and values on the other row, then taking a slice from that pdl to get the values. That should certainly work with pdl threading... but I can't get it to. :(
Suggestions, and examples of correct syntax for doing this kind of thing in pdl, very much appreciated.
All the best, andye.
PS where "doesn't work" = either a syntax error, or runs but produces the wrong values...