diff --git a/ocaml/Block.ml b/ocaml/Block.ml index 6790df7..6941b21 100644 --- a/ocaml/Block.ml +++ b/ocaml/Block.ml @@ -195,16 +195,6 @@ let update_raw_data ?(locked=true) () = ) result in - let rec transform new_list = function - | [] -> new_list - | head :: tail -> - let head = String.trim head in - let item = of_string head in - match item with - | None -> transform new_list tail - | Some x -> transform (x::new_list) tail - in - if Qmcchem_config.binary_io then begin let result = @@ -237,6 +227,16 @@ let update_raw_data ?(locked=true) () = end else begin + let rec transform new_list = function + | [] -> new_list + | head :: tail -> + let head = String.trim head in + let item = of_string head in + match item with + | None -> transform new_list tail + | Some x -> transform (x::new_list) tail + in + let result = let rec aux ic accu = let l = diff --git a/ocaml/Qmcchem_result.ml b/ocaml/Qmcchem_result.ml index 102bae7..68106d8 100644 --- a/ocaml/Qmcchem_result.ml +++ b/ocaml/Qmcchem_result.ml @@ -139,9 +139,8 @@ let display_summary ~range = and print_property property = let p = Random_variable.of_raw_data ~range property in - Printf.printf "%20s : %s\n" - (Property.to_string property) - (Random_variable.to_string p) + Printf.printf "%20s : %!" (Property.to_string property); + Printf.printf "%s\n%!" (Random_variable.to_string p) in List.iter print_property properties ; diff --git a/ocaml/Random_variable.ml b/ocaml/Random_variable.ml index 13482ab..f408564 100644 --- a/ocaml/Random_variable.ml +++ b/ocaml/Random_variable.ml @@ -209,7 +209,7 @@ let ave_error { property ; data } = else ( Average.of_float (sum /. ansum), None) end - | (x,w) :: tail -> + | (x, w) :: tail -> begin let avcu0 = avsum /. ansum in let xw = x *. w in @@ -633,6 +633,7 @@ let to_string p = in Printf.sprintf "%16.10f" ave else +begin match ave_error p with | (ave, Some error) -> let idxmax = @@ -645,16 +646,18 @@ let to_string p = Error.to_float ~idx error in let s = - Printf.sprintf "%8d : %16.10f +/- %16.10f ;\n" (idx+1) ave error + Printf.sprintf "%8d : %16.10f +/- %16.10f ;" (idx+1) ave error in - f (accu ^ s) (idx+1) + (f [@tailcall]) (s :: accu) (idx+1) else - accu + List.rev (" ]" :: accu) in - (f "[ \n" 0) ^ " ]" + f ["[ \n"] 0 + |> String.concat "\n" | (ave, None) -> Average.to_float ave - |> Printf.sprintf "%16.10f" + |> Printf.sprintf "%16.10f%!" +end end diff --git a/ocaml/Sample.ml b/ocaml/Sample.ml index f1f6c51..4a2d64f 100644 --- a/ocaml/Sample.ml +++ b/ocaml/Sample.ml @@ -58,7 +58,10 @@ let of_bytes b = | 8 -> let x = Qptypes.float_of_bytes b in One_dimensional x | l -> let len = l/8 in +let result = Multidimensional ( Array.init len (fun i -> Bytes.get_int64_le b (i*8) |> Int64.float_of_bits ), len ) +in +result