10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-03 20:54:00 +01:00

Fixed qp_overlap_of_wf.ml

This commit is contained in:
Anthony Scemama 2017-09-14 18:39:40 +02:00
parent 07c7804658
commit 7c8f56bd06

View File

@ -40,18 +40,28 @@ let () =
in in
let overlap wf wf' = let overlap wf wf' =
let result, norm, norm' = let norm =
Hashtbl.fold (fun k c (accu,norm,norm') -> Hashtbl.fold (fun k c norm ->
norm +. c *. c ) wf 0.
and norm' =
Hashtbl.fold (fun k c norm ->
norm +. c *. c ) wf' 0.
in
let get_result wf wf' =
Hashtbl.fold (fun k c accu ->
let c' = let c' =
try Hashtbl.find wf' k try Hashtbl.find wf' k
with Not_found -> 0. with Not_found -> 0.
in in
(accu +. c *. c' , accu +. c *. c' ) wf 0.
norm +. c *. c ,
norm'+. c'*. c' )
) wf (0.,0.,0.)
in in
result /. (norm *. norm') let result =
if Hashtbl.length wf < Hashtbl.length wf' then
get_result wf wf'
else
get_result wf' wf
in
result /. (sqrt (norm *. norm'))
in in
let wf, wf' = let wf, wf' =
@ -62,5 +72,6 @@ let () =
let o = let o =
overlap wf wf' overlap wf wf'
in in
print_float (abs_float o) print_float (abs_float o);
print_newline ()