mmul, mdiv
These functions do true matrix multiplication and division (and not not simple scalar multiplication or division)
Matrices must be provided as 2-level parameter sets, e.g. {{1,2},{3,4}}
mmul: For matrix multiplications, the number of columns (and / rows) in the left matrix needs to match with the number of rows (/ columns) in the right matrix.
mdiv: For matrix divisions, both matrices need to be squares, i.e. row and column count must equal.
In case of division, 2nd matrix must also be a square matrix as it is inverted before a multiplication (like mmul) is applied. Result = A • B-1,
The function will reject calculations and assert exceptions if not all criteria are properly met.
Indirect parameter passing is disabled
2
No. | Type | Description |
---|---|---|
1 input |
matrix of numerals | Left Matrix |
2 input |
matrix of numerals | Right Matrix |
Type | Description |
---|---|
matrix of numerals | Result Matrix with number of rows as specified in the left matrix and number of columns as specified in the right matrix |
Mismatching matrix sizes
Division: Matrices are not squares
echo( mmul ( {{1,2},{3,4}}, {{8,6},{4,2}} ) ); // returns {{16,10},{40,26}}
echo( mdiv ( {{1,2},{3,4}}, {{3,1},{1,2}} ) ); // returns {{0,1}, {0.4,1.8}}
{{16,10},{40,26}}
{{0,1},{0.4,1.8}}