From fb8fff6ee12a67563dfd667fd8bd9c81b732e3a1 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 2 Feb 2018 00:04:35 +0100 Subject: [PATCH] Optimization --- Basis/TwoElectronRR.ml | 4 +--- Basis/TwoElectronRRVectorized.ml | 6 ++++-- Makefile | 5 +++++ Utils/Util.ml | 6 ++---- _tags | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Basis/TwoElectronRR.ml b/Basis/TwoElectronRR.ml index 35b6b29..876ef61 100644 --- a/Basis/TwoElectronRR.ml +++ b/Basis/TwoElectronRR.ml @@ -92,8 +92,7 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d) Printf.printf "vrr : %d %d : %d %d %d %d %d %d\n" totAngMom_a totAngMom_c angMom_a.(0) angMom_a.(1) angMom_a.(2) angMom_c.(0) angMom_c.(1) angMom_c.(2); match (totAngMom_a, totAngMom_c) with - | (0,0) -> zero_m_array - | (_,0) -> vrr0 angMom_a totAngMom_a + | (i,0) -> if (i>0) then vrr0 angMom_a totAngMom_a else zero_m_array | (_,_) -> let maxsze = maxm+1 in @@ -190,7 +189,6 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d) in v1.(0) +. f2 *. v2.(0) | _ -> - let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |] and bm = [| angMom_b.(0) ; angMom_b.(1) ; angMom_b.(2) |] and xyz = diff --git a/Basis/TwoElectronRRVectorized.ml b/Basis/TwoElectronRRVectorized.ml index d813183..45e9a5f 100644 --- a/Basis/TwoElectronRRVectorized.ml +++ b/Basis/TwoElectronRRVectorized.ml @@ -92,8 +92,10 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d) and vrr_v m angMom_a angMom_c totAngMom_a totAngMom_c = match (totAngMom_a, totAngMom_c) with - | (0,0) -> Array.mapi (fun k c -> c *. zero_m_array.(k).(m)) coef_prod - | (_,0) -> vrr0_v m angMom_a totAngMom_a + | (i,0) -> if (i=0) then + Array.mapi (fun k c -> c *. zero_m_array.(k).(m)) coef_prod + else + vrr0_v m angMom_a totAngMom_a | (_,_) -> let key = Zkey.of_int_tuple (Zkey.Six diff --git a/Makefile b/Makefile index 6bc9375..a831ffe 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,11 @@ doc: qpackage.odocl $(OCAMLBUILD) $*.native -use-ocamlfind $(PKGS) ln -s $*.native $* +%.p.native: $(MLFILES) $(MLIFILES) $(MLLFILES) $(MLYFILES) + rm -f -- $* + $(OCAMLBUILD) $*.p.native -use-ocamlfind $(PKGS) + ln -s $*.p.native $* + clean: rm -rf _build $(ALL_EXE) $(ALL_TESTS) *.native *.byte diff --git a/Utils/Util.ml b/Utils/Util.ml index 38c4335..85f16f5 100644 --- a/Utils/Util.ml +++ b/Utils/Util.ml @@ -23,7 +23,7 @@ let rec p_gamma a x loggamma_a = else if x = 0. then 0. else let rec pg_loop prev res term k = - if k > 1000. then failwith "p_gamma could not converge." + if k > 1000. then failwith "p_gamma did not converge." else if prev = res then res else let term = term *. x /. (a +. k) in @@ -36,7 +36,7 @@ let rec p_gamma a x loggamma_a = if x < 1. +. a then 1. -. p_gamma a x loggamma_a else let rec qg_loop prev res la lb w k = - if k > 1000. then failwith "q_gamma could not converge." + if k > 1000. then failwith "q_gamma did not converge." else if prev = res then res else let k_inv = 1. /. k in @@ -69,8 +69,6 @@ let rec boys_function ~maxm t = Array.init (maxm+1) (fun m -> 1. /. float_of_int (m+m+1)) else let incomplete_gamma ~alpha x = -(* (gamma_float alpha) *. ( Gsl.Sf.gamma_inc_P alpha x ) -*) let gf = gamma_float alpha in gf *. p_gamma alpha x (log gf) in diff --git a/_tags b/_tags index 7199fb1..3ca4638 100644 --- a/_tags +++ b/_tags @@ -1,3 +1,3 @@ -true: package(str,gsl,zarith) +true: package(str,zarith) <*.byte> : linkdep(Utils/math_functions.o) <*.native>: linkdep(Utils/math_functions.o)