10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-22 12:23:31 +01:00

Array access optimization (4idx)

This commit is contained in:
Anthony Scemama 2020-01-21 21:27:40 +01:00
parent 41cfd3e6d4
commit b8b1d3e1e0

View File

@ -44,7 +44,7 @@ let array_3_init d1 d2 d3 fx =
done) done)
; ;
if Parallel.master then Printf.printf "Broadcast d3\n" ; if Parallel.master then Printf.printf "Broadcast d3\n" ;
Parallel.broadcast (lazy result) Parallel.Node.broadcast (lazy result)
let array_4_init d1 d2 d3 d4 fx = let array_4_init d1 d2 d3 d4 fx =
let f l = let f l =
@ -76,7 +76,7 @@ let array_4_init d1 d2 d3 d4 fx =
done) done)
; ;
if Parallel.master then Printf.printf "Broadcast d4\n" ; if Parallel.master then Printf.printf "Broadcast d4\n" ;
Parallel.broadcast (lazy result) Parallel.Node.broadcast (lazy result)
let array_5_init d1 d2 d3 d4 d5 fx = let array_5_init d1 d2 d3 d4 d5 fx =
let f m = let f m =
@ -112,7 +112,7 @@ let array_5_init d1 d2 d3 d4 d5 fx =
done) done)
; ;
if Parallel.master then Printf.printf "Broadcast d5\n" ; if Parallel.master then Printf.printf "Broadcast d5\n" ;
Parallel.broadcast (lazy result) Parallel.Node.broadcast (lazy result)
let make ~simulation ~mo_basis ~aux_basis_filename () = let make ~simulation ~mo_basis ~aux_basis_filename () =
@ -208,7 +208,7 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_0111_1H_1F = let m_0111_1H_1F =
Vec.init mo_num (fun i -> Vec.init mo_num (fun i ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_one i a Spin.Alfa *. f_one a i Spin.Alfa )) h_one a i Spin.Alfa *. f_one a i Spin.Alfa ))
in in
if Parallel.master then Printf.printf "Computing m_0111_1H_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_0111_1H_2Fa\n" ;
@ -217,15 +217,15 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_0122_Haa = let m_0122_Haa =
array_3_init mo_num mo_num mo_num (fun i j k -> array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a k Spin.Alfa Spin.Alfa *. f_two a k i j Spin.Alfa Spin.Alfa h_two a k i j Spin.Alfa Spin.Alfa *. f_two a k i j Spin.Alfa Spin.Alfa
) ) ) )
in in
let m_0111_1H_2Fa = let m_0111_1H_2Fa =
Mat.init_cols mo_num mo_num (fun i j -> Mat.init_cols mo_num mo_num (fun i j ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_one i a Spin.Alfa *. f_two a j i j Spin.Alfa Spin.Alfa +. h_one a i Spin.Alfa *. f_two a j i j Spin.Alfa Spin.Alfa +.
h_two i j a j Spin.Alfa Spin.Alfa *. f_one a i Spin.Alfa h_two a j i j Spin.Alfa Spin.Alfa *. f_one a i Spin.Alfa
) +. ) +.
if i < j then 0. else if i < j then 0. else
begin begin
@ -242,7 +242,7 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_0111_2Ha_2Fa = let m_0111_2Ha_2Fa =
array_3_init mo_num mo_num mo_num (fun i j k -> array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Alfa *. h_two a j i j Spin.Alfa Spin.Alfa *.
f_two a k i k Spin.Alfa Spin.Alfa f_two a k i k Spin.Alfa Spin.Alfa
) -. if i < j then 0. else m_0122_Haa.{i,j,k} ) -. if i < j then 0. else m_0122_Haa.{i,j,k}
) )
@ -254,22 +254,22 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_0122_Hab = let m_0122_Hab =
array_3_init mo_num mo_num mo_num (fun i j k -> array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a k Spin.Alfa Spin.Beta *. f_two a k i j Spin.Alfa Spin.Beta h_two a k i j Spin.Alfa Spin.Beta *. f_two a k i j Spin.Alfa Spin.Beta
) ) ) )
in in
let m_0111_1H_2Fb = let m_0111_1H_2Fb =
Mat.init_cols mo_num mo_num (fun i j -> Mat.init_cols mo_num mo_num (fun i j ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_one i a Spin.Alfa *. f_two a j i j Spin.Alfa Spin.Beta +. h_one a i Spin.Alfa *. f_two a j i j Spin.Alfa Spin.Beta +.
h_two i j a j Spin.Alfa Spin.Beta *. f_one a i Spin.Alfa +. h_two a j i j Spin.Alfa Spin.Beta *. f_one a i Spin.Alfa +.
h_one j a Spin.Alfa *. f_two a i j i Spin.Alfa Spin.Beta +. h_one a j Spin.Alfa *. f_two a i j i Spin.Alfa Spin.Beta +.
h_two j i a i Spin.Alfa Spin.Beta *. f_one a j Spin.Alfa h_two a i j i Spin.Alfa Spin.Beta *. f_one a j Spin.Alfa
) +. ) +.
sum mos_in (fun k -> m_0122_Hab.{i,j,k} +. m_0122_Hab.{j,i,k} ) +. sum mos_in (fun k -> m_0122_Hab.{i,j,k} +. m_0122_Hab.{j,i,k} ) +.
sum mos_cabs (fun a ->
sum mos_cabs (fun b -> sum mos_cabs (fun b ->
h_two i j a b Spin.Alfa Spin.Beta *. f_two a b i j Spin.Alfa Spin.Beta sum mos_cabs (fun a ->
h_two a b i j Spin.Alfa Spin.Beta *. f_two a b i j Spin.Alfa Spin.Beta
) )
) )
) )
@ -278,9 +278,9 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_0111_2Hb_2Fb = let m_0111_2Hb_2Fb =
array_3_init mo_num mo_num mo_num (fun i j k -> array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two k i a i Spin.Alfa Spin.Beta *. h_two a i k i Spin.Alfa Spin.Beta *.
f_two a j k j Spin.Alfa Spin.Beta +. f_two a j k j Spin.Alfa Spin.Beta +.
h_two i k a k Spin.Alfa Spin.Beta *. h_two a k i k Spin.Alfa Spin.Beta *.
f_two a j i j Spin.Alfa Spin.Alfa f_two a j i j Spin.Alfa Spin.Alfa
) -. m_0122_Hab.{k,i,j} ) -. m_0122_Hab.{k,i,j}
) )
@ -292,7 +292,7 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_0111_2Ha_2Fb = let m_0111_2Ha_2Fb =
array_3_init mo_num mo_num mo_num (fun i j k -> array_3_init mo_num mo_num mo_num (fun i j k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Alfa *. h_two a j i j Spin.Alfa Spin.Alfa *.
f_two a k i k Spin.Alfa Spin.Beta f_two a k i k Spin.Alfa Spin.Beta
) )
) )
@ -364,7 +364,7 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
if Parallel.master then Printf.printf "Computing m_1111_1H_1F\n" ; if Parallel.master then Printf.printf "Computing m_1111_1H_1F\n" ;
let m_1111_1H_1F = let m_1111_1H_1F =
Mat.init_cols mo_num mo_num (fun i k -> Mat.init_cols mo_num mo_num (fun i k ->
sum mos_cabs (fun a -> h_one i a Spin.Alfa *. f_one a k Spin.Alfa )) sum mos_cabs (fun a -> h_one a i Spin.Alfa *. f_one a k Spin.Alfa ))
in in
if Parallel.master then Printf.printf "Computing m_1111_2Ha_2Fa\n" ; if Parallel.master then Printf.printf "Computing m_1111_2Ha_2Fa\n" ;
@ -372,14 +372,13 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
if l=i then if l=i then
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two j l a l Spin.Alfa Spin.Alfa *. h_two a l j l Spin.Alfa Spin.Alfa *.
f_two a i j k Spin.Alfa Spin.Alfa f_two a i j k Spin.Alfa Spin.Alfa )
)
else else
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Alfa *. h_two a j i j Spin.Alfa Spin.Alfa *.
f_two a l k l Spin.Alfa Spin.Alfa +. f_two a l k l Spin.Alfa Spin.Alfa +.
h_two j l a l Spin.Alfa Spin.Alfa *. h_two a l j l Spin.Alfa Spin.Alfa *.
f_two a i j k Spin.Alfa Spin.Alfa ) f_two a i j k Spin.Alfa Spin.Alfa )
) )
in in
@ -389,16 +388,14 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
if l=i then if l=i then
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two j l a l Spin.Alfa Spin.Beta *. h_two a l j l Spin.Alfa Spin.Beta *.
f_two a i j k Spin.Alfa Spin.Beta f_two a i j k Spin.Alfa Spin.Beta )
)
else else
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Beta *. h_two a j i j Spin.Alfa Spin.Beta *.
f_two a l k l Spin.Alfa Spin.Alfa +. f_two a l k l Spin.Alfa Spin.Alfa +.
h_two j l a l Spin.Alfa Spin.Beta *. h_two a l j l Spin.Alfa Spin.Beta *.
f_two a i j k Spin.Alfa Spin.Beta f_two a i j k Spin.Alfa Spin.Beta )
)
) )
in in
@ -406,9 +403,9 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1111_2Ha_2Fb = let m_1111_2Ha_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Alfa *. h_two a j i j Spin.Alfa Spin.Alfa *.
f_two a l k l Spin.Alfa Spin.Beta +. f_two a l k l Spin.Alfa Spin.Beta +.
h_two j l a l Spin.Alfa Spin.Beta *. h_two a l j l Spin.Alfa Spin.Beta *.
f_two a i j k Spin.Alfa Spin.Alfa f_two a i j k Spin.Alfa Spin.Alfa
) )
) )
@ -418,9 +415,9 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1111_2Hb_2Fb = let m_1111_2Hb_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Beta *. h_two a j i j Spin.Alfa Spin.Beta *.
f_two a l k l Spin.Alfa Spin.Beta +. f_two a l k l Spin.Alfa Spin.Beta +.
h_two j l a l Spin.Alfa Spin.Alfa *. h_two a l j l Spin.Alfa Spin.Alfa *.
f_two a i j k Spin.Alfa Spin.Beta f_two a i j k Spin.Alfa Spin.Beta
) )
) )
@ -430,8 +427,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1121_2Ha_2Fa = let m_1121_2Ha_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j k a Spin.Alfa Spin.Alfa *. h_two a k j i Spin.Alfa Spin.Alfa *.
f_two l a l j Spin.Alfa Spin.Alfa f_two a l j l Spin.Alfa Spin.Alfa
) )
) )
in in
@ -440,8 +437,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1121_2Hb_2Fa = let m_1121_2Hb_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j k a Spin.Alfa Spin.Beta *. h_two a k j i Spin.Alfa Spin.Beta *.
f_two l a l j Spin.Alfa Spin.Alfa f_two a l j l Spin.Alfa Spin.Alfa
) )
) )
in in
@ -450,8 +447,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1121_2Ha_2Fb = let m_1121_2Ha_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j k a Spin.Alfa Spin.Alfa *. h_two a k j i Spin.Alfa Spin.Alfa *.
f_two l a l j Spin.Alfa Spin.Beta f_two a l j l Spin.Alfa Spin.Beta
) )
) )
in in
@ -460,8 +457,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1121_2Hb_2Fb = let m_1121_2Hb_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j k a Spin.Alfa Spin.Beta *. h_two a k j i Spin.Alfa Spin.Beta *.
f_two l a l j Spin.Alfa Spin.Beta f_two a l j l Spin.Alfa Spin.Beta
) )
) )
in in
@ -470,8 +467,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1122_va = let m_1122_va =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two j i a l Spin.Alfa Spin.Alfa *. h_two a l j i Spin.Alfa Spin.Alfa *.
f_two l a k j Spin.Alfa Spin.Alfa f_two a l j k Spin.Alfa Spin.Alfa
) )
) )
in in
@ -481,13 +478,13 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
array_3_init mo_num mo_num mo_num (fun j i k -> array_3_init mo_num mo_num mo_num (fun j i k ->
sum mos_in (fun l -> m_1122_va.{l,j,i,k}) +. sum mos_in (fun l -> m_1122_va.{l,j,i,k}) +.
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_one i a Spin.Alfa *. f_two a j k j Spin.Alfa Spin.Alfa +. h_one a i Spin.Alfa *. f_two a j k j Spin.Alfa Spin.Alfa +.
h_two i j a j Spin.Alfa Spin.Alfa *. f_one a k Spin.Alfa +. h_two a j i j Spin.Alfa Spin.Alfa *. f_one a k Spin.Alfa +.
h_one j a Spin.Alfa *. f_two a i j k Spin.Alfa Spin.Alfa +. h_one a j Spin.Alfa *. f_two a i j k Spin.Alfa Spin.Alfa +.
h_two i j k a Spin.Alfa Spin.Alfa *. f_one a j Spin.Alfa +. h_two a k j i Spin.Alfa Spin.Alfa *. f_one a j Spin.Alfa +.
sum mos_cabs (fun b -> if b > a then 0. else sum mos_cabs (fun b -> if b > a then 0. else
h_two i j a b Spin.Alfa Spin.Alfa *. h_two b a j i Spin.Alfa Spin.Alfa *.
f_two a b k j Spin.Alfa Spin.Alfa ) f_two b a j k Spin.Alfa Spin.Alfa )
) )
) )
in in
@ -496,8 +493,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1122_v2 = let m_1122_v2 =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j l a Spin.Alfa Spin.Beta *. h_two a l j i Spin.Alfa Spin.Beta *.
f_two l a k j Spin.Alfa Spin.Beta f_two a l j k Spin.Alfa Spin.Beta
) )
) )
in in
@ -506,7 +503,7 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1122_v3 = let m_1122_v3 =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a l Spin.Alfa Spin.Beta *. h_two a l i j Spin.Alfa Spin.Beta *.
f_two a l k j Spin.Alfa Spin.Beta f_two a l k j Spin.Alfa Spin.Beta
) )
) )
@ -517,13 +514,13 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
array_3_init mo_num mo_num mo_num (fun j i k -> array_3_init mo_num mo_num mo_num (fun j i k ->
sum mos_in (fun l -> m_1122_v2.{l,j,i,k} +. m_1122_v3.{l,j,i,k}) +. sum mos_in (fun l -> m_1122_v2.{l,j,i,k} +. m_1122_v3.{l,j,i,k}) +.
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_one i a Spin.Alfa *. f_two a j k j Spin.Alfa Spin.Beta +. h_one a i Spin.Alfa *. f_two a j k j Spin.Alfa Spin.Beta +.
h_two i j a j Spin.Alfa Spin.Beta *. f_one a k Spin.Alfa +. h_two a j i j Spin.Alfa Spin.Beta *. f_one a k Spin.Alfa +.
h_one j a Spin.Beta *. f_two a i j k Spin.Alfa Spin.Beta +. h_one a j Spin.Beta *. f_two a i j k Spin.Alfa Spin.Beta +.
h_two i j k a Spin.Alfa Spin.Beta *. f_one a j Spin.Beta +. h_two a k j i Spin.Alfa Spin.Beta *. f_one a j Spin.Beta +.
sum mos_cabs (fun b -> sum mos_cabs (fun b ->
h_two i j a b Spin.Alfa Spin.Beta *. h_two b a j i Spin.Alfa Spin.Beta *.
f_two a b k j Spin.Alfa Spin.Beta f_two b a j k Spin.Alfa Spin.Beta
) )
) )
) )
@ -534,8 +531,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
if l > j then if l > j then
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two j l a k Spin.Alfa Spin.Alfa *. h_two a k j l Spin.Alfa Spin.Alfa *.
f_two i a l j Spin.Alfa Spin.Alfa f_two a i j l Spin.Alfa Spin.Alfa
) )
else 0. else 0.
) )
@ -545,8 +542,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1122_o = let m_1122_o =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k -> array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two l j k a Spin.Alfa Spin.Beta *. h_two a k j l Spin.Alfa Spin.Beta *.
f_two i a l j Spin.Alfa Spin.Beta f_two a i j l Spin.Alfa Spin.Beta
) )
) )
in in
@ -634,14 +631,14 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2112_1H_2Fa = let m_2112_1H_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun i j k l -> array_4_init mo_num mo_num mo_num mo_num (fun i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_one i a Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Alfa +. h_one a i Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Alfa +.
h_one j a Spin.Alfa *. f_two i a k l Spin.Alfa Spin.Alfa +. h_one a j Spin.Alfa *. f_two i a k l Spin.Alfa Spin.Alfa +.
h_two i j a l Spin.Alfa Spin.Alfa *. f_one a k Spin.Alfa +. h_two a l i j Spin.Alfa Spin.Alfa *. f_one a k Spin.Alfa +.
h_two i j k a Spin.Alfa Spin.Alfa *. f_one a l Spin.Alfa +. h_two a k j i Spin.Alfa Spin.Alfa *. f_one a l Spin.Alfa +.
sum mos_in (fun m -> -. h_two i j a m Spin.Alfa Spin.Alfa *. sum mos_in (fun m -> -. h_two m a j i Spin.Alfa Spin.Alfa *.
f_two m a k l Spin.Alfa Spin.Alfa) +. f_two m a k l Spin.Alfa Spin.Alfa) +.
sum mos_cabs (fun b -> if b >= a then 0. else sum mos_cabs (fun b -> if b >= a then 0. else
h_two i j a b Spin.Alfa Spin.Alfa *. f_two a b k l Spin.Alfa Spin.Alfa h_two b a j i Spin.Alfa Spin.Alfa *. f_two b a l k Spin.Alfa Spin.Alfa
) )
) )
) )
@ -651,15 +648,15 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2112_1H_2Fb = let m_2112_1H_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun i j k l -> array_4_init mo_num mo_num mo_num mo_num (fun i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_one i a Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Beta +. h_one a i Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Beta +.
h_one j a Spin.Alfa *. f_two i a k l Spin.Alfa Spin.Beta +. h_one a j Spin.Alfa *. f_two a i l k Spin.Alfa Spin.Beta +.
h_two i j a l Spin.Alfa Spin.Beta *. f_one a k Spin.Alfa +. h_two a l i j Spin.Alfa Spin.Beta *. f_one a k Spin.Alfa +.
h_two i j k a Spin.Alfa Spin.Beta *. f_one a l Spin.Alfa +. h_two a k j i Spin.Alfa Spin.Beta *. f_one a l Spin.Alfa +.
sum mos_in (fun m -> sum mos_in (fun m ->
h_two i j a m Spin.Alfa Spin.Beta *. f_two a m k l Spin.Alfa Spin.Beta +. h_two m a j i Spin.Alfa Spin.Beta *. f_two m a l k Spin.Alfa Spin.Beta +.
h_two i j m a Spin.Alfa Spin.Beta *. f_two m a k l Spin.Alfa Spin.Beta ) +. h_two m a i j Spin.Alfa Spin.Beta *. f_two m a k l Spin.Alfa Spin.Beta ) +.
sum mos_cabs (fun b -> sum mos_cabs (fun b ->
h_two i j a b Spin.Alfa Spin.Beta *. f_two a b k l Spin.Alfa Spin.Beta h_two b a j i Spin.Alfa Spin.Beta *. f_two b a l k Spin.Alfa Spin.Beta
) )
) )
) )
@ -669,8 +666,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2112_2Ha_2Fa = let m_2112_2Ha_2Fa =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i n a n Spin.Alfa Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Alfa +. h_two a n i n Spin.Alfa Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Alfa +.
h_two j n a n Spin.Alfa Spin.Alfa *. f_two a i l k Spin.Alfa Spin.Alfa h_two a n j n Spin.Alfa Spin.Alfa *. f_two a i l k Spin.Alfa Spin.Alfa
) )
) )
in in
@ -679,8 +676,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2112_2Hb_2Fa = let m_2112_2Hb_2Fa =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i n a n Spin.Alfa Spin.Beta *. f_two a j k l Spin.Alfa Spin.Alfa +. h_two a n i n Spin.Alfa Spin.Beta *. f_two a j k l Spin.Alfa Spin.Alfa +.
h_two j n a n Spin.Alfa Spin.Beta *. f_two a i l k Spin.Alfa Spin.Alfa h_two a n j n Spin.Alfa Spin.Beta *. f_two a i l k Spin.Alfa Spin.Alfa
) )
) )
in in
@ -689,8 +686,9 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2112_2Ha_2Fb = let m_2112_2Ha_2Fb =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i n a n Spin.Alfa Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Beta +. h_two a n i n Spin.Alfa Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Beta +.
h_two j n a n Spin.Alfa Spin.Beta *. f_two a i l k Spin.Alfa Spin.Beta ) h_two a n j n Spin.Alfa Spin.Beta *. f_two a i l k Spin.Alfa Spin.Beta
)
) )
in in
@ -698,8 +696,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2121_2Ha_2Fa = let m_2121_2Ha_2Fa =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a l Spin.Alfa Spin.Alfa *. f_two a n k n Spin.Alfa Spin.Alfa +. h_two a l i j Spin.Alfa Spin.Alfa *. f_two a n k n Spin.Alfa Spin.Alfa +.
h_two j i a k Spin.Alfa Spin.Alfa *. f_two a n l n Spin.Alfa Spin.Alfa h_two a k j i Spin.Alfa Spin.Alfa *. f_two a n l n Spin.Alfa Spin.Alfa
) )
) )
in in
@ -708,8 +706,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2121_2Hb_2Fa = let m_2121_2Hb_2Fa =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a l Spin.Alfa Spin.Beta *. f_two a n k n Spin.Alfa Spin.Alfa +. h_two a l i j Spin.Alfa Spin.Beta *. f_two a n k n Spin.Alfa Spin.Alfa +.
h_two j i a k Spin.Alfa Spin.Beta *. f_two a n l n Spin.Alfa Spin.Beta h_two a k j i Spin.Alfa Spin.Beta *. f_two a n l n Spin.Alfa Spin.Beta
) )
) )
in in
@ -718,8 +716,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2121_2Ha_2Fb = let m_2121_2Ha_2Fb =
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i j a l Spin.Alfa Spin.Alfa *. f_two a n k n Spin.Alfa Spin.Beta +. h_two a l i j Spin.Alfa Spin.Alfa *. f_two a n k n Spin.Alfa Spin.Beta +.
h_two j i a k Spin.Alfa Spin.Alfa *. f_two a n l n Spin.Alfa Spin.Beta h_two a k j i Spin.Alfa Spin.Alfa *. f_two a n l n Spin.Alfa Spin.Beta
) )
) )
in in
@ -729,10 +727,10 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let s = Spin.Alfa in let s = Spin.Alfa in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two i n a k s s *. f_two j a n l s s h_two a k i n s s *. f_two a j l n s s
+. h_two i n a l s s *. f_two j a k n s s +. h_two a l i n s s *. f_two a j n k s s
-. h_two j n a k s s *. f_two i a n l s s -. h_two a k j n s s *. f_two a i l n s s
-. h_two j n a l s s *. f_two i a k n s s -. h_two a l j n s s *. f_two a i n k s s
) )
) )
in in
@ -742,9 +740,9 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
h_two n i a k s s *. f_two a j n l s s' h_two a k n i s s *. f_two a j n l s s'
+. h_two n j a l s s' *. f_two i a k n s s +. h_two a l n j s s' *. f_two a i n k s s
-. h_two n j k a s s' *. f_two i a n l s s' -. h_two a k j n s s' *. f_two a i l n s s'
) )
) )
in in
@ -754,13 +752,13 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a ->
-. h_two i n a l s s' *. f_two a j k n s s' +. -. h_two a l i n s s' *. f_two a j k n s s' +.
(if n < j then (if n < j then
h_two i n k a s s' *. f_two j a l n s' s' h_two a k n i s s' *. f_two a j n l s' s'
+. h_two n j a l s' s' *. f_two i a k n s s' +. h_two a l n j s' s' *. f_two a i n k s s'
else else
-. h_two i n k a s s' *. f_two j a n l s' s' -. h_two a k n i s s' *. f_two j a n l s' s'
-. h_two j n a l s' s' *. f_two i a k n s s' -. h_two a l j n s' s' *. f_two i a k n s s'
) )
) )
) )
@ -770,12 +768,10 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2122_2Ha_2Fa_ij2 = let m_2122_2Ha_2Fa_ij2 =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> sum mos_cabs (fun a -> h_two a k n i s s' *. f_two a j n l s s') +.
h_two i n k a s s' *. f_two j a l n s s' sum mos_cabs (fun a -> h_two a l n j s s' *. f_two a i n k s s') -.
+. h_two j n l a s s' *. f_two i a k n s s' sum mos_cabs (fun a -> h_two a l n i s s' *. f_two a j n k s s') -.
-. h_two i n l a s s' *. f_two j a k n s s' sum mos_cabs (fun a -> h_two a k n j s s' *. f_two a i n l s s')
-. h_two j n k a s s' *. f_two i a l n s s'
)
) )
in in
@ -783,21 +779,21 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2122_2Ha_2Fa_nv = let m_2122_2Ha_2Fa_nv =
let s = Spin.Alfa in let s = Spin.Alfa in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> h_two i j a n s s *. f_two n a k l s s ) ) sum mos_cabs (fun a -> h_two a n i j s s *. f_two a n l k s s ) )
in in
if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv\n" ; if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv\n" ;
let m_2122_2Hb_2Fb_nv = let m_2122_2Hb_2Fb_nv =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> -. h_two i j a n s s' *. f_two a n k l s s' ) ) sum mos_cabs (fun a -> -. h_two a n i j s s' *. f_two a n k l s s' ) )
in in
if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv2\n" ; if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv2\n" ;
let m_2122_2Hb_2Fb_nv2 = let m_2122_2Hb_2Fb_nv2 =
let s, s' = Spin.(Alfa, Beta) in let s, s' = Spin.(Alfa, Beta) in
array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l -> array_5_init mo_num mo_num mo_num mo_num mo_num (fun n i j k l ->
sum mos_cabs (fun a -> -. h_two i j n a s s' *. f_two n a k l s s' ) ) sum mos_cabs (fun a -> -. h_two a n j i s s' *. f_two a n l k s s' ) )
in in
let f_2 ki kj = let f_2 ki kj =