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

Better vectorization

This commit is contained in:
Anthony Scemama 2018-02-11 00:05:56 +01:00
parent 7415033b64
commit 58d0e65b4e
2 changed files with 67 additions and 52 deletions

View File

@ -215,7 +215,7 @@ let of_basis basis =
done; done;
done; done;
Printf.printf "In: %d Out:%d\n" !inn !out ; Printf.printf "In: %d Out:%d\n" !inn !out ;
Printf.printf "Computed ERIs in %f seconds\n" (Unix.gettimeofday () -. t0); Printf.printf "Computed ERIs in %f seconds\n%!" (Unix.gettimeofday () -. t0);
eri_array eri_array

View File

@ -24,9 +24,6 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
map_1d map_2d np nq map_1d map_2d np nq
= =
let empty = Array.make nq 0. in
let tmp_1 = Array.make nq 0. in
let totAngMom_a = Angular_momentum.to_int totAngMom_a let totAngMom_a = Angular_momentum.to_int totAngMom_a
and totAngMom_b = Angular_momentum.to_int totAngMom_b and totAngMom_b = Angular_momentum.to_int totAngMom_b
@ -70,56 +67,74 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
in in
let result = Array.make_matrix np nq 0. in let result = Array.make_matrix np nq 0. in
for l=0 to np-1 if amxyz < 1 then
do begin
let p0 = let p0 =
match p1_top with match p1_top with
| Some p1_top -> p1_top.(l) | Some p1_top -> p1_top
| _ -> assert false | _ -> assert false
in in
begin
match v1_top with
| None -> ()
| Some v0 ->
for l=0 to np-1 do
let f0 = let f0 =
-. expo_b.(l) *. expo_inv_p.(l) *. cab -. expo_b.(l) *. expo_inv_p.(l) *. cab
in in
let v0 =
match v1_top with
| Some v1_top -> v1_top.(l)
| None -> empty
in
for k=0 to nq-1 for k=0 to nq-1
do do
tmp_1.(k) <- v0.(k) *. f0 result.(l).(k) <- v0.(l).(k) *. f0
done; done
let v0 = tmp_1 in done
if amxyz < 1 then end;
begin for l=0 to np-1 do
for k=0 to nq-1 for k=0 to nq-1 do
do result.(l).(k) <- result.(l).(k) +. expo_inv_p.(l) *. center_pq.(xyz).(l).(k) *. p0.(l).(k)
result.(l).(k) <- v0.(k) +. expo_inv_p.(l) *. center_pq.(xyz).(l).(k) *. p0.(k) done
done done
end end
else else
begin begin
let f = (float_of_int amxyz) *. expo_inv_p.(l) *. 0.5 let p0 =
match p1_top with
| Some p1_top -> p1_top
| _ -> assert false
in in
begin
match v1_top with
| None -> ()
| Some v0 ->
for l=0 to np-1 do
let f0 =
-. expo_b.(l) *. expo_inv_p.(l) *. cab
in
for k=0 to nq-1
do
result.(l).(k) <- v0.(l).(k) *. f0
done
done
end;
let v1 = let v1 =
match v1_top2 with match v1_top2 with
| Some v1_top2 -> v1_top2.(l) | Some v1_top2 -> v1_top2
| None -> assert false | None -> assert false
in in
let v2 = let v2 =
match p1_top2 with match p1_top2 with
| Some p1_top2 -> p1_top2.(l) | Some p1_top2 -> p1_top2
| None -> assert false | None -> assert false
in in
for l=0 to np-1 do
let f = (float_of_int amxyz) *. expo_inv_p.(l) *. 0.5 in
for k=0 to nq-1 for k=0 to nq-1
do do
result.(l).(k) <- result.(l).(k) <- result.(l).(k)
v0.(k) +. expo_inv_p.(l) *. center_pq.(xyz).(l).(k) *. p0.(l).(k)
+. expo_inv_p.(l) *. center_pq.(xyz).(l).(k) *. p0.(k) +. f *. (v1.(l).(k) +. v2.(l).(k) *. expo_inv_p.(l) )
+. f *. (v1.(k) +. v2.(k) *. expo_inv_p.(l) )
done done
end done
done; end;
Some result Some result
end end
in in
@ -163,7 +178,7 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
*) *)
let do_compute = ref false in let do_compute = ref false in
let v1 = let v1 =
let f = (Coordinate.coord center_cd xyz) in let f = -. (Coordinate.coord center_cd xyz) in
let f1 = let f1 =
Array.init nq (fun k -> Array.init nq (fun k ->
let x = expo_d.(k) *. expo_inv_q.(k) *. f in let x = expo_d.(k) *. expo_inv_q.(k) *. f in
@ -179,7 +194,7 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
let result = Array.make_matrix np nq 0. in let result = Array.make_matrix np nq 0. in
for l=0 to np-1 do for l=0 to np-1 do
for k=0 to nq-1 do for k=0 to nq-1 do
result.(l).(k) <- -. v1.(l).(k) *. f1.(k) (* v1 rec *) result.(l).(k) <- v1.(l).(k) *. f1.(k)
done done
done; done;
Some result Some result