PDL::MatrixOps#
📦 stdpdl
Linear algebra on PDL’s ndarrays: determinants, inverses, LU, singular value and eigen decompositions, linear systems, triangular storage.
use PDL;
use PDL::MatrixOps;
my $m = pdl([4, 7], [2, 6]);
print det($m), " ", inv($m)->flat, "\n"; # 10 [0.6 -0.7 -0.2 0.4]
print identity(2)->flat, " ", ($m x inv($m))->flat, "\n"; # [1 0 0 1] [1 0 0 1]
my ($u, $s, $v) = svd(pdl([3, 0], [0, 4]));
print "$s\n"; # [4 3]
my ($ev, $e) = eigens_sym(pdl([2, 1], [1, 2]));
print qsort($e), "\n"; # [1 3]
A matrix is a 2-D ndarray indexed (column, row), and every function broadcasts over further dimensions, so a stack of matrices is one call. x is matrix multiplication (PDL::Primitive’s matmult).
This is PDL::MatrixOps of PDL 2.106. The kernels are PDL’s own, through pperl’s engine; upstream’s Perl is used unchanged for identity, stretcher, inv, det, determinant, lu_decomp, lu_decomp2, lu_backsub, eigens, eigens_sym, gurney and tritosym.