September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -0,0 +1,19 @@
structure Matrix = struct
local
open Array2
fun dot(x,y) = Vector.foldli (fn (i,xi,agg) => agg+xi*Vector.sub(y,i)) 0 x
in
val fromList = fromList
fun x*y = tabulate ColMajor (nRows x, nCols y, fn (i,j) => dot(row(x,i),column(y,j)))
(* for display *)
fun toList a =
List.tabulate(nRows a, fn i => List.tabulate(nCols a, fn j => sub(a,i,j)))
end
end;
(* example *)
let open Matrix
val m1 = fromList [[1,2],[3,4]]
val m2 = fromList [[~3,~8,3],[~2,1,4]]
in
toList (m1*m2)
end;

View file

@ -0,0 +1 @@
val it = [[~7,~6,11],[~17,~20,25]] : int list list