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