From fa3a407253907ea754ac813d7ab3efd788d78778 Mon Sep 17 00:00:00 2001 From: Pierre-Francois Loos Date: Mon, 12 Oct 2020 08:57:00 +0200 Subject: [PATCH] Add Multipole.to_file --- dune-project | 1 - gaussian_integrals/lib/multipole.ml | 16 ++++++++++++++++ gaussian_integrals/lib/multipole.mli | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dune-project b/dune-project index 3d7638a..74b9906 100644 --- a/dune-project +++ b/dune-project @@ -27,7 +27,6 @@ in quantum chemistry.") (depends (ocaml (>= 4.10)) (dune (>= 1.10)) - str lacaml getopt zarith diff --git a/gaussian_integrals/lib/multipole.ml b/gaussian_integrals/lib/multipole.ml index deea6e0..83cfe40 100644 --- a/gaussian_integrals/lib/multipole.ml +++ b/gaussian_integrals/lib/multipole.ml @@ -222,3 +222,19 @@ let of_basis basis = Array.iter Matrix.detri_inplace result; result + +let to_file ~filename eni_array = + let n = Matrix.dim1 eni_array in + let eni_array = Matrix.to_bigarray_inplace eni_array in + let oc = open_out filename in + + for j=1 to n do + for i=1 to j do + let value = eni_array.{i,j} in + if (value <> 0.) then + Printf.fprintf oc " %5d %5d %20.15f\n" i j value; + done; + done; + close_out oc + + diff --git a/gaussian_integrals/lib/multipole.mli b/gaussian_integrals/lib/multipole.mli index f9e8ba8..f897ccc 100644 --- a/gaussian_integrals/lib/multipole.mli +++ b/gaussian_integrals/lib/multipole.mli @@ -60,3 +60,7 @@ val matrix_z4 : t -> (Basis.t, Basis.t) Matrix.t (** {% $$ \langle \chi_i | z^4 | \chi_j \rangle $$ %} *) val of_basis : Basis.t -> t + +val to_file : filename:string -> (Basis.t, Basis.t) Matrix.t -> unit +(** Write a matrix to a file *) +