If you can install octave, then you could try using
Inline::Octave (which I've never tried),
or just call octave directly.
Octave is a free matrix manipulation program similar to
matlab, and it has some lapack functions.
Here's a quick example script
that calculates the determinant
of a 2x2 matrix with octave.
#!perl
use warnings;
use strict;
my $OCTAVE = "octave";
use File::Temp "tempfile";
my($datafile, $dataname) = tempfile;
my($cmdfile, $cmdname) = tempfile;
my @matrix = (
[3.5, 1.2],
[-0.9, 4.5],
);
my $mrows = @matrix;
my $mcols = @{$matrix[0]};
print $datafile pack("d*", map { @$_ } @matrix) or
die "error writing data: $!";
close $datafile or
die "error closing data: $!";
print $cmdfile qq{
dataname = "$dataname"; % we trust tempfile not to return wier
+d characters in filename
mcols = $mcols;
mrows = $mrows;
} . q{
page_screen_output = 0;
[datafile, msg] = fopen(dataname, "r");
if (datafile < 0) error ("error opening datafile: %s", msg); e
+ndif;
d = fread(datafile, mrows * mcols, "double"); % you should che
+ck for errors here
fclose(datafile);
matrix = reshape(d, mcols, mrows).';
result = det(matrix);
fwrite(stdout, result, "double"); % check for errors here too
};
close $cmdfile or
die "error closing data: $!";
open my $octave, "-|", $OCTAVE, "-q", $cmdname or
die "cannot launch octave: $!";
my $result = unpack("d*", do { local undef $/; <$octave>; });
close $octave or
die "could not close octave: $!";
$? and
die "octave died";
print $result, "\n";
__END__