10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-12-22 04:13:31 +01:00

Added operators on random variables

This commit is contained in:
Anthony Scemama 2016-05-02 21:51:09 +02:00
parent 571df84d9d
commit 54f2bae5f6
4 changed files with 48 additions and 9 deletions

View File

@ -145,15 +145,15 @@ let display_summary ~range =
in
List.iter properties ~f:print_property ;
(** TODO *)
(*
let open Random_variable in
let p = (of_raw_data ~range Property.E_loc_zv)
+! (of_raw_data ~range Property.E_loc)
let p = (of_raw_data ~range Property.E_loc)
+! (of_raw_data ~range Property.E_loc_zv)
in
Printf.printf "%20s : %s\n"
("E_loc_zv(+)")
(Random_variable.to_string p);
(** TODO *)
*)
let cpu =
Random_variable.of_raw_data ~range Property.Cpu

View File

@ -457,20 +457,59 @@ let merge_per_compute_node_and_block_id =
(Block_id.to_int block.Block.block_id) )
(** Create a new random variable which is a sum of 2 *)
let (+!) p1 p2 =
(** Create float, variable operators *)
let one_variable_operator ~update_value p f =
merge
~update_value
~hashable:String.hashable
~create_key:(fun block ->
Printf.sprintf "%s %10.10d %10.10d"
(Compute_node.to_string block.Block.compute_node)
(Block_id.to_int block.Block.block_id)
(Pid.to_int block.Block.pid) )
~update_weight:(fun wc wb -> wc )
p
let ( +@ ) p f = one_variable_operator p f
~update_value: (fun wc vc wb vb sw -> f +. (wc *. vc +. wb *. vb) /. sw)
let ( *@ ) p f = one_variable_operator p f
~update_value: (fun wc vc wb vb sw -> f *. (wc *. vc +. wb *. vb) /. sw)
let ( -@ ) p f = one_variable_operator p f
~update_value: (fun wc vc wb vb sw -> (wc *. vc +. wb *. vb) /. sw -. f)
let ( /@ ) p f = one_variable_operator p f
~update_value: (fun wc vc wb vb sw -> (wc *. vc +. wb *. vb) /. sw /. f)
(** Create two variable operators *)
let two_variable_operator ~update_value p1 p2 =
merge
~update_value
~hashable:String.hashable
~create_key:(fun block ->
Printf.sprintf "%s %10.10d %10.10d"
(Compute_node.to_string block.Block.compute_node)
(Block_id.to_int block.Block.block_id)
(Pid.to_int block.Block.pid) )
~update_value: (fun wc vc wb vb sw -> (vc +. vb) )
~update_weight:(fun wc wb -> wc )
{ property = p1.property ;
data = List.concat [ p1.data ; p2.data ] }
let ( +! ) = two_variable_operator
~update_value: (fun wc vc wb vb sw -> (vc +. vb) )
let ( *! ) = two_variable_operator
~update_value: (fun wc vc wb vb sw -> (vc *. vb) )
let ( -! ) = two_variable_operator
~update_value: (fun wc vc wb vb sw -> (vc -. vb) )
let ( /! ) = two_variable_operator
~update_value: (fun wc vc wb vb sw -> (vc /. vb) )
(** Merge two consecutive blocks *)

View File

@ -253,7 +253,7 @@ BEGIN_PROVIDER [ double precision, E_loc_zv ]
BEGIN_DOC
! Zero-variance parameter on E_loc
END_DOC
E_loc_zv = 0.d0
E_loc_zv = E_loc
END_PROVIDER

View File

@ -174,7 +174,7 @@ END_SHELL
if (calc_E_loc_zv) then
if (dabs(pdmc_weight(i_walk)*pop_weight_mult) > 1.d-6) then
E_loc_zv = (E_ref-E_loc)/(pdmc_weight(i_walk)*pop_weight_mult)
E_loc_zv = E_loc + (E_ref-E_loc)/(pdmc_weight(i_walk)*pop_weight_mult)
else
E_loc_zv = 0.d0
endif