in reply to How do I create a matrix?

You can use PDL::Matrix
#!/usr/bin/perl -w use strict; use PDL::Matrix; my $m = pdl [ [1,2,3], [4,5,6], [7,8,9] ];
Which then also allows you to perform clean, fast math on them.
my $m = pdl [ [1,2,3], [4,5,6], [7,8,9] ]; my $n = pdl [ [1,0,0], [0,1,0], [0,0,1] ]; my $r = $m x $n;

Replies are listed 'Best First'.
Re^2: How do I create a matrix?
by etj (Priest) on Jul 08, 2022 at 19:35 UTC
    The above appears not to use PDL::Matrix-specific features (which are full of gotchas); better practice would be just to use PDL, and all the rest of the code above will then work as given. Try perldl after installing PDL, the online help is really good. For better matrix support, try also PDL::LinearAlgebra.