You could also use "eval" which evaluates your equations at run time.
You can the feed your equations as strings and have them evaluated
by your program. eval is usually not very fast, but should probably
fit your needs.

  Something like this should work:

#!/usr/bin/env perl

use PDL;

$a=1;
$b=2;
$c=3;

@equations=qw(
    $a+$b==6
    $a+$c==6
    $b+$c==6
    $a+$b+$c==6
    $c+$b
    $a+$c
);

foreach $eq (@equations) {
    $result=eval($eq)+0;  # Adding 0 to convert it to a number

    print "Result of equation $eq is $result\n";
}


Note that the equations are fed into the program as strings. In your
case you could
read them from a file.

  And yes, you do not need PDL for this, plain perl should do, unless you use
PDL in your equations.

  Cheers

  Xavier



On Wed, Dec 10, 2008 at 12:28 AM, Alan Barclay <[EMAIL PROTECTED]> 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.
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to