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__

In reply to Re: Lapack, inline and Perl by ambrus
in thread Lapack, inline and Perl by qhayaal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.