(* %use "Matrix/mat_mult_loop.fsh";; *) (* some basic linear algebra. You must specify values for the algebraic primitives before using this module. plus zero times ... This file uses float as the default *) %use "Datum/float.fsh" ;; let rows x = lendim #x ;; let cols x = lendim (preddim #x) ;; let mat_mult_loop_pr (z:var [a]) (x:var [a]) (y:var [a]) = for 0<= i< rows x do for 0 <= j< cols y do z[i,j]:= 0.0 for 0 <= k< cols x do z[i,j] := plus z[i,j] (times x[i,k] y[k,j]) done done done ;; let mat_mult_loop_sh x y = let m = lendim x and n = lendim (preddim x) and p = lendim y and q = lendim (preddim y) in check (n = p) succdim m (succdim q (zerodim #zero)) ;; let mat_mult_loop = proc2fun2 mat_mult_loop_pr mat_mult_loop_sh ;;