10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-06-26 15:12:05 +02:00

Indentation

This commit is contained in:
Anthony Scemama 2018-02-03 19:01:30 +01:00
parent 687c023284
commit 5e87c5edef
4 changed files with 513 additions and 512 deletions

View File

@ -25,10 +25,6 @@ let zero_m ~maxm ~expo_pq_inv ~norm_pq_sq =
(** Compute all the integrals of a contracted class *)
(*
let contracted_class shell_a shell_b shell_c shell_d : float Zmap.t =
TwoElectronRRVectorized.contracted_class ~zero_m shell_a shell_b shell_c shell_d
*)
let contracted_class shell_a shell_b shell_c shell_d : float Zmap.t =
TwoElectronRR.contracted_class ~zero_m shell_a shell_b shell_c shell_d
@ -41,9 +37,6 @@ let contracted_class_shell_pairs ?schwartz_p ?schwartz_q shell_p shell_q : float
let cutoff2 = cutoff *. cutoff
(*
type n_cls = { n : int ; cls : Z.t array }
*)
exception NullIntegral
(*
@ -94,8 +87,8 @@ let to_file ~filename basis =
print_int basis.(i).Contracted_shell.indice ; print_newline ();
for j=0 to i do
let schwartz_p, schwartz_p_max = schwartz.(i).(j) in
if (schwartz_p_max >= cutoff) then
icount := !icount + 1;
if (schwartz_p_max >= cutoff) then
icount := !icount + 1;
done;
done;
Printf.printf "%d shell pairs computed in %f seconds\n" !icount (Unix.gettimeofday () -. t0);
@ -130,63 +123,71 @@ let to_file ~filename basis =
for l=0 to k do
let schwartz_q, schwartz_q_max = schwartz.(k).(l) in
try
if schwartz_p_max *. schwartz_q_max < cutoff2 then
raise NullIntegral;
let
shell_q = shell_pairs.(k).(l)
in
if schwartz_p_max *. schwartz_q_max < cutoff2 then
raise NullIntegral;
let
shell_q = shell_pairs.(k).(l)
in
let swap =
Array.length shell_q < Array.length shell_p
in
let swap =
Array.length shell_q < Array.length shell_p
in
(* Compute all the integrals of the class *)
let cls =
if swap then
if Array.length shell_p < 2 then
contracted_class_shell_pairs ~schwartz_p:schwartz_q ~schwartz_q:schwartz_p shell_q shell_p
(* Compute all the integrals of the class *)
let cls =
if swap then
if Array.length shell_p < 2 then
contracted_class_shell_pairs
~schwartz_p:schwartz_q ~schwartz_q:schwartz_p
shell_q shell_p
else
contracted_class_shell_pairs_vec
~schwartz_p:schwartz_q ~schwartz_q:schwartz_p
shell_q shell_p
else
contracted_class_shell_pairs_vec ~schwartz_p:schwartz_q ~schwartz_q:schwartz_p shell_q shell_p
else
if Array.length shell_q < 2 then
contracted_class_shell_pairs ~schwartz_p ~schwartz_q shell_p shell_q
contracted_class_shell_pairs
~schwartz_p ~schwartz_q
shell_p shell_q
else
contracted_class_shell_pairs_vec ~schwartz_p ~schwartz_q shell_p shell_q
in
contracted_class_shell_pairs_vec
~schwartz_p ~schwartz_q
shell_p shell_q
in
(* Write the data in the output file *)
Array.iteri (fun i_c powers_i ->
let i_c = basis.(i).Contracted_shell.indice + i_c + 1 in
let xi = to_int_tuple powers_i in
Array.iteri (fun j_c powers_j ->
let j_c = basis.(j).Contracted_shell.indice + j_c + 1 in
let xj = to_int_tuple powers_j in
Array.iteri (fun k_c powers_k ->
let k_c = basis.(k).Contracted_shell.indice + k_c + 1 in
let xk = to_int_tuple powers_k in
Array.iteri (fun l_c powers_l ->
let l_c = basis.(l).Contracted_shell.indice + l_c + 1 in
let xl = to_int_tuple powers_l in
let key =
if swap then
Zkey.of_int_tuple (Zkey.Twelve (xk,xl,xi,xj))
(* Write the data in the output file *)
Array.iteri (fun i_c powers_i ->
let i_c = basis.(i).Contracted_shell.indice + i_c + 1 in
let xi = to_int_tuple powers_i in
Array.iteri (fun j_c powers_j ->
let j_c = basis.(j).Contracted_shell.indice + j_c + 1 in
let xj = to_int_tuple powers_j in
Array.iteri (fun k_c powers_k ->
let k_c = basis.(k).Contracted_shell.indice + k_c + 1 in
let xk = to_int_tuple powers_k in
Array.iteri (fun l_c powers_l ->
let l_c = basis.(l).Contracted_shell.indice + l_c + 1 in
let xl = to_int_tuple powers_l in
let key =
if swap then
Zkey.of_int_tuple (Zkey.Twelve (xk,xl,xi,xj))
else
Zkey.of_int_tuple (Zkey.Twelve (xi,xj,xk,xl))
in
let value =
Zmap.find cls key
in
if (abs_float value > cutoff) then
(inn := !inn + 1;
eri_array.{(i_c-1),(k_c-1),(j_c-1),(l_c-1)} <- value;
)
else
Zkey.of_int_tuple (Zkey.Twelve (xi,xj,xk,xl))
in
let value =
Zmap.find cls key
in
if (abs_float value > cutoff) then
(inn := !inn + 1;
eri_array.{(i_c-1),(k_c-1),(j_c-1),(l_c-1)} <- value;
)
else
out := !out + 1;
) basis.(l).Contracted_shell.powers
) basis.(k).Contracted_shell.powers
) basis.(j).Contracted_shell.powers
) basis.(i).Contracted_shell.powers;
with NullIntegral -> ()
out := !out + 1;
) basis.(l).Contracted_shell.powers
) basis.(k).Contracted_shell.powers
) basis.(j).Contracted_shell.powers
) basis.(i).Contracted_shell.powers;
with NullIntegral -> ()
done;
done;
with NullIntegral -> ()
@ -197,15 +198,15 @@ let to_file ~filename basis =
(* Print ERIs *)
for i_c=1 to (Genarray.nth_dim eri_array 0) do
for j_c=1 to (Genarray.nth_dim eri_array 2) do
for k_c=1 to (Genarray.nth_dim eri_array 1) do
for l_c=1 to (Genarray.nth_dim eri_array 3) do
let value = eri_array.{(i_c-1),(k_c-1),(j_c-1),(l_c-1)} in
if (value <> 0.) then
Printf.fprintf oc " %5d %5d %5d %5d%20.15f\n" i_c k_c j_c l_c value;
done;
for j_c=1 to (Genarray.nth_dim eri_array 2) do
for k_c=1 to (Genarray.nth_dim eri_array 1) do
for l_c=1 to (Genarray.nth_dim eri_array 3) do
let value = eri_array.{(i_c-1),(k_c-1),(j_c-1),(l_c-1)} in
if (value <> 0.) then
Printf.fprintf oc " %5d %5d %5d %5d%20.15f\n" i_c k_c j_c l_c value;
done;
done;
done;
done;
done;
Printf.printf "In: %d Out:%d\n" !inn !out ;
close_out oc

View File

@ -33,19 +33,19 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
Printf.printf "%d %d %d\n" angMom_c.(0) angMom_c.(1) angMom_c.(2) ;
Printf.printf "%d %d %d\n" angMom_d.(0) angMom_d.(1) angMom_d.(2) ;
Printf.printf "%f %f %f %f\n%f %f %f\n%f %f %f\n%f %f %f\n" expo_b expo_d
expo_inv_p expo_inv_q
(Coordinate.coord center_ab 0) (Coordinate.coord center_ab 1) (Coordinate.coord center_ab 2)
(Coordinate.coord center_cd 0) (Coordinate.coord center_cd 1) (Coordinate.coord center_cd 2)
(Coordinate.coord center_pq 0) (Coordinate.coord center_pq 1) (Coordinate.coord center_pq 2)
expo_inv_p expo_inv_q
(Coordinate.coord center_ab 0) (Coordinate.coord center_ab 1) (Coordinate.coord center_ab 2)
(Coordinate.coord center_cd 0) (Coordinate.coord center_cd 1) (Coordinate.coord center_cd 2)
(Coordinate.coord center_pq 0) (Coordinate.coord center_pq 1) (Coordinate.coord center_pq 2)
end;
(** Vertical recurrence relations *)
let rec vrr0 angMom_a totAngMom_a =
if debug then
begin
let (x,y,z) = angMom_a in
Printf.printf "vrr0: %d : %d %d %d\n" totAngMom_a x y z
end;
begin
let (x,y,z) = angMom_a in
Printf.printf "vrr0: %d : %d %d %d\n" totAngMom_a x y z
end;
match totAngMom_a with
| 0 -> zero_m_array
@ -55,47 +55,47 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
try Zmap.find map_1d key with
| Not_found ->
let result =
let am, amm, amxyz, xyz =
match angMom_a with
| (x,0,0) -> (x-1,0,0),(x-2,0,0), x-1, 0
| (x,y,0) -> (x,y-1,0),(x,y-2,0), y-1, 1
| (x,y,z) -> (x,y,z-1),(x,y,z-2), z-1, 2
in
if amxyz < 0 then empty else
let v1 =
vrr0 am (totAngMom_a-1)
in
let f1 = expo_inv_p *. (Coordinate.coord center_pq xyz)
and f2 = expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz)
in
if amxyz < 1 then
Array.init maxsze (fun m ->
if m = maxm then 0. else (f1 *. v1.(m+1) ) -. f2 *. v1.(m) )
else
let f3 = (float_of_int amxyz) *. expo_inv_p *. 0.5 in
let v3 =
vrr0 amm (totAngMom_a-2)
in
Array.init maxsze (fun m ->
(if m = maxm then 0. else
(f1 *. v1.(m+1) ) -. f2 *. v1.(m) )
+. f3 *. (v3.(m) +. if m = maxm then 0. else
expo_inv_p *. v3.(m+1))
)
in Zmap.add map_1d key result;
result
let result =
let am, amm, amxyz, xyz =
match angMom_a with
| (x,0,0) -> (x-1,0,0),(x-2,0,0), x-1, 0
| (x,y,0) -> (x,y-1,0),(x,y-2,0), y-1, 1
| (x,y,z) -> (x,y,z-1),(x,y,z-2), z-1, 2
in
if amxyz < 0 then empty else
let v1 =
vrr0 am (totAngMom_a-1)
in
let f1 = expo_inv_p *. (Coordinate.coord center_pq xyz)
and f2 = expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz)
in
if amxyz < 1 then
Array.init maxsze (fun m ->
if m = maxm then 0. else (f1 *. v1.(m+1) ) -. f2 *. v1.(m) )
else
let f3 = (float_of_int amxyz) *. expo_inv_p *. 0.5 in
let v3 =
vrr0 amm (totAngMom_a-2)
in
Array.init maxsze (fun m ->
(if m = maxm then 0. else
(f1 *. v1.(m+1) ) -. f2 *. v1.(m) )
+. f3 *. (v3.(m) +. if m = maxm then 0. else
expo_inv_p *. v3.(m+1))
)
in Zmap.add map_1d key result;
result
and vrr angMom_a angMom_c totAngMom_a totAngMom_c =
if debug then
begin
let angMom_ax, angMom_ay, angMom_az = angMom_a in
let angMom_cx, angMom_cy, angMom_cz = angMom_c in
Printf.printf "vrr : %d %d : %d %d %d %d %d %d\n" totAngMom_a totAngMom_c
angMom_ax angMom_ay angMom_az angMom_cx angMom_cy angMom_cz
end;
begin
let angMom_ax, angMom_ay, angMom_az = angMom_a in
let angMom_cx, angMom_cy, angMom_cz = angMom_c in
Printf.printf "vrr : %d %d : %d %d %d %d %d %d\n" totAngMom_a totAngMom_c
angMom_ax angMom_ay angMom_az angMom_cx angMom_cy angMom_cz
end;
match (totAngMom_a, totAngMom_c) with
| (i,0) -> if (i>0) then vrr0 angMom_a totAngMom_a else zero_m_array
@ -104,71 +104,71 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
try Zmap.find map_2d key with
| Not_found ->
let result =
let am, cm, cmm, axyz, cmxyz, xyz =
let angMom_ax, angMom_ay, angMom_az = angMom_a
and angMom_cx, angMom_cy, angMom_cz = angMom_c in
match angMom_c with
| (_,0,0) -> (* 321_984 *)
(angMom_ax-1, angMom_ay, angMom_az),
(angMom_cx-1, angMom_cy, angMom_cz),
(angMom_cx-2, angMom_cy, angMom_cz),
angMom_ax,angMom_cx-1, 0
| (_,_,0) -> (* 612_002 *)
(angMom_ax, angMom_ay-1, angMom_az),
(angMom_cx, angMom_cy-1, angMom_cz),
(angMom_cx, angMom_cy-2, angMom_cz),
angMom_ay,angMom_cy-1, 1
| _ -> (* 1_067_324 *)
(angMom_ax, angMom_ay, angMom_az-1),
(angMom_cx, angMom_cy, angMom_cz-1),
(angMom_cx, angMom_cy, angMom_cz-2),
angMom_az,angMom_cz-1, 2
in
if cmxyz < 0 then empty else
let f1 =
-. expo_d *. expo_inv_q *. (Coordinate.coord center_cd xyz)
in
let f2 =
expo_inv_q *. (Coordinate.coord center_pq xyz)
in
let result =
let am, cm, cmm, axyz, cmxyz, xyz =
let angMom_ax, angMom_ay, angMom_az = angMom_a
and angMom_cx, angMom_cy, angMom_cz = angMom_c in
match angMom_c with
| (_,0,0) -> (* 321_984 *)
(angMom_ax-1, angMom_ay, angMom_az),
(angMom_cx-1, angMom_cy, angMom_cz),
(angMom_cx-2, angMom_cy, angMom_cz),
angMom_ax,angMom_cx-1, 0
| (_,_,0) -> (* 612_002 *)
(angMom_ax, angMom_ay-1, angMom_az),
(angMom_cx, angMom_cy-1, angMom_cz),
(angMom_cx, angMom_cy-2, angMom_cz),
angMom_ay,angMom_cy-1, 1
| _ -> (* 1_067_324 *)
(angMom_ax, angMom_ay, angMom_az-1),
(angMom_cx, angMom_cy, angMom_cz-1),
(angMom_cx, angMom_cy, angMom_cz-2),
angMom_az,angMom_cz-1, 2
in
if cmxyz < 0 then empty else
let f1 =
-. expo_d *. expo_inv_q *. (Coordinate.coord center_cd xyz)
in
let f2 =
expo_inv_q *. (Coordinate.coord center_pq xyz)
in
let result =
if ( (abs_float f1 < cutoff) && (abs_float f2 < cutoff) ) then empty else
let v1 =
vrr angMom_a cm totAngMom_a (totAngMom_c-1)
in
Array.init maxsze (fun m ->
f1 *. v1.(m) -. (if m = maxm then 0. else f2 *. v1.(m+1)) )
in
let result =
if cmxyz < 1 then result else
let f3 =
(float_of_int cmxyz) *. expo_inv_q *. 0.5
in
if (abs_float f3 < cutoff) && (abs_float (f3 *. expo_inv_q) < cutoff) then result else
(
let v3 =
vrr angMom_a cmm totAngMom_a (totAngMom_c-2)
in
Array.init maxsze (fun m -> result.(m) +.
f3 *. (v3.(m) +. (if m=maxm then 0. else expo_inv_q *. v3.(m+1)) ))
)
in
let result =
if (axyz < 1) || (cmxyz < 0) then result else
let f5 =
(float_of_int axyz) *. expo_inv_p *. expo_inv_q *. 0.5
in
if (abs_float f5 < cutoff) then result else
let v5 =
vrr am cm (totAngMom_a-1) (totAngMom_c-1)
in
Array.init (maxsze) (fun m ->
result.(m) -. (if m = maxm then 0. else f5 *. v5.(m+1)))
in
result
in Zmap.add map_2d key result;
result
if ( (abs_float f1 < cutoff) && (abs_float f2 < cutoff) ) then empty else
let v1 =
vrr angMom_a cm totAngMom_a (totAngMom_c-1)
in
Array.init maxsze (fun m ->
f1 *. v1.(m) -. (if m = maxm then 0. else f2 *. v1.(m+1)) )
in
let result =
if cmxyz < 1 then result else
let f3 =
(float_of_int cmxyz) *. expo_inv_q *. 0.5
in
if (abs_float f3 < cutoff) && (abs_float (f3 *. expo_inv_q) < cutoff) then result else
(
let v3 =
vrr angMom_a cmm totAngMom_a (totAngMom_c-2)
in
Array.init maxsze (fun m -> result.(m) +.
f3 *. (v3.(m) +. (if m=maxm then 0. else expo_inv_q *. v3.(m+1)) ))
)
in
let result =
if (axyz < 1) || (cmxyz < 0) then result else
let f5 =
(float_of_int axyz) *. expo_inv_p *. expo_inv_q *. 0.5
in
if (abs_float f5 < cutoff) then result else
let v5 =
vrr am cm (totAngMom_a-1) (totAngMom_c-1)
in
Array.init (maxsze) (fun m ->
result.(m) -. (if m = maxm then 0. else f5 *. v5.(m+1)))
in
result
in Zmap.add map_2d key result;
result
@ -179,88 +179,88 @@ let hvrr_two_e (angMom_a, angMom_b, angMom_c, angMom_d)
totAngMom_a totAngMom_b totAngMom_c =
if debug then
begin
let angMom_ax, angMom_ay, angMom_az = angMom_a
and angMom_bx, angMom_by, angMom_bz = angMom_b
and angMom_cx, angMom_cy, angMom_cz = angMom_c in
Printf.printf "hrr0: %d %d %d : %d %d %d %d %d %d %d %d %d\n"
totAngMom_a totAngMom_b totAngMom_c
angMom_ax angMom_ay angMom_az
angMom_bx angMom_by angMom_bz
angMom_cx angMom_cy angMom_cz
end;
begin
let angMom_ax, angMom_ay, angMom_az = angMom_a
and angMom_bx, angMom_by, angMom_bz = angMom_b
and angMom_cx, angMom_cy, angMom_cz = angMom_c in
Printf.printf "hrr0: %d %d %d : %d %d %d %d %d %d %d %d %d\n"
totAngMom_a totAngMom_b totAngMom_c
angMom_ax angMom_ay angMom_az
angMom_bx angMom_by angMom_bz
angMom_cx angMom_cy angMom_cz
end;
match totAngMom_b with
| 0 -> (vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0)
| 1 ->
let angMom_ax, angMom_ay, angMom_az = angMom_a in
let ap, xyz =
match angMom_b with
| (1,_,_) -> (angMom_ax+1,angMom_ay,angMom_az), 0
| (_,1,_) -> (angMom_ax,angMom_ay+1,angMom_az), 1
| _ -> (angMom_ax,angMom_ay,angMom_az+1), 2
in
let v1 =
vrr ap angMom_c (totAngMom_a+1) totAngMom_c
in
let f2 =
(Coordinate.coord center_ab xyz)
in
if (abs_float f2 < cutoff) then v1.(0) else
let v2 =
vrr angMom_a angMom_c totAngMom_a totAngMom_c
in
v1.(0) +. f2 *. v2.(0)
| _ ->
let angMom_ax, angMom_ay, angMom_az = angMom_a
and angMom_bx, angMom_by, angMom_bz = angMom_b in
let bxyz, xyz =
match angMom_b with
| (_,0,0) -> angMom_bx, 0
| (_,_,0) -> angMom_by, 1
| (_,_,_) -> angMom_bz, 2
let angMom_ax, angMom_ay, angMom_az = angMom_a in
let ap, xyz =
match angMom_b with
| (1,_,_) -> (angMom_ax+1,angMom_ay,angMom_az), 0
| (_,1,_) -> (angMom_ax,angMom_ay+1,angMom_az), 1
| _ -> (angMom_ax,angMom_ay,angMom_az+1), 2
in
let v1 =
vrr ap angMom_c (totAngMom_a+1) totAngMom_c
in
let f2 =
(Coordinate.coord center_ab xyz)
in
if (abs_float f2 < cutoff) then v1.(0) else
let v2 =
vrr angMom_a angMom_c totAngMom_a totAngMom_c
in
if (bxyz < 1) then 0. else
let ap, bm =
match xyz with
| 0 -> (angMom_ax+1,angMom_ay,angMom_az),(angMom_bx-1,angMom_by,angMom_bz)
| 1 -> (angMom_ax,angMom_ay+1,angMom_az),(angMom_bx,angMom_by-1,angMom_bz)
| _ -> (angMom_ax,angMom_ay,angMom_az+1),(angMom_bx,angMom_by,angMom_bz-1)
v1.(0) +. f2 *. v2.(0)
| _ ->
let angMom_ax, angMom_ay, angMom_az = angMom_a
and angMom_bx, angMom_by, angMom_bz = angMom_b in
let bxyz, xyz =
match angMom_b with
| (_,0,0) -> angMom_bx, 0
| (_,_,0) -> angMom_by, 1
| (_,_,_) -> angMom_bz, 2
in
if (bxyz < 1) then 0. else
let ap, bm =
match xyz with
| 0 -> (angMom_ax+1,angMom_ay,angMom_az),(angMom_bx-1,angMom_by,angMom_bz)
| 1 -> (angMom_ax,angMom_ay+1,angMom_az),(angMom_bx,angMom_by-1,angMom_bz)
| _ -> (angMom_ax,angMom_ay,angMom_az+1),(angMom_bx,angMom_by,angMom_bz-1)
in
let h1 =
hrr0 ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c
in
let f2 =
(Coordinate.coord center_ab xyz)
in
if (abs_float f2 < cutoff) then h1 else
let h2 =
hrr0 angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
in
let h1 =
hrr0 ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c
in
let f2 =
(Coordinate.coord center_ab xyz)
in
if (abs_float f2 < cutoff) then h1 else
let h2 =
hrr0 angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
in
h1 +. f2 *. h2
h1 +. f2 *. h2
and hrr angMom_a angMom_b angMom_c angMom_d
totAngMom_a totAngMom_b totAngMom_c totAngMom_d =
if debug then
begin
let angMom_ax, angMom_ay, angMom_az = angMom_a in
let angMom_bx, angMom_by, angMom_bz = angMom_b in
let angMom_cx, angMom_cy, angMom_cz = angMom_c in
let angMom_dx, angMom_dy, angMom_dz = angMom_d in
Printf.printf "hrr : %d %d %d %d : %d %d %d %d %d %d %d %d %d %d %d %d\n"
totAngMom_a totAngMom_b totAngMom_c totAngMom_d
angMom_ax angMom_ay angMom_az
angMom_bx angMom_by angMom_bz
angMom_cx angMom_cy angMom_cz
angMom_dx angMom_dy angMom_dz
end;
begin
let angMom_ax, angMom_ay, angMom_az = angMom_a in
let angMom_bx, angMom_by, angMom_bz = angMom_b in
let angMom_cx, angMom_cy, angMom_cz = angMom_c in
let angMom_dx, angMom_dy, angMom_dz = angMom_d in
Printf.printf "hrr : %d %d %d %d : %d %d %d %d %d %d %d %d %d %d %d %d\n"
totAngMom_a totAngMom_b totAngMom_c totAngMom_d
angMom_ax angMom_ay angMom_az
angMom_bx angMom_by angMom_bz
angMom_cx angMom_cy angMom_cz
angMom_dx angMom_dy angMom_dz
end;
match (totAngMom_b, totAngMom_d) with
| (_,0) -> if (totAngMom_b = 0) then
(vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0)
else
hrr0 angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
(vrr angMom_a angMom_c totAngMom_a totAngMom_c).(0)
else
hrr0 angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
| (_,_) ->
let (angMom_cx, angMom_cy, angMom_cz) = angMom_c
and (angMom_dx, angMom_dy, angMom_dz) = angMom_d in
@ -342,45 +342,45 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
in
let zero_m_array =
zero_m ~maxm ~expo_pq_inv ~norm_pq_sq
zero_m ~maxm ~expo_pq_inv ~norm_pq_sq
in
begin
match Contracted_shell.(totAngMom shell_a, totAngMom shell_b,
totAngMom shell_c, totAngMom shell_d) with
| Angular_momentum.(S,S,S,S) ->
let integral =
zero_m_array.(0)
in
contracted_class.(0) <- contracted_class.(0) +. coef_prod *. integral
let integral =
zero_m_array.(0)
in
contracted_class.(0) <- contracted_class.(0) +. coef_prod *. integral
| _ ->
let d = shell_q.(cd).Shell_pair.j in
let map_1d = Zmap.create (4*maxm) in
let map_2d = Zmap.create (Array.length class_indices) in
let norm_coef_scale_q = shell_q.(cd).Shell_pair.norm_coef_scale in
let norm_coef_scale =
Array.map (fun v1 ->
let d = shell_q.(cd).Shell_pair.j in
let map_1d = Zmap.create (4*maxm) in
let map_2d = Zmap.create (Array.length class_indices) in
let norm_coef_scale_q = shell_q.(cd).Shell_pair.norm_coef_scale in
let norm_coef_scale =
Array.map (fun v1 ->
Array.map (fun v2 -> v1 *. v2) norm_coef_scale_q
) norm_coef_scale_p
|> Array.to_list
|> Array.concat
in
|> Array.to_list
|> Array.concat
in
(*
let monocentric =
shell_p.(ab).Shell_pair.monocentric &&
shell_q.(cd).Shell_pair.monocentric
in
*)
(* Compute the integral class from the primitive shell quartet *)
class_indices
|> Array.iteri (fun i key ->
let a = Zkey.to_int_array Zkey.Kind_12 key in
let (angMomA,angMomB,angMomC,angMomD) =
( [| a.(0) ; a.(1) ; a.(2) |],
[| a.(3) ; a.(4) ; a.(5) |],
[| a.(6) ; a.(7) ; a.(8) |],
[| a.(9) ; a.(10) ; a.(11) |] )
in
try
(* Compute the integral class from the primitive shell quartet *)
class_indices
|> Array.iteri (fun i key ->
let a = Zkey.to_int_array Zkey.Kind_12 key in
let (angMomA,angMomB,angMomC,angMomD) =
( [| a.(0) ; a.(1) ; a.(2) |],
[| a.(3) ; a.(4) ; a.(5) |],
[| a.(6) ; a.(7) ; a.(8) |],
[| a.(9) ; a.(10) ; a.(11) |] )
in
try
(*
if monocentric then
begin
@ -391,7 +391,7 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
raise NullQuartet
end;
*)
(* Schwartz screening *)
(* Schwartz screening *)
(*
let schwartz_p =
let key =
@ -421,23 +421,23 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
if schwartz_p *. schwartz_q < cutoff2 then raise NullQuartet;
*)
let norm = norm_coef_scale.(i) in
let coef_prod = coef_prod *. norm in
let integral =
hvrr_two_e (angMomA, angMomB, angMomC, angMomD)
(Contracted_shell.totAngMom shell_a, Contracted_shell.totAngMom shell_b,
Contracted_shell.totAngMom shell_c, Contracted_shell.totAngMom shell_d)
(maxm, zero_m_array)
(Contracted_shell.expo shell_b b, Contracted_shell.expo shell_d d)
(shell_p.(ab).Shell_pair.expo_inv, shell_q.(cd).Shell_pair.expo_inv)
(shell_p.(ab).Shell_pair.center_ab, shell_q.(cd).Shell_pair.center_ab, center_pq)
map_1d map_2d
in
contracted_class.(i) <- contracted_class.(i) +. coef_prod *. integral
with NullQuartet -> ()
)
let norm = norm_coef_scale.(i) in
let coef_prod = coef_prod *. norm in
let integral =
hvrr_two_e (angMomA, angMomB, angMomC, angMomD)
(Contracted_shell.totAngMom shell_a, Contracted_shell.totAngMom shell_b,
Contracted_shell.totAngMom shell_c, Contracted_shell.totAngMom shell_d)
(maxm, zero_m_array)
(Contracted_shell.expo shell_b b, Contracted_shell.expo shell_d d)
(shell_p.(ab).Shell_pair.expo_inv, shell_q.(cd).Shell_pair.expo_inv)
(shell_p.(ab).Shell_pair.center_ab, shell_q.(cd).Shell_pair.center_ab, center_pq)
map_1d map_2d
in
contracted_class.(i) <- contracted_class.(i) +. coef_prod *. integral
with NullQuartet -> ()
)
end
with NullQuartet -> ()
with NullQuartet -> ()
done
done;

View File

@ -43,8 +43,8 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
in
let f = expo_b *. (Coordinate.coord center_ab xyz) in
Array.init ncoef (fun k -> coef_prod.(k) *. expo_inv_p *.
( (Coordinate.coord center_pq.(k) xyz) *. zero_m_array.(m+1).(k)
-. f *. zero_m_array.(m).(k) ) )
( (Coordinate.coord center_pq.(k) xyz) *. zero_m_array.(m+1).(k)
-. f *. zero_m_array.(m).(k) ) )
| 0 -> Array.map2 ( *. ) zero_m_array.(m) coef_prod
| totAngMom_a ->
let key = Zkey.of_int_tuple (Zkey.Three angMom_a)
@ -52,138 +52,138 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
try Zmap.find map_1d.(m) key with
| Not_found ->
let result =
let am, amm, amxyz, xyz =
match angMom_a with
| (x,0,0) -> (x-1,0,0),(x-2,0,0), x-1, 0
| (x,y,0) -> (x,y-1,0),(x,y-2,0), y-1, 1
| (x,y,z) -> (x,y,z-1),(x,y,z-2), z-1, 2
in
if amxyz < 0 then empty else
let v1 =
let f =
-. expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz)
in
if (abs_float f < cutoff) then empty else
Array.map (fun v1k -> f *. v1k) (vrr0_v m am (totAngMom_a-1) )
in
let p1 =
Array.mapi (fun k v2k -> v1.(k) +. expo_inv_p *. (Coordinate.coord center_pq.(k) xyz) *. v2k) (vrr0_v (m+1) am (totAngMom_a-1))
in
if amxyz < 1 then p1 else
let f = (float_of_int amxyz) *. expo_inv_p *. 0.5
in
if (abs_float f < cutoff) then empty else
let v1 = vrr0_v m amm (totAngMom_a-2)
in
let v2 =
if (abs_float (f *. expo_inv_p)) < cutoff then empty else
vrr0_v (m+1) amm (totAngMom_a-2)
in
Array.init ncoef (fun k -> p1.(k) +.
f *. (v1.(k) +. v2.(k) *. expo_inv_p ) )
in Zmap.add map_1d.(m) key result;
result
let result =
let am, amm, amxyz, xyz =
match angMom_a with
| (x,0,0) -> (x-1,0,0),(x-2,0,0), x-1, 0
| (x,y,0) -> (x,y-1,0),(x,y-2,0), y-1, 1
| (x,y,z) -> (x,y,z-1),(x,y,z-2), z-1, 2
in
if amxyz < 0 then empty else
let v1 =
let f =
-. expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz)
in
if (abs_float f < cutoff) then empty else
Array.map (fun v1k -> f *. v1k) (vrr0_v m am (totAngMom_a-1) )
in
let p1 =
Array.mapi (fun k v2k -> v1.(k) +. expo_inv_p *. (Coordinate.coord center_pq.(k) xyz) *. v2k) (vrr0_v (m+1) am (totAngMom_a-1))
in
if amxyz < 1 then p1 else
let f = (float_of_int amxyz) *. expo_inv_p *. 0.5
in
if (abs_float f < cutoff) then empty else
let v1 = vrr0_v m amm (totAngMom_a-2)
in
let v2 =
if (abs_float (f *. expo_inv_p)) < cutoff then empty else
vrr0_v (m+1) amm (totAngMom_a-2)
in
Array.init ncoef (fun k -> p1.(k) +.
f *. (v1.(k) +. v2.(k) *. expo_inv_p ) )
in Zmap.add map_1d.(m) key result;
result
and vrr_v m angMom_a angMom_c totAngMom_a totAngMom_c =
match (totAngMom_a, totAngMom_c) with
| (i,0) -> if (i>0) then
vrr0_v m angMom_a totAngMom_a
else
Array.map2 ( *. ) zero_m_array.(m) coef_prod
vrr0_v m angMom_a totAngMom_a
else
Array.map2 ( *. ) zero_m_array.(m) coef_prod
| (_,_) ->
let key = Zkey.of_int_tuple (Zkey.Six (angMom_a, angMom_c))
in
try Zmap.find map_2d.(m) key with
| Not_found ->
let result =
begin
let am, cm, cmm, axyz, cxyz, xyz =
let (aax, aay, aaz) = angMom_a
and (acx, acy, acz) = angMom_c in
if (acz > 0) then
(aax, aay, aaz-1),
(acx, acy, acz-1),
(acx, acy, acz-2),
aaz, acz, 2
else if (acy > 0) then
(aax, aay-1,aaz),
(acx, acy-1,acz),
(acx, acy-2,acz),
aay,acy, 1
else
(aax-1,aay,aaz),
(acx-1,acy,acz),
(acx-2,acy,acz),
aax,acx, 0
in
| Not_found ->
let result =
begin
let am, cm, cmm, axyz, cxyz, xyz =
let (aax, aay, aaz) = angMom_a
and (acx, acy, acz) = angMom_c in
if (acz > 0) then
(aax, aay, aaz-1),
(acx, acy, acz-1),
(acx, acy, acz-2),
aaz, acz, 2
else if (acy > 0) then
(aax, aay-1,aaz),
(acx, acy-1,acz),
(acx, acy-2,acz),
aay,acy, 1
else
(aax-1,aay,aaz),
(acx-1,acy,acz),
(acx-2,acy,acz),
aax,acx, 0
in
(*
if cxyz < 1 then empty else
*)
let f1 =
Array.init ncoef (fun k ->
expo_d.(k) *. expo_inv_q.(k) *.
(Coordinate.coord center_cd.(k) xyz) )
in
let f2 =
Array.init ncoef (fun k ->
expo_inv_q.(k) *. (Coordinate.coord center_pq.(k) xyz) )
in
let v1 =
if (at_least_one_valid f1) then
vrr_v m angMom_a cm totAngMom_a (totAngMom_c-1)
else empty
and v2 =
if (at_least_one_valid f2) then
vrr_v (m+1) angMom_a cm totAngMom_a (totAngMom_c-1)
else empty
in
let p1 =
Array.init ncoef (fun k -> -. v1.(k) *. f1.(k) -. v2.(k) *. f2.(k))
in
let p2 =
if cxyz < 2 then p1 else
let fcm =
(float_of_int (cxyz-1)) *. 0.5
in
let f1 =
Array.map (fun e -> fcm *. e) expo_inv_q
in
let f2 =
Array.map2 ( *. ) f1 expo_inv_q
in
let v1 =
if (at_least_one_valid f1) then
vrr_v m angMom_a cmm totAngMom_a (totAngMom_c-2)
else empty
in
let v2 =
if (at_least_one_valid f2) then
vrr_v (m+1) angMom_a cmm totAngMom_a (totAngMom_c-2)
else empty
in
Array.init ncoef (fun k -> p1.(k) +. f1.(k) *. v1.(k) +. f2.(k) *. v2.(k))
in
if (axyz < 1) || (cxyz < 1) then p2 else
let fa =
(float_of_int axyz) *. expo_inv_p *. 0.5
in
let f1 =
Array.map (fun e -> fa *. e ) expo_inv_q
in
if (at_least_one_valid f1) then
let v =
vrr_v (m+1) am cm (totAngMom_a-1) (totAngMom_c-1)
in
Array.init ncoef (fun k -> p2.(k) -. f1.(k) *. v.(k))
else p2
end
in Zmap.add map_2d.(m) key result;
result
let f1 =
Array.init ncoef (fun k ->
expo_d.(k) *. expo_inv_q.(k) *.
(Coordinate.coord center_cd.(k) xyz) )
in
let f2 =
Array.init ncoef (fun k ->
expo_inv_q.(k) *. (Coordinate.coord center_pq.(k) xyz) )
in
let v1 =
if (at_least_one_valid f1) then
vrr_v m angMom_a cm totAngMom_a (totAngMom_c-1)
else empty
and v2 =
if (at_least_one_valid f2) then
vrr_v (m+1) angMom_a cm totAngMom_a (totAngMom_c-1)
else empty
in
let p1 =
Array.init ncoef (fun k -> -. v1.(k) *. f1.(k) -. v2.(k) *. f2.(k))
in
let p2 =
if cxyz < 2 then p1 else
let fcm =
(float_of_int (cxyz-1)) *. 0.5
in
let f1 =
Array.map (fun e -> fcm *. e) expo_inv_q
in
let f2 =
Array.map2 ( *. ) f1 expo_inv_q
in
let v1 =
if (at_least_one_valid f1) then
vrr_v m angMom_a cmm totAngMom_a (totAngMom_c-2)
else empty
in
let v2 =
if (at_least_one_valid f2) then
vrr_v (m+1) angMom_a cmm totAngMom_a (totAngMom_c-2)
else empty
in
Array.init ncoef (fun k -> p1.(k) +. f1.(k) *. v1.(k) +. f2.(k) *. v2.(k))
in
if (axyz < 1) || (cxyz < 1) then p2 else
let fa =
(float_of_int axyz) *. expo_inv_p *. 0.5
in
let f1 =
Array.map (fun e -> fa *. e ) expo_inv_q
in
if (at_least_one_valid f1) then
let v =
vrr_v (m+1) am cm (totAngMom_a-1) (totAngMom_c-1)
in
Array.init ncoef (fun k -> p2.(k) -. f1.(k) *. v.(k))
else p2
end
in Zmap.add map_2d.(m) key result;
result
@ -203,14 +203,14 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
| 1 ->
let (aax, aay, aaz) = angMom_a in
let ap, xyz =
match angMom_b with
| (_,_,1) -> (aax,aay,aaz+1), 2
| (_,1,_) -> (aax,aay+1,aaz), 1
| (_,_,_) -> (aax+1,aay,aaz), 0
match angMom_b with
| (_,_,1) -> (aax,aay,aaz+1), 2
| (_,1,_) -> (aax,aay+1,aaz), 1
| (_,_,_) -> (aax+1,aay,aaz), 0
in
let f = Coordinate.coord center_ab xyz in
let v1 =
vrr_v 0 ap angMom_c (totAngMom_a+1) totAngMom_c
vrr_v 0 ap angMom_c (totAngMom_a+1) totAngMom_c
in
if (abs_float f < cutoff) then v1 else
let v2 =
@ -221,36 +221,36 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
let (aax, aay, aaz) = angMom_a
and (abx, aby, abz) = angMom_b in
let bxyz, xyz =
match angMom_b with
| (0,0,_) -> abz, 2
| (0,_,_) -> aby, 1
| _ -> abx, 0
match angMom_b with
| (0,0,_) -> abz, 2
| (0,_,_) -> aby, 1
| _ -> abx, 0
in
if (bxyz < 1) then empty else
let ap, bm =
match xyz with
| 0 -> (aax+1,aay,aaz),(abx-1,aby,abz)
| 1 -> (aax,aay+1,aaz),(abx,aby-1,abz)
| _ -> (aax,aay,aaz+1),(abx,aby,abz-1)
in
let ap, bm =
match xyz with
| 0 -> (aax+1,aay,aaz),(abx-1,aby,abz)
| 1 -> (aax,aay+1,aaz),(abx,aby-1,abz)
| _ -> (aax,aay,aaz+1),(abx,aby,abz-1)
in
let h1 =
hrr0_v ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c
in
let f = (Coordinate.coord center_ab xyz) in
if (abs_float f < cutoff) then h1 else
let h2 =
hrr0_v angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
in Array.map2 (fun h1 h2 -> h1 +. h2 *. f) h1 h2
let h2 =
hrr0_v angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
in Array.map2 (fun h1 h2 -> h1 +. h2 *. f) h1 h2
and hrr_v angMom_a angMom_b angMom_c angMom_d
totAngMom_a totAngMom_b totAngMom_c totAngMom_d =
match (totAngMom_b, totAngMom_d) with
| (_,0) -> if (totAngMom_b = 0) then
vrr_v 0 angMom_a angMom_c totAngMom_a totAngMom_c
else
hrr0_v angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
vrr_v 0 angMom_a angMom_c totAngMom_a totAngMom_c
else
hrr0_v angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
| (_,_) ->
let (acx, acy, acz) = angMom_c
and (adx, ady, adz) = angMom_d in
@ -314,32 +314,32 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
contracted_class.(0) <-
Array.fold_left
(fun accu shell_ab -> accu +.
Array.fold_left (fun accu shell_cd ->
let coef_prod =
shell_ab.Shell_pair.coef *. shell_cd.Shell_pair.coef
in
(** Screening on the product of coefficients *)
try
if (abs_float coef_prod) < 1.e-3*.cutoff then
raise NullQuartet;
Array.fold_left (fun accu shell_cd ->
let coef_prod =
shell_ab.Shell_pair.coef *. shell_cd.Shell_pair.coef
in
(** Screening on the product of coefficients *)
try
if (abs_float coef_prod) < 1.e-3*.cutoff then
raise NullQuartet;
let expo_pq_inv =
shell_ab.Shell_pair.expo_inv +. shell_cd.Shell_pair.expo_inv
in
let center_pq =
Coordinate.(shell_ab.Shell_pair.center |- shell_cd.Shell_pair.center)
in
let norm_pq_sq =
Coordinate.dot center_pq center_pq
in
let expo_pq_inv =
shell_ab.Shell_pair.expo_inv +. shell_cd.Shell_pair.expo_inv
in
let center_pq =
Coordinate.(shell_ab.Shell_pair.center |- shell_cd.Shell_pair.center)
in
let norm_pq_sq =
Coordinate.dot center_pq center_pq
in
let zero_m_array =
zero_m ~maxm:0 ~expo_pq_inv ~norm_pq_sq
in
let zero_m_array =
zero_m ~maxm:0 ~expo_pq_inv ~norm_pq_sq
in
accu +. coef_prod *. zero_m_array.(0)
with NullQuartet -> accu
) 0. shell_q
accu +. coef_prod *. zero_m_array.(0)
with NullQuartet -> accu
) 0. shell_q
) 0. shell_p
| _ ->
@ -368,18 +368,18 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
let d = shell_cd.Shell_pair.j in
(zero_m_array, shell_cd.Shell_pair.expo_inv,
Contracted_shell.expo shell_d d, shell_cd.Shell_pair.center_ab,
center_pq,coef_prod)
Contracted_shell.expo shell_d d, shell_cd.Shell_pair.center_ab,
center_pq,coef_prod)
) shell_q
|> Array.to_list
|> List.filter (fun (zero_m_array, expo_inv, d, center_cd,
center_pq,coef_prod) -> abs_float coef_prod >= 1.e-4 *. cutoff)
center_pq,coef_prod) -> abs_float coef_prod >= 1.e-4 *. cutoff)
|> Array.of_list
in
let zero_m_array = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
center_pq,coef_prod) -> zero_m_array) common
center_pq,coef_prod) -> zero_m_array) common
and expo_inv = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
center_pq,coef_prod) -> expo_inv ) common
center_pq,coef_prod) -> expo_inv ) common
and d = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
center_pq,coef_prod) -> d) common
and center_cd = Array.map (fun (zero_m_array, expo_inv, d, center_cd,
@ -393,48 +393,48 @@ let contracted_class_shell_pairs ~zero_m ?schwartz_p ?schwartz_q shell_p shell_q
*)
let zero_m_array =
let result = Array.init (maxm+1) (fun _ ->
Array.make (Array.length coef_prod) 0.)
Array.make (Array.length coef_prod) 0.)
in
for m=0 to maxm do
for k=0 to (Array.length coef_prod-1) do
result.(m).(k) <- zero_m_array.(k).(m)
result.(m).(k) <- zero_m_array.(k).(m)
done;
done;
result
in
(* Compute the integral class from the primitive shell quartet *)
(* Compute the integral class from the primitive shell quartet *)
let map_1d = Array.init maxm (fun _ -> Zmap.create (4*maxm)) in
let map_2d = Array.init maxm (fun _ -> Zmap.create (Array.length class_indices)) in
let norm =
let norm_coef_scale_q = shell_q.(0).Shell_pair.norm_coef_scale in
Array.map (fun v1 ->
Array.map (fun v2 -> v1 *. v2) norm_coef_scale_q
) norm_coef_scale_p
|> Array.to_list
|> Array.concat
in
Array.iteri (fun i key ->
let a = Zkey.to_int_array Zkey.Kind_12 key in
let (angMomA,angMomB,angMomC,angMomD) =
( [| a.(0) ; a.(1) ; a.(2) |],
[| a.(3) ; a.(4) ; a.(5) |],
[| a.(6) ; a.(7) ; a.(8) |],
[| a.(9) ; a.(10) ; a.(11) |] )
in
let integral =
hvrr_two_e_vector (angMomA, angMomB, angMomC, angMomD)
(Contracted_shell.totAngMom shell_a, Contracted_shell.totAngMom shell_b,
Contracted_shell.totAngMom shell_c, Contracted_shell.totAngMom shell_d)
(maxm, zero_m_array)
(Contracted_shell.expo shell_b b, d)
(shell_ab.Shell_pair.expo_inv, expo_inv)
(shell_ab.Shell_pair.center_ab, center_cd, center_pq)
coef_prod map_1d map_2d
in
let x = Array.fold_left (+.) 0. integral in
contracted_class.(i) <- contracted_class.(i) +. x *. norm.(i)
) class_indices
let norm =
let norm_coef_scale_q = shell_q.(0).Shell_pair.norm_coef_scale in
Array.map (fun v1 ->
Array.map (fun v2 -> v1 *. v2) norm_coef_scale_q
) norm_coef_scale_p
|> Array.to_list
|> Array.concat
in
Array.iteri (fun i key ->
let a = Zkey.to_int_array Zkey.Kind_12 key in
let (angMomA,angMomB,angMomC,angMomD) =
( [| a.(0) ; a.(1) ; a.(2) |],
[| a.(3) ; a.(4) ; a.(5) |],
[| a.(6) ; a.(7) ; a.(8) |],
[| a.(9) ; a.(10) ; a.(11) |] )
in
let integral =
hvrr_two_e_vector (angMomA, angMomB, angMomC, angMomD)
(Contracted_shell.totAngMom shell_a, Contracted_shell.totAngMom shell_b,
Contracted_shell.totAngMom shell_c, Contracted_shell.totAngMom shell_d)
(maxm, zero_m_array)
(Contracted_shell.expo shell_b b, d)
(shell_ab.Shell_pair.expo_inv, expo_inv)
(shell_ab.Shell_pair.center_ab, center_cd, center_pq)
coef_prod map_1d map_2d
in
let x = Array.fold_left (+.) 0. integral in
contracted_class.(i) <- contracted_class.(i) +. x *. norm.(i)
) class_indices
) shell_p
end;

View File

@ -34,24 +34,24 @@ let incomplete_gamma ~alpha x =
let r0 = exp (a *. log x -. x -. loggamma_a) /. a in
pg_loop min_float r0 r0 1.
and q_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 did not converge."
else if prev = res then res
else
let k_inv = 1. /. k in
let la, lb =
lb, ((k -. 1. -. a) *. (lb -. la) +. (k +. x) *. lb) *. k_inv
in
let w = w *. (k -. 1. -. a) *. k_inv in
let prev, res = res, res +. w /. (la *. lb) in
qg_loop prev res la lb w (k +. 1.)
in
let w = exp (a *. log x -. x -. loggamma_a) in
let lb = (1. +. x -. a) in
qg_loop min_float (w /. lb) 1. lb w 2.0
and q_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 did not converge."
else if prev = res then res
else
let k_inv = 1. /. k in
let la, lb =
lb, ((k -. 1. -. a) *. (lb -. la) +. (k +. x) *. lb) *. k_inv
in
let w = w *. (k -. 1. -. a) *. k_inv in
let prev, res = res, res +. w /. (la *. lb) in
qg_loop prev res la lb w (k +. 1.)
in
let w = exp (a *. log x -. x -. loggamma_a) in
let lb = (1. +. x -. a) in
qg_loop min_float (w /. lb) 1. lb w 2.0
in
let gf = gamma_float alpha in
gf *. p_gamma alpha x (log gf)
@ -62,12 +62,12 @@ let incomplete_gamma ~alpha x =
let fact_memo =
let rec aux accu_l accu = function
| 0 -> aux [1.] 1. 1
| i when (i = factmax) ->
let x = (float_of_int factmax) *. accu in
List.rev (x::accu_l)
| i -> let x = (float_of_int i) *. accu in
aux (x::accu_l) x (i+1)
| 0 -> aux [1.] 1. 1
| i when (i = factmax) ->
let x = (float_of_int factmax) *. accu in
List.rev (x::accu_l)
| i -> let x = (float_of_int i) *. accu in
aux (x::accu_l) x (i+1)
in
aux [] 0. 0
|> Array.of_list
@ -114,8 +114,8 @@ let boys_function ~maxm t =
| 0 ->
begin
if t = 0. then [| 1. |] else
let sq_t = sqrt t in
[| (sq_pi_over_two /. sq_t) *. erf_float sq_t |]
let sq_t = sqrt t in
[| (sq_pi_over_two /. sq_t) *. erf_float sq_t |]
end
| _ ->
begin