in reply to Fast matrix multiplication

Interestingly, this came up today on perl.com's entry from the Perl Cookbook.

Use PDL, which overloads the '*' operator (among others) to multiply a matrix.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re^2: Fast matrix multiplication
by etj (Priest) on Feb 20, 2022 at 15:25 UTC
    In PDL, '*' is for scalar multiplication, which automatically "broadcasts" up so that two ndarrays can be scalar-multiplied so the result is each of the six "slots" being the product of the two numbers. Matrix multiplication is the overload of the 'x' operator.
    pdl> p $x = sequence(2,2) [ [0 1] [2 3] ] pdl> p $y = sequence(2,2) + 3 [ [3 4] [5 6] ] pdl> p $x * $y [ [ 0 4] [10 18] ] pdl> p $x x $y [ [ 5 6] [21 26] ]