I don't know much about PDL, but your problem doesn't seem that difficult. You have a file with 4 rows and 5 columns, and you want to compute the determinant of 4x4 matrices obtained by picking, and possibly reordering, 4 out of the 5 columns. Though it's not rocket science to move around columns, it is simpler to move around rows, and since the determinant is not affected by taking the transpose, I'd work with the transpose. I.e. I'd compute the determinants of

pdl [ [4, 2, 6, 8], [2, 5, 3, 4], [9, 5, 5, 6], [7, 4, 3, 6], ], pdl [ [21, 11.5, 15.5, 22], [2, 5, 3, 4], [9, 5, 5, 6], [7, 4, 3, 6], ],
etc. So this is what I'd do (untested):
my @rows; my $j = 0; { local @ARGV = $ARGV[ 0 ]; while ( <> ) { my $i = 0; $rows[ $i++ ][ $j ] = $_ for split; $j++; } } my $dmat = pdl [ @rows[ 0, 1, 2, 3 ] ]; my $damat = pdl [ @rows[ 4, 1, 2, 3 ] ]; my $dbmat = pdl [ @rows[ 0, 4, 2, 3 ] ]; my $dcmat = pdl [ @rows[ 0, 1, 4, 3 ] ]; my $ddmat = pdl [ @rows[ 0, 1, 3, 4 ] ]; # proceed to compute the determinants of the $dmat, $damat, etc.

the lowliest monk


In reply to Re: creating matrices for PDL module by tlm
in thread creating matrices for PDL module by Angharad

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.