From b019cd04f0b08ef1cccc4e6b2ac4eaf6ad8e77c8 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 22 Feb 2016 23:33:30 +0100 Subject: [PATCH] Only 10k determinants max in qp_edit --- ocaml/Bitlist.ml | 6 ++++++ ocaml/Bitlist.mli | 1 + ocaml/Determinant.ml | 30 ++++++++++++++++------------- ocaml/Input_determinants_by_hand.ml | 23 +++++++++++----------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/ocaml/Bitlist.ml b/ocaml/Bitlist.ml index c1dc66d9..d7b9fc50 100644 --- a/ocaml/Bitlist.ml +++ b/ocaml/Bitlist.ml @@ -79,6 +79,12 @@ let of_int64_list l = List.map ~f:of_int64 l |> List.concat +(* Create a bit list from an array of int64 *) +let of_int64_array l = + Array.map ~f:of_int64 l + |> Array.to_list + |> List.concat + (* Compute n_int *) let n_int_of_mo_tot_num mo_tot_num = diff --git a/ocaml/Bitlist.mli b/ocaml/Bitlist.mli index 69019920..f67d86b7 100644 --- a/ocaml/Bitlist.mli +++ b/ocaml/Bitlist.mli @@ -18,6 +18,7 @@ val of_int64 : int64 -> t val to_int64 : t -> int64 val of_int64_list : int64 list -> t +val of_int64_array : int64 array -> t val to_int64_list : t -> int64 list val to_int64_array : t -> int64 array diff --git a/ocaml/Determinant.ml b/ocaml/Determinant.ml index 13df7b38..3791e07e 100644 --- a/ocaml/Determinant.ml +++ b/ocaml/Determinant.ml @@ -15,21 +15,25 @@ let to_alpha_beta x = let to_bitlist_couple x = let (xa,xb) = to_alpha_beta x in - let xa = to_int64_array xa - |> Array.to_list - |> Bitlist.of_int64_list - and xb = to_int64_array xb - |> Array.to_list - |> Bitlist.of_int64_list + let xa = + to_int64_array xa + |> Bitlist.of_int64_array + and xb = + to_int64_array xb + |> Bitlist.of_int64_array in (xa,xb) let bitlist_to_string ~mo_tot_num x = - List.map x ~f:(fun i -> match i with - | Bit.Zero -> "-" - | Bit.One -> "+" ) + let len = + MO_number.to_int mo_tot_num + in + List.map x ~f:(function + | Bit.Zero -> "-" + | Bit.One -> "+" + ) |> String.concat - |> String.sub ~pos:0 ~len:(MO_number.to_int mo_tot_num) + |> String.sub ~pos:0 ~len @@ -71,8 +75,8 @@ let of_bitlist_couple ?n_int ~alpha ~beta (xa,xb) = let to_string ~mo_tot_num x = let (xa,xb) = to_bitlist_couple x in - [ bitlist_to_string ~mo_tot_num:mo_tot_num xa ; - bitlist_to_string ~mo_tot_num:mo_tot_num xb ] - |> String.concat ~sep:"\n" + [ " " ; bitlist_to_string ~mo_tot_num xa ; "\n" ; + " " ; bitlist_to_string ~mo_tot_num xb ] + |> String.concat diff --git a/ocaml/Input_determinants_by_hand.ml b/ocaml/Input_determinants_by_hand.ml index 65eb9204..eecd87f0 100644 --- a/ocaml/Input_determinants_by_hand.ml +++ b/ocaml/Input_determinants_by_hand.ml @@ -29,7 +29,7 @@ end = struct let get_default = Qpackage.get_ezfio_default "determinants";; - let n_det_read_max = 50_000_000 ;; + let n_det_read_max = 10_000 ;; let read_n_int () = if not (Ezfio.has_determinants_n_int()) then @@ -258,11 +258,16 @@ end = struct let to_rst b = - let mo_tot_num = Ezfio.get_mo_basis_mo_tot_num () in - let mo_tot_num = MO_number.of_int mo_tot_num ~max:mo_tot_num in + let max = + Ezfio.get_mo_basis_mo_tot_num () + in + let mo_tot_num = + MO_number.of_int ~max max + in let det_text = let nstates = - read_n_states () |> States_number.to_int + read_n_states () + |> States_number.to_int and ndet = Det_number.to_int b.n_det in @@ -281,13 +286,9 @@ end = struct |> String.concat_array ~sep:"\t" in Array.init ndet ~f:(fun i -> - Printf.sprintf " %s\n%s\n" - (coefs_string i) - (Determinant.to_string ~mo_tot_num:mo_tot_num b.psi_det.(i) - |> String.split ~on:'\n' - |> List.map ~f:(fun x -> " "^x) - |> String.concat ~sep:"\n" - ) + String.concat [ " " ; + (coefs_string i) ; "\n" ; + (Determinant.to_string ~mo_tot_num b.psi_det.(i)) ; "\n" ] ) |> String.concat_array ~sep:"\n" in