10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-19 20:42:22 +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)
;
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 f l =
@ -76,7 +76,7 @@ let array_4_init d1 d2 d3 d4 fx =
done)
;
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 f m =
@ -112,7 +112,7 @@ let array_5_init d1 d2 d3 d4 d5 fx =
done)
;
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 () =
@ -208,7 +208,7 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_0111_1H_1F =
Vec.init mo_num (fun i ->
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
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 =
array_3_init mo_num mo_num mo_num (fun i j k ->
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
let m_0111_1H_2Fa =
Mat.init_cols mo_num mo_num (fun i j ->
sum mos_cabs (fun a ->
h_one i a 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_one a i Spin.Alfa *. f_two a j i j Spin.Alfa Spin.Alfa +.
h_two a j i j Spin.Alfa Spin.Alfa *. f_one a i Spin.Alfa
) +.
if i < j then 0. else
begin
@ -242,7 +242,7 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_0111_2Ha_2Fa =
array_3_init mo_num mo_num mo_num (fun i j k ->
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
) -. 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 =
array_3_init mo_num mo_num mo_num (fun i j k ->
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
let m_0111_1H_2Fb =
Mat.init_cols mo_num mo_num (fun i j ->
sum mos_cabs (fun a ->
h_one i a 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_one j a 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_one a i Spin.Alfa *. f_two a j i j Spin.Alfa Spin.Beta +.
h_two a j i j Spin.Alfa Spin.Beta *. f_one a i Spin.Alfa +.
h_one a j Spin.Alfa *. f_two a i j i Spin.Alfa Spin.Beta +.
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_cabs (fun a ->
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 b ->
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 =
array_3_init mo_num mo_num mo_num (fun i j k ->
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 +.
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
) -. m_0122_Hab.{k,i,j}
)
@ -292,7 +292,7 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_0111_2Ha_2Fb =
array_3_init mo_num mo_num mo_num (fun i j k ->
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
)
)
@ -364,23 +364,22 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
if Parallel.master then Printf.printf "Computing m_1111_1H_1F\n" ;
let m_1111_1H_1F =
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
if Parallel.master then Printf.printf "Computing m_1111_2Ha_2Fa\n" ;
let m_1111_2Ha_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
if l=i then
sum mos_cabs (fun a ->
h_two j l a l Spin.Alfa Spin.Alfa *.
f_two a i j k Spin.Alfa Spin.Alfa
)
sum mos_cabs (fun a ->
h_two a l j l Spin.Alfa Spin.Alfa *.
f_two a i j k Spin.Alfa Spin.Alfa )
else
sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Alfa *.
f_two a l k l Spin.Alfa Spin.Alfa +.
h_two j l a l Spin.Alfa Spin.Alfa *.
f_two a i j k Spin.Alfa Spin.Alfa )
sum mos_cabs (fun a ->
h_two a j i j Spin.Alfa Spin.Alfa *.
f_two a l k 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 )
)
in
@ -388,17 +387,15 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1111_2Hb_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
if l=i then
sum mos_cabs (fun a ->
h_two j l a l Spin.Alfa Spin.Beta *.
f_two a i j k Spin.Alfa Spin.Beta
)
sum mos_cabs (fun a ->
h_two a l j l Spin.Alfa Spin.Beta *.
f_two a i j k Spin.Alfa Spin.Beta )
else
sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Beta *.
f_two a l k l Spin.Alfa Spin.Alfa +.
h_two j l a l Spin.Alfa Spin.Beta *.
f_two a i j k Spin.Alfa Spin.Beta
)
sum mos_cabs (fun a ->
h_two a j i j Spin.Alfa Spin.Beta *.
f_two a l k l Spin.Alfa Spin.Alfa +.
h_two a l j l Spin.Alfa Spin.Beta *.
f_two a i j k Spin.Alfa Spin.Beta )
)
in
@ -406,10 +403,10 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1111_2Ha_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Alfa *.
f_two a l k l Spin.Alfa Spin.Beta +.
h_two j l a l Spin.Alfa Spin.Beta *.
f_two a i j k Spin.Alfa Spin.Alfa
h_two a j i j Spin.Alfa Spin.Alfa *.
f_two a l k 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
)
)
in
@ -418,10 +415,10 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1111_2Hb_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a ->
h_two i j a j Spin.Alfa Spin.Beta *.
f_two a l k l Spin.Alfa Spin.Beta +.
h_two j l a l Spin.Alfa Spin.Alfa *.
f_two a i j k Spin.Alfa Spin.Beta
h_two a j i j Spin.Alfa Spin.Beta *.
f_two a l k l Spin.Alfa Spin.Beta +.
h_two a l j l Spin.Alfa Spin.Alfa *.
f_two a i j k Spin.Alfa Spin.Beta
)
)
in
@ -430,8 +427,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1121_2Ha_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a ->
h_two i j k a Spin.Alfa Spin.Alfa *.
f_two l a l j Spin.Alfa Spin.Alfa
h_two a k j i Spin.Alfa Spin.Alfa *.
f_two a l j l Spin.Alfa Spin.Alfa
)
)
in
@ -440,8 +437,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1121_2Hb_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a ->
h_two i j k a Spin.Alfa Spin.Beta *.
f_two l a l j Spin.Alfa Spin.Alfa
h_two a k j i Spin.Alfa Spin.Beta *.
f_two a l j l Spin.Alfa Spin.Alfa
)
)
in
@ -450,8 +447,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1121_2Ha_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a ->
h_two i j k a Spin.Alfa Spin.Alfa *.
f_two l a l j Spin.Alfa Spin.Beta
h_two a k j i Spin.Alfa Spin.Alfa *.
f_two a l j l Spin.Alfa Spin.Beta
)
)
in
@ -460,8 +457,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1121_2Hb_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a ->
h_two i j k a Spin.Alfa Spin.Beta *.
f_two l a l j Spin.Alfa Spin.Beta
h_two a k j i Spin.Alfa Spin.Beta *.
f_two a l j l Spin.Alfa Spin.Beta
)
)
in
@ -470,8 +467,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1122_va =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a ->
h_two j i a l Spin.Alfa Spin.Alfa *.
f_two l a k j Spin.Alfa Spin.Alfa
h_two a l j i Spin.Alfa Spin.Alfa *.
f_two a l j k Spin.Alfa Spin.Alfa
)
)
in
@ -479,16 +476,16 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
if Parallel.master then Printf.printf "Computing m_1111_1H_2Fa\n" ;
let m_1111_1H_2Fa =
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_cabs (fun a ->
h_one i a 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_one j a 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 +.
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 j Spin.Alfa Spin.Alfa )
)
sum mos_in (fun l -> m_1122_va.{l,j,i,k}) +.
sum mos_cabs (fun a ->
h_one a i Spin.Alfa *. f_two a j k j Spin.Alfa Spin.Alfa +.
h_two a j i j Spin.Alfa Spin.Alfa *. f_one a k Spin.Alfa +.
h_one a j Spin.Alfa *. f_two a i j k Spin.Alfa 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
h_two b a j i Spin.Alfa Spin.Alfa *.
f_two b a j k Spin.Alfa Spin.Alfa )
)
)
in
@ -496,8 +493,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1122_v2 =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a ->
h_two i j l a Spin.Alfa Spin.Beta *.
f_two l a k j Spin.Alfa Spin.Beta
h_two a l j i Spin.Alfa Spin.Beta *.
f_two a l j k Spin.Alfa Spin.Beta
)
)
in
@ -506,7 +503,7 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1122_v3 =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
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
)
)
@ -515,17 +512,17 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
if Parallel.master then Printf.printf "Computing m_1111_1H_2Fb\n" ;
let m_1111_1H_2Fb =
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_cabs (fun a ->
h_one i a 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_one j a 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 +.
sum mos_cabs (fun b ->
h_two i j a b Spin.Alfa Spin.Beta *.
f_two a b k j Spin.Alfa Spin.Beta
)
)
sum mos_in (fun l -> m_1122_v2.{l,j,i,k} +. m_1122_v3.{l,j,i,k}) +.
sum mos_cabs (fun a ->
h_one a i Spin.Alfa *. f_two a j k j Spin.Alfa Spin.Beta +.
h_two a j i j Spin.Alfa Spin.Beta *. f_one a k Spin.Alfa +.
h_one a j Spin.Beta *. f_two a i j k Spin.Alfa Spin.Beta +.
h_two a k j i Spin.Alfa Spin.Beta *. f_one a j Spin.Beta +.
sum mos_cabs (fun b ->
h_two b a j i Spin.Alfa Spin.Beta *.
f_two b a j k Spin.Alfa Spin.Beta
)
)
)
in
@ -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 ->
if l > j then
sum mos_cabs (fun a ->
h_two j l a k Spin.Alfa Spin.Alfa *.
f_two i a l j Spin.Alfa Spin.Alfa
h_two a k j l Spin.Alfa Spin.Alfa *.
f_two a i j l Spin.Alfa Spin.Alfa
)
else 0.
)
@ -545,8 +542,8 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_1122_o =
array_4_init mo_num mo_num mo_num mo_num (fun l j i k ->
sum mos_cabs (fun a ->
h_two l j k a Spin.Alfa Spin.Beta *.
f_two i a l j Spin.Alfa Spin.Beta
h_two a k j l Spin.Alfa Spin.Beta *.
f_two a i j l Spin.Alfa Spin.Beta
)
)
in
@ -634,16 +631,16 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2112_1H_2Fa =
array_4_init mo_num mo_num mo_num mo_num (fun i j k l ->
sum mos_cabs (fun a ->
h_one i a 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_two i j a l 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 +.
sum mos_in (fun m -> -. h_two i j a m 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
h_two i j a b Spin.Alfa Spin.Alfa *. f_two a b k l Spin.Alfa Spin.Alfa
)
)
h_one a i Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Alfa +.
h_one a j Spin.Alfa *. f_two i a k l Spin.Alfa Spin.Alfa +.
h_two a l i j Spin.Alfa Spin.Alfa *. f_one a k 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 m a j i 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
h_two b a j i Spin.Alfa Spin.Alfa *. f_two b a l k Spin.Alfa Spin.Alfa
)
)
)
in
@ -651,17 +648,17 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2112_1H_2Fb =
array_4_init mo_num mo_num mo_num mo_num (fun i j k l ->
sum mos_cabs (fun a ->
h_one i a 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_two i j a l 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 +.
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 i j m a Spin.Alfa Spin.Beta *. f_two m a k l Spin.Alfa Spin.Beta ) +.
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_one a i Spin.Alfa *. f_two a j k l Spin.Alfa Spin.Beta +.
h_one a j Spin.Alfa *. f_two a i l k Spin.Alfa Spin.Beta +.
h_two a l i j Spin.Alfa Spin.Beta *. f_one a k Spin.Alfa +.
h_two a k j i Spin.Alfa Spin.Beta *. f_one a l Spin.Alfa +.
sum mos_in (fun m ->
h_two m a j i Spin.Alfa Spin.Beta *. f_two m a l k 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 ->
h_two b a j i Spin.Alfa Spin.Beta *. f_two b a l k Spin.Alfa Spin.Beta
)
)
)
in
@ -669,38 +666,39 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2112_2Ha_2Fa =
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 n a 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 i n Spin.Alfa Spin.Alfa *. f_two a j k l 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
if Parallel.master then Printf.printf "Computing m_2112_2Hb_2Fa\n" ;
let m_2112_2Hb_2Fa =
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 n a 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
)
sum mos_cabs (fun a ->
h_two a n i n Spin.Alfa Spin.Beta *. f_two a j k l 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
if Parallel.master then Printf.printf "Computing m_2112_2Ha_2Fb\n" ;
let m_2112_2Ha_2Fb =
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 n a 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 )
sum mos_cabs (fun a ->
h_two a n i n Spin.Alfa Spin.Alfa *. f_two a j k l 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
if Parallel.master then Printf.printf "Computing m_2121_2Ha_2Fa\n" ;
let m_2121_2Ha_2Fa =
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 l 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 l i j Spin.Alfa Spin.Alfa *. f_two a n k 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
@ -708,9 +706,9 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2121_2Hb_2Fa =
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 l 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 l i j Spin.Alfa Spin.Beta *. f_two a n k n Spin.Alfa Spin.Alfa +.
h_two a k j i Spin.Alfa Spin.Beta *. f_two a n l n Spin.Alfa Spin.Beta
)
)
in
@ -718,9 +716,9 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2121_2Ha_2Fb =
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 l 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 l i j Spin.Alfa Spin.Alfa *. f_two a n k 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
@ -729,11 +727,11 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let s = Spin.Alfa in
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 n a k s s *. f_two j a n l s s
+. h_two i n a l s s *. f_two j a k n s s
-. h_two j n a k s s *. f_two i a n l s s
-. h_two j n a l s s *. f_two i a k n s s
)
h_two a k i n s s *. f_two a j l n s s
+. h_two a l i n s s *. f_two a j n k s s
-. h_two a k j n s s *. f_two a i l n s s
-. h_two a l j n s s *. f_two a i n k s s
)
)
in
@ -742,9 +740,9 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
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 ->
sum mos_cabs (fun a ->
h_two n i a k 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 n j k a s s' *. f_two i a n l s s'
h_two a k n i s s *. f_two a j n l s s'
+. h_two a l n j s s' *. f_two a i n k s s
-. h_two a k j n s s' *. f_two a i l n s s'
)
)
in
@ -753,15 +751,15 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2122_2Hb_2Fb_ij2 =
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 ->
sum mos_cabs (fun a ->
-. h_two i n a l s s' *. f_two a j k n s s' +.
(if n < j then
h_two i n k a s s' *. f_two j a l n s' s'
+. h_two n j a l s' s' *. f_two i a k n s s'
else
-. h_two i n k a 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'
)
sum mos_cabs (fun a ->
-. h_two a l i n s s' *. f_two a j k n s s' +.
(if n < j then
h_two a k n i s s' *. f_two a j n l s' s'
+. h_two a l n j s' s' *. f_two a i n k s s'
else
-. h_two a k n i s s' *. f_two j a n l s' s'
-. h_two a l j n s' s' *. f_two i a k n s s'
)
)
)
in
@ -770,12 +768,10 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2122_2Ha_2Fa_ij2 =
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 ->
sum mos_cabs (fun a ->
h_two i n k a s s' *. f_two j a l n s s'
+. h_two j n l a s s' *. f_two i a k n s s'
-. h_two i n l a s s' *. f_two j a k n s s'
-. h_two j n k a s s' *. f_two i a l n s s'
)
sum mos_cabs (fun a -> h_two a k n i s s' *. f_two a j n l s s') +.
sum mos_cabs (fun a -> h_two a l n j s s' *. f_two a i n k s s') -.
sum mos_cabs (fun a -> h_two a l n i s s' *. f_two a j n k s s') -.
sum mos_cabs (fun a -> h_two a k n j s s' *. f_two a i n l s s')
)
in
@ -783,21 +779,21 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
let m_2122_2Ha_2Fa_nv =
let s = Spin.Alfa in
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
if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv\n" ;
let m_2122_2Hb_2Fb_nv =
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 ->
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
if Parallel.master then Printf.printf "Computing m_2122_2Hb_2Fb_nv2\n" ;
let m_2122_2Hb_2Fb_nv2 =
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 ->
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
let f_2 ki kj =