Matrix multiplication: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added/changed comments and whitespace, changed a subroutine name.) |
(Revise to be more idiomatic and not use local) |
||
Line 4,329: | Line 4,329: | ||
=={{header|Standard ML}}== |
=={{header|Standard ML}}== |
||
<lang sml>structure |
<lang sml>structure IMatrix = struct |
||
⚫ | |||
local |
|||
fun x*y = |
|||
⚫ | |||
let |
|||
⚫ | |||
⚫ | |||
in |
|||
in |
|||
val fromList = fromList |
|||
tabulate ColMajor (nRows x, nCols y, fn (i,j) => dot(row(x,i),column(y,j))) |
|||
⚫ | |||
⚫ | |||
(* for display *) |
(* for display *) |
||
fun toList a = |
fun toList a = |
||
let |
|||
⚫ | |||
open Array2 |
|||
⚫ | |||
in |
|||
⚫ | |||
⚫ | |||
end; |
|||
(* example *) |
(* example *) |
||
let |
|||
let open Matrix |
|||
open IMatrix |
|||
⚫ | |||
val |
val m1 = Array2.fromList [[1,2],[3,4]] |
||
⚫ | |||
in |
in |
||
toList (m1*m2) |
toList (m1*m2) |
||
end;</lang> |
end;</lang> |
||
'''Output:''' |
'''Output:''' |