Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
structure IMatrix = struct
|
||||
fun dot(x,y) = Vector.foldli (fn (i,xi,agg) => agg+xi*Vector.sub(y,i)) 0 x
|
||||
fun x*y =
|
||||
let
|
||||
open Array2
|
||||
in
|
||||
tabulate ColMajor (nRows x, nCols y, fn (i,j) => dot(row(x,i),column(y,j)))
|
||||
end
|
||||
end;
|
||||
(* for display *)
|
||||
fun toList a =
|
||||
let
|
||||
open Array2
|
||||
in
|
||||
List.tabulate(nRows a, fn i => List.tabulate(nCols a, fn j => sub(a,i,j)))
|
||||
end;
|
||||
(* example *)
|
||||
let
|
||||
open IMatrix
|
||||
val m1 = Array2.fromList [[1,2],[3,4]]
|
||||
val m2 = Array2.fromList [[~3,~8,3],[~2,1,4]]
|
||||
in
|
||||
toList (m1*m2)
|
||||
end;
|
||||
|
|
@ -0,0 +1 @@
|
|||
val it = [[~7,~6,11],[~17,~20,25]] : int list list
|
||||
Loading…
Add table
Add a link
Reference in a new issue