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