Alan Barclay wrote: > I don't think this is going to be a PDL answer, but maybe I'm wrong, > and even if I'm not wrong, this list might have some ideas which can > point me in the right direction. > > I've been using PDL for quite a while, and it's been great to > manipulate large datasets with a few equations. Now I'd like to do the > opposite, I've got a relatively small dataset, and a large number of > equations that I'd like to use to manipulate against that dataset. For > example, (and this is not my real problem), lets say > > #!/usr/bin/perl > > my $a=1; > my $b=2; > my $c=3; > > print "1\n" if($a+$b==6); > print "2\n" if($a+$c==6); > print "3\n" if($b+$c == 6); > print "4\n" if($a+$b+$c == 6); > > In my real problem, I've got a few dozens of variables and tens of > thousands of equations to try out, while each one takes quite a short > amount of time, the overall program takes too long. > > Any ideas about what I can do to speed up equation processing like this. > Are your real equations simple like this, or complex? Are they additions and subtractions of these variables, or more complicated functions like multiplication? If it's the former, you could make a piddle [[1 0 0 -6] [1 0 1 -6] [0 1 1 -6] [1 1 1 -6]] and use appropriate multiplications by your variables and sumovers to generate your result. You've probably already thought of that, though.
If they are more complicated, you might need to be more specific about what you are trying to minimize: compiling time or running time? Are you running this program more than once? If they're more complicated equations, my first thought was to write it in C and start passing around function pointers instead. Maybe Inline::Pdlpp or Inline::C could help you with that, maybe not--maybe you don't even want to use Perl for this. Presumably you have abstracted your equations in some way so that they aren't hard-coded. Maybe you could use Perl (or C or whatever) to read in this abstraction and write a bunch of C subroutines. Compilation will be a bear, but execution should be faster. I guess that's what the Inline modules do, too. If you only need to run the program once, then maybe the C interface isn't the way to go, and you just need to slog through the hard way. Probably others have some better ideas, and some ideas about what would be faster, but this is a start anyway. cheers, Derek _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
