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:
my @old_values = list($pdl_oldvalues); my @new_values = map $hash_lookup->{$_}, @old_values; my $pdl_newvalues = pdl(\@new_values);
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.
I've tried:
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.my $pdl_newvals = $hash_lookup->{$pdl_oldvals};
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...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash-type lookup in PDL
by zentara (Cardinal) on Jan 05, 2007 at 17:28 UTC | |
by andye (Curate) on Jan 05, 2007 at 18:18 UTC | |
by lin0 (Curate) on Jan 05, 2007 at 19:52 UTC | |
by andye (Curate) on Jan 06, 2007 at 18:17 UTC | |
|
Re: Hash-type lookup in PDL
by zentara (Cardinal) on Jan 05, 2007 at 22:03 UTC |