{
"id": "fn-matrix-multiply",
"dataComponent": "matrix",
"heading": {
"title": "multiply",
"badges": [
"Matrix",
"PARTIAL"
]
},
"synopsis": "Performs standard matrix multiplication of two 2D arrays (int2d or float2d).",
"codeBlocks": [
"extend(\"matrix\")\n\n# 1) Standard usage => multiply 2×2 by 2×2\nA = [[1,2],[3,4]]\nB = [[5,6],[7,8]]\nproduct = matrix:multiply(A,B)\n# => [[19,22],[43,50]]\nsput(product)\n\n# 2) Partial usage => known A, missing B\nmulA = matrix:multiply(A)\nres = mulA(B)\nsput(res) # => [[19,22],[43,50]]\n\n# 3) Dimension mismatch => raises an error.\n# test:expect_error(\n# () => { matrix:multiply([[1,2,3],[4,5,6]], [[7,8],[9,10]]) },\n# \"dimension mismatch\"\n# )\n\n# 4) Float usage => multiply float2d arrays\nF1 = [[1.1,2.1],[3.5,4.5]]\nF2 = [[5.2,6.2],[7.1,8.9]]\nfloatProd = matrix:multiply(F1,F2)\n# => [[20.630000000000003, 25.51],[50.15, 61.75]]\nsput(floatProd)\n"
],
"notes": [
"Takes (A, B). If shapes are compatible => result is M×P if A is M×N and B is N×P.",
"If dimension mismatch (A’s columns != B’s rows), it raises an error. If one arg is missing, partial usage awaits the second array.",
"Supports both int2d_array and float2d_array. If mixing, you might get a float2d_array result."
]
}