10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-06-26 15:12:05 +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;
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

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
=
let empty = Array.make nq 0. in
let tmp_1 = Array.make nq 0. in
let totAngMom_a = Angular_momentum.to_int totAngMom_a
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
let result = Array.make_matrix np nq 0. in
for l=0 to np-1
do
let p0 =
match p1_top with
| Some p1_top -> p1_top.(l)
| _ -> assert false
in
let f0 =
-. expo_b.(l) *. expo_inv_p.(l) *. cab
in
let v0 =
match v1_top with
| Some v1_top -> v1_top.(l)
| None -> empty
in
for k=0 to nq-1
do
tmp_1.(k) <- v0.(k) *. f0
done;
let v0 = tmp_1 in
if amxyz < 1 then
if amxyz < 1 then
begin
let p0 =
match p1_top with
| Some p1_top -> p1_top
| _ -> assert false
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;
for l=0 to np-1 do
for k=0 to nq-1 do
result.(l).(k) <- result.(l).(k) +. expo_inv_p.(l) *. center_pq.(xyz).(l).(k) *. p0.(l).(k)
done
done
end
else
begin
let p0 =
match p1_top with
| Some p1_top -> p1_top
| _ -> assert false
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 =
match v1_top2 with
| Some v1_top2 -> v1_top2
| None -> assert false
in
let v2 =
match p1_top2 with
| Some p1_top2 -> p1_top2
| None -> assert false
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
do
result.(l).(k) <- v0.(k) +. expo_inv_p.(l) *. center_pq.(xyz).(l).(k) *. p0.(k)
result.(l).(k) <- result.(l).(k)
+. expo_inv_p.(l) *. center_pq.(xyz).(l).(k) *. p0.(l).(k)
+. f *. (v1.(l).(k) +. v2.(l).(k) *. expo_inv_p.(l) )
done
end
else
begin
let f = (float_of_int amxyz) *. expo_inv_p.(l) *. 0.5
in
let v1 =
match v1_top2 with
| Some v1_top2 -> v1_top2.(l)
| None -> assert false
in
let v2 =
match p1_top2 with
| Some p1_top2 -> p1_top2.(l)
| None -> assert false
in
for k=0 to nq-1
do
result.(l).(k) <-
v0.(k)
+. expo_inv_p.(l) *. center_pq.(xyz).(l).(k) *. p0.(k)
+. f *. (v1.(k) +. v2.(k) *. expo_inv_p.(l) )
done
end
done;
done
end;
Some result
end
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 v1 =
let f = (Coordinate.coord center_cd xyz) in
let f = -. (Coordinate.coord center_cd xyz) in
let f1 =
Array.init nq (fun k ->
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
for l=0 to np-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;
Some result