You can install PDL-LinearAlgebra if you want to do linear algebra over complexes. Here is an example (note that if you load PDL::LinearALgebra the x operator (matrix multiplication in PDL) is overriden by the BLAS matrix multiplication and thus is complex aware. Here is a perldl session:
perldl> use PDL::Complex perldl> use PDL::LinearAlgebra perldl> $matrixM = cplx pdl [ [ 1+1*i, 2+1*i], [ 1-2*i, 2-1*i] ]; perldl> p $matrixM [ [1 +1i 2 +1i] [1 -2i 2 -1i] ] perldl> $matrixB_assigned_value = cplx pdl [ 5+8*i, 10-5*i ]; perldl> p $matrixB [ [ 5 +8i] [10 -5i] ] perldl> msolve($matrixM,$matrixB) [ [3+1i] [2+1i] ] [ [ 1 -2i 2 -1i] [-0.2 +0.6i 1.8 -0.4i] ] [2 2] 0 perldl> scalar msolve($matrixM,$matrixB) [ [3+1i] [2+1i] ] perldl> $matrixM->minv x $matrixB [ [3 +1i] [2 +1i] ]
In the last result we see from the amount of space between the real and imaginary part that the result is less precise.
----------------------------------------------------------- perldl> help minv minv Compute inverse of a general square matrix using LU factorization. Supports inplace and threading. Uses getrf and getri or cgetrf and cgetri from Lapack and return "inverse, info" in array context. PDL(inv) = minv(PDL) my $a = random(10,10); my $inv = minv($a); Docs from /usr/lib/perl5/PDL/LinearAlgebra.pm perldl> help msolve msolve Solve linear system of equations using LU decomposition. A * X = B Returns X in scalar context else X, LU, pivot vector and info. B is overwrited by X if its inplace flag is set. Supports threading. Uses gesv or cgesv from Lapack. (PDL(X), (PDL(LU), PDL(pivot), PDL(info))) = msolve(PDL(A), PDL(B) +) my $a = random(5,5); my $b = random(10,5); my $X = msolve($a, $b); Docs from /usr/lib/perl5/PDL/LinearAlgebra.pm

In reply to Re: PDL::Complex question by Anonymous Monk
in thread PDL::Complex question by gmacfadden

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.