forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbigarray_test.ml
39 lines (31 loc) · 1.11 KB
/
bigarray_test.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module BA1 = Bigarray.Array1
(* let v = BA1.create Int32 C_layout 20;; *)
let sum (v : (int32, 'a, 'b) BA1.t ) =
let result = ref 0l in
for i = 0 to BA1.dim v - 1 do (* caml_ba_dim_1 *)
result := Int32.add (!result) v.{i} (* caml_ba_get_1*)
done
(* let vv : (int32, Bigarray.int32_elt, Bigarray.fortran_layout) BA1.t *)
(* = BA1.create Int32 Fortran_layout 30 ;; *)
let init (v : (Complex.t,
Bigarray.int32_elt, Bigarray.c_layout ) BA1.t) =
for i = 0 to BA1.dim v - 1 do (* caml_ba_dim_1 *)
(* let i = Int32.of_int i in *)
v.{i} <- { re = float @@ i * i; im = float @@ i * i * i}
done
let init2 (v : (int32,
Bigarray.int32_elt, Bigarray.c_layout ) BA1.t) =
for i = 0 to BA1.dim v - 1 do (* caml_ba_dim_1 *)
(* let i = Int32.of_int i in *)
v.{i} <- Int32.of_int i
done
let init3 (v : (int32,
_, Bigarray.c_layout ) BA1.t) =
for i = 0 to BA1.dim v - 1 do (* caml_ba_dim_1 *)
(* let i = Int32.of_int i in *)
v.{i} <- Int32.of_int i
done
(* let a = *)
(* init v ; *)
(* (\* init vv; *\) *)
(* (sum v(\* , sum vv *\)) *)