diff --git a/Utils/Util.ml b/Utils/Util.ml index c19b4fc..e81b8d0 100644 --- a/Utils/Util.ml +++ b/Utils/Util.ml @@ -1,4 +1,5 @@ include Constants +external erf_float : float -> float = "erf_float_bytecode" "erf_float" [@@unboxed] [@@noalloc] let factmax = 150 @@ -12,7 +13,10 @@ let rec boys_function ~maxm t = begin if t = 0. then [| 1. |] else let sq_t = sqrt t in + (* [| (sq_pi_over_two /. sq_t) *. Gsl.Sf.erf sq_t |] + *) + [| (sq_pi_over_two /. sq_t) *. erf_float sq_t |] end | _ -> begin @@ -87,3 +91,5 @@ let chop f g = if (abs_float f) < cutoff then 0. else f *. (g ()) + + diff --git a/Utils/math_functions.c b/Utils/math_functions.c new file mode 100644 index 0000000..4109aab --- /dev/null +++ b/Utils/math_functions.c @@ -0,0 +1,15 @@ +#include +#include +#include + + +CAMLprim value erf_float_bytecode(value x) +{ + return copy_double(erf(Double_val(x))); +} + +CAMLprim double erf_float(double x) +{ + return erf(x); +} + diff --git a/_tags b/_tags index e3819e0..7199fb1 100644 --- a/_tags +++ b/_tags @@ -1 +1,3 @@ true: package(str,gsl,zarith) +<*.byte> : linkdep(Utils/math_functions.o) +<*.native>: linkdep(Utils/math_functions.o) diff --git a/myocamlbuild.ml b/myocamlbuild.ml new file mode 100644 index 0000000..321f3e9 --- /dev/null +++ b/myocamlbuild.ml @@ -0,0 +1,8 @@ + +open Ocamlbuild_plugin;; + +dispatch (function + | After_rules -> + pdep ["link"] "linkdep" (fun param -> [param]) + | _ -> ()) +