From f4f31db614f2e755a66a93ea7f095382fc2c986f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 27 Mar 2018 19:32:37 +0200 Subject: [PATCH] Changed integral storage to Float32 --- Basis/ERI.ml | 2 +- Utils/FourIdxStorage.ml | 5 +++-- Utils/FourIdxStorage.mli | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 Utils/FourIdxStorage.mli diff --git a/Basis/ERI.ml b/Basis/ERI.ml index 675ab55..577b85c 100644 --- a/Basis/ERI.ml +++ b/Basis/ERI.ml @@ -77,7 +77,7 @@ let filter_contracted_shell_pairs ?(cutoff=integrals_cutoff) shell_pairs = | Some cspc -> let cls = class_of_contracted_shell_pair_couple cspc in (pair, Zmap.fold (fun key value accu -> max (abs_float value) accu) cls 0. ) - | None -> (pair, -1.) + | None -> (pair, -1.) ) shell_pairs |> List.filter (fun (_, schwartz_p_max) -> schwartz_p_max >= cutoff) |> List.map fst diff --git a/Utils/FourIdxStorage.ml b/Utils/FourIdxStorage.ml index 4390701..a90e1f9 100644 --- a/Utils/FourIdxStorage.ml +++ b/Utils/FourIdxStorage.ml @@ -2,8 +2,9 @@ let max_index = 1 lsl 14 type index_pair = { first : int ; second : int } + type storage_t = - | Dense of (float, Bigarray.float64_elt, Bigarray.fortran_layout) Bigarray.Genarray.t + | Dense of (float, Bigarray.float32_elt, Bigarray.fortran_layout) Bigarray.Genarray.t | Sparse of (int, float) Hashtbl.t type t = @@ -81,7 +82,7 @@ let create ~size sparsity = match sparsity with | `Dense -> let result = - Bigarray.Genarray.create Float64 Bigarray.fortran_layout [| size ; size ; size ; size |] + Bigarray.Genarray.create Float32 Bigarray.fortran_layout [| size ; size ; size ; size |] in Bigarray.Genarray.fill result 0.; Dense result diff --git a/Utils/FourIdxStorage.mli b/Utils/FourIdxStorage.mli new file mode 100644 index 0000000..78f9656 --- /dev/null +++ b/Utils/FourIdxStorage.mli @@ -0,0 +1,25 @@ +(** Storage for four-index data (integrals, density matrices, ...). + +There are two kinds of ordering of indices: + +- Physicist's : { \[ \langle i j | k l \rangle \] } +- Chemist's : { \[ ( i j | k l ) \] } + +*) + +type t + +val create : size:int -> [< `Dense | `Sparse ] -> t +(** If [`Dense] is chosen, internally the data is stored as a 4-dimensional + [Bigarray]. Else, it is stored as a hash table. +*) + +(** {2 Accessors} *) +val get_chem : t -> int -> int -> int -> int -> float +val get_phys : t -> int -> int -> int -> int -> float +val set_chem : t -> int -> int -> int -> int -> float -> unit +val set_phys : t -> int -> int -> int -> int -> float -> unit + +(** {2 I/O} *) +val to_file : ?cutoff:float -> filename:string -> t -> unit +(** Write the data to file, using the physicist's ordering. *)