10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-08-29 07:51:59 +02:00

Vectorizing

This commit is contained in:
Anthony Scemama 2018-01-29 13:39:59 +01:00
parent 8a851eb4ed
commit bdccd66b1a

View File

@ -26,13 +26,11 @@ let hvrr_two_e m (angMom_a, angMom_b, angMom_c, angMom_d)
(** Vertical recurrence relations *) (** Vertical recurrence relations *)
let rec vrr0 m angMom_a = function let rec vrr0 m angMom_a = function
| 0 -> Array.mapi (fun k c -> c *. zero_m_array.(k).(m)) coef_prod | 0 -> Array.mapi (fun k c -> c *. zero_m_array.(k).(m)) coef_prod
|> getk
| 1 -> let i = if angMom_a.(0) = 1 then 0 else if angMom_a.(1) = 1 then 1 else 2 | 1 -> let i = if angMom_a.(0) = 1 then 0 else if angMom_a.(1) = 1 then 1 else 2
in in
Array.mapi (fun k c -> c *. expo_inv_p *. Array.mapi (fun k c -> c *. expo_inv_p *.
( (Coordinate.coord center_pq.(k) i) *. zero_m_array.(k).(m+1) ( (Coordinate.coord center_pq.(k) i) *. zero_m_array.(k).(m+1)
-. expo_b *. (Coordinate.coord center_ab i) *. zero_m_array.(k).(m) ) ) coef_prod -. expo_b *. (Coordinate.coord center_ab i) *. zero_m_array.(k).(m) ) ) coef_prod
|> getk
| totAngMom_a -> | totAngMom_a ->
let key = Zkey.of_int_tuple (Zkey.Three let key = Zkey.of_int_tuple (Zkey.Three
@ -52,19 +50,28 @@ let hvrr_two_e m (angMom_a, angMom_b, angMom_c, angMom_d)
in in
am.(xyz) <- am.(xyz) - 1; am.(xyz) <- am.(xyz) - 1;
amm.(xyz) <- amm.(xyz) - 2; amm.(xyz) <- amm.(xyz) - 2;
if am.(xyz) < 0 then 0. else if am.(xyz) < 0 then
Array.mapi (fun k _ -> Array.map (fun _ -> 0.) coef_prod
(-. expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz)) else
*. (vrr0 m am (totAngMom_a-1) ) let v1 =
+. (expo_inv_p *. (Coordinate.coord center_pq.(k) xyz)) vrr0 m am (totAngMom_a-1)
*.(vrr0 (m+1) am (totAngMom_a-1) ) and v2 =
+. (if amm.(xyz) < 0 then 0. else vrr0 (m+1) am (totAngMom_a-1)
((float_of_int am.(xyz)) *. expo_inv_p *. 0.5) in
*. (vrr0 m amm (totAngMom_a-2) let p1 =
+. expo_inv_p *. (vrr0 (m+1) amm (totAngMom_a-2) ) ) ) Array.mapi (fun k _ ->
) coef_prod (-. expo_b *. expo_inv_p *. (Coordinate.coord center_ab xyz)) *. v1.(k)
|> getk +. (expo_inv_p *. (Coordinate.coord center_pq.(k) xyz)) *. v2.(k)
) ) coef_prod
in
if amm.(xyz) < 0 then p1 else
let v1 = vrr0 m amm (totAngMom_a-2)
and v2 = vrr0 (m+1) amm (totAngMom_a-2)
in
Array.mapi (fun k _ -> p1.(k) +.
(float_of_int am.(xyz)) *. expo_inv_p *. 0.5
*. (v1.(k) +. v2.(k) *. expo_inv_p ) ) coef_prod
)
in in
if not found then if not found then
Zmap.add map.(m) key result; Zmap.add map.(m) key result;
@ -74,7 +81,6 @@ if am.(xyz) < 0 then 0. else
match (totAngMom_a, totAngMom_c) with match (totAngMom_a, totAngMom_c) with
| (0,0) -> Array.mapi (fun k c -> c *. zero_m_array.(k).(m)) coef_prod | (0,0) -> Array.mapi (fun k c -> c *. zero_m_array.(k).(m)) coef_prod
|> getk
| (_,0) -> vrr0 m angMom_a totAngMom_a | (_,0) -> vrr0 m angMom_a totAngMom_a
| (_,_) -> | (_,_) ->
@ -99,20 +105,28 @@ if am.(xyz) < 0 then 0. else
am.(xyz) <- am.(xyz) - 1; am.(xyz) <- am.(xyz) - 1;
cm.(xyz) <- cm.(xyz) - 1; cm.(xyz) <- cm.(xyz) - 1;
cmm.(xyz) <- cmm.(xyz) - 2; cmm.(xyz) <- cmm.(xyz) - 2;
if cm.(xyz) < 0 then 0. else
Array.mapi (fun k _ -> Array.mapi (fun k _ ->
(-. expo_d.(k) *. expo_inv_q.(k) *. (Coordinate.coord center_cd.(k) xyz) ) if cm.(xyz) < 0 then 0. else
*.(vrr m angMom_a cm totAngMom_a (totAngMom_c-1) ) let v1 =
-. (expo_inv_q.(k) *. (Coordinate.coord center_pq.(k) xyz)) vrr m angMom_a cm totAngMom_a (totAngMom_c-1)
*.(vrr (m+1) angMom_a cm totAngMom_a (totAngMom_c-1) ) and v2 =
vrr (m+1) angMom_a cm totAngMom_a (totAngMom_c-1)
in
-. v1.(k) *. expo_d.(k) *. expo_inv_q.(k) *. (Coordinate.coord center_cd.(k) xyz)
-. v2.(k) *. (expo_inv_q.(k) *. (Coordinate.coord center_pq.(k) xyz))
+. (if cmm.(xyz) < 0 then 0. else +. (if cmm.(xyz) < 0 then 0. else
((float_of_int cm.(xyz)) *. expo_inv_q.(k) *. 0.5 ) let v1 =
*.(vrr m angMom_a cmm totAngMom_a (totAngMom_c-2) vrr m angMom_a cmm totAngMom_a (totAngMom_c-2)
+. expo_inv_q.(k) *. (vrr (m+1) angMom_a cmm totAngMom_a (totAngMom_c-2) ) ) ) and v2 =
vrr (m+1) angMom_a cmm totAngMom_a (totAngMom_c-2)
in
((float_of_int cm.(xyz)) *. expo_inv_q.(k) *. 0.5 ) *.(v1.(k) +. expo_inv_q.(k) *. v2.(k) ) )
-. (if am.(xyz) lor cm.(xyz) < 0 then 0. else -. (if am.(xyz) lor cm.(xyz) < 0 then 0. else
((float_of_int angMom_a.(xyz)) *. expo_inv_p *. expo_inv_q.(k) *. 0.5 ) let v =
*.(vrr (m+1) am cm (totAngMom_a-1) (totAngMom_c-1) ) )) coef_prod vrr (m+1) am cm (totAngMom_a-1) (totAngMom_c-1)
|> getk in
(float_of_int angMom_a.(xyz)) *. expo_inv_p *. expo_inv_q.(k) *. 0.5 *.v.(k) )
) coef_prod
) )
in in
if not found then if not found then
@ -128,11 +142,17 @@ if cm.(xyz) < 0 then 0. else
match totAngMom_b with match totAngMom_b with
| 0 -> vrr m angMom_a angMom_c totAngMom_a totAngMom_c | 0 -> vrr m angMom_a angMom_c totAngMom_a totAngMom_c
|> getk
| 1 -> let xyz = if angMom_b.(0) = 1 then 0 else if angMom_b.(1) = 1 then 1 else 2 in | 1 -> let xyz = if angMom_b.(0) = 1 then 0 else if angMom_b.(1) = 1 then 1 else 2 in
let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |] in let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |] in
ap.(xyz) <- ap.(xyz) + 1; ap.(xyz) <- ap.(xyz) + 1;
vrr m ap angMom_c (totAngMom_a+1) totAngMom_c let v1 =
+. (Coordinate.coord center_ab xyz) *. (vrr m angMom_a angMom_c totAngMom_a totAngMom_c) vrr m ap angMom_c (totAngMom_a+1) totAngMom_c
|> getk
and v2 =
vrr m angMom_a angMom_c totAngMom_a totAngMom_c
|> getk
in v1 +. v2 *. (Coordinate.coord center_ab xyz)
| _ -> | _ ->
let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |] let ap = [| angMom_a.(0) ; angMom_a.(1) ; angMom_a.(2) |]
and bm = [| angMom_b.(0) ; angMom_b.(1) ; angMom_b.(2) |] and bm = [| angMom_b.(0) ; angMom_b.(1) ; angMom_b.(2) |]
@ -144,18 +164,19 @@ if cm.(xyz) < 0 then 0. else
in in
ap.(xyz) <- ap.(xyz) + 1; ap.(xyz) <- ap.(xyz) + 1;
bm.(xyz) <- bm.(xyz) - 1; bm.(xyz) <- bm.(xyz) - 1;
if (bm.(xyz) < 0) then 0. else if (bm.(xyz) < 0) then 0. else
hrr0 m ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c let h1 =
+. (Coordinate.coord center_ab xyz) hrr0 m ap bm angMom_c (totAngMom_a+1) (totAngMom_b-1) totAngMom_c
*.(hrr0 m angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) and h2 =
totAngMom_c ) hrr0 m angMom_a bm angMom_c totAngMom_a (totAngMom_b-1) totAngMom_c
in h1 +. h2 *. (Coordinate.coord center_ab xyz)
and hrr m angMom_a angMom_b angMom_c angMom_d and hrr m angMom_a angMom_b angMom_c angMom_d
totAngMom_a totAngMom_b totAngMom_c totAngMom_d = totAngMom_a totAngMom_b totAngMom_c totAngMom_d =
match (totAngMom_b, totAngMom_d) with match (totAngMom_b, totAngMom_d) with
| (0,0) -> | (0,0) -> vrr m angMom_a angMom_c totAngMom_a totAngMom_c
vrr m angMom_a angMom_c totAngMom_a totAngMom_c |> getk
| (_,0) -> hrr0 m angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c | (_,0) -> hrr0 m angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
| (_,_) -> | (_,_) ->
let cp = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |] let cp = [| angMom_c.(0) ; angMom_c.(1) ; angMom_c.(2) |]