-
Notifications
You must be signed in to change notification settings - Fork 0
/
rj_base.ml
30 lines (28 loc) · 931 Bytes
/
rj_base.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
type state =
| Histogram of float array
| Gaussian of float array
| Power_law of float array
| Two_gaussian of float array
| Exp_cutoff of float array
| Log_normal of float array
| Skew_gaussian of float array
let state_to_array = function
| Histogram(x) -> Array.append [|0.0|] x
| Gaussian(x) -> Array.append [|1.0|] x
| Power_law(x) -> Array.append [|2.0|] x
| Two_gaussian(x) -> Array.append [|3.0|] x
| Exp_cutoff(x) -> Array.append [|4.0|] x
| Log_normal(x) -> Array.append [|5.0|] x
| Skew_gaussian(x) -> Array.append [|6.0|] x
let array_to_state x =
let n = Array.length x in
let pt = Array.sub x 1 (n-1) in
match x.(0) with
| 0.0 -> Histogram pt
| 1.0 -> Gaussian pt
| 2.0 -> Power_law pt
| 3.0 -> Two_gaussian pt
| 4.0 -> Exp_cutoff pt
| 5.0 -> Log_normal pt
| 6.0 -> Skew_gaussian pt
| _ -> raise (Failure "array_to_state: bad first 'coordinate'")