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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
let e = 2.71828182845904523536028747135
let log2e = 1.44269504088896340735992468100
let log10e = 0.43429448190325182765112891892
let sqrt2 = 1.41421356237309504880168872421
let sqrt1_2 = 0.70710678118654752440084436210
let sqrt3 = 1.73205080756887729352744634151
let pi = 3.14159265358979323846264338328
let pi_2 = 1.57079632679489661923132169164
let pi_4 = 0.78539816339744830966156608458
let sqrtpi = 1.77245385090551602729816748334
let i_2_sqrtpi = 1.12837916709551257389615890312
let i_1_pi = 0.31830988618379067153776752675
let i_2_pi = 0.63661977236758134307553505349
let ln10 = 2.30258509299404568401799145468
let ln2 = 0.69314718055994530941723212146
let lnpi = 1.14472988584940017414342735135
let euler = 0.57721566490153286060651209008
let rec unsafe_pow_int x = function
| 1 -> x
| n when n mod 2 = 0 ->
unsafe_pow_int (x *. x) (n/2)
| n ->
x *. (unsafe_pow_int x (pred n))
let pow_int x = function
| 0 -> 1.
| n when n > 0 -> unsafe_pow_int x n
| _ -> invalid_arg "pow_int"
external log1p : float -> float
= "ml_gsl_log1p" "gsl_log1p" [@@unboxed] [@@noalloc]
external expm1 : float -> float
= "ml_gsl_expm1" "gsl_expm1" [@@unboxed] [@@noalloc]
external hypot : float -> float -> float
= "ml_gsl_hypot" "gsl_hypot" [@@unboxed] [@@noalloc]
external acosh : float -> float
= "ml_gsl_acosh" "gsl_acosh" [@@unboxed] [@@noalloc]
external asinh : float -> float
= "ml_gsl_asinh" "gsl_asinh" [@@unboxed] [@@noalloc]
external atanh : float -> float
= "ml_gsl_atanh" "gsl_atanh" [@@unboxed] [@@noalloc]
external fcmp : float -> float -> epsilon:float -> int
= "ml_gsl_fcmp"