(* param 1 = size of the matrices at the beginning param 2 = incrementation param 3 = size of the matrices at the end param 4 = number of iteration (Objective Caml version 3.09.1) ocamlopt -unsafe -o ocamlmult mult.ml time ./ocamlmult 600 2 602 1 real 0m17.043s user 0m16.937s sys 0m0.052s *) let multiplication n zero add mul a b c = let tmp=ref zero in for i=0 to n-1 do for j=0 to n-1 do tmp:=zero; (* let rec loop tmp k = if k=n then tmp else loop (add tmp (mul b.(k*n+j) a.(i*n+k))) (k+1) in c.(i*n+j)<-loop zero 0 *) for k=0 to n-1 do tmp:= add (!tmp) (mul b.(k*n+j) a.(i*n+k)) done; c.(i*n+j)<-(!tmp) done done let random_complex n = {Complex.re=Random.float n; im=Random.float n} let matrixRandom n = Array.init (n*n) (fun _ -> random_complex 1000.) let _ = Random.self_init(); let i = ref (int_of_string (Sys.argv).(1)) and pas=(int_of_string (Sys.argv).(2)) and maxi=(int_of_string (Sys.argv).(3)) and iter=(int_of_string (Sys.argv).(4)) in while !i