10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-06 22:23:42 +01:00
This commit is contained in:
Anthony Scemama 2018-02-01 22:19:23 +01:00
parent b5ee17ca3e
commit daf96d567b
4 changed files with 31 additions and 0 deletions

View File

@ -1,4 +1,5 @@
include Constants include Constants
external erf_float : float -> float = "erf_float_bytecode" "erf_float" [@@unboxed] [@@noalloc]
let factmax = 150 let factmax = 150
@ -12,7 +13,10 @@ let rec boys_function ~maxm t =
begin begin
if t = 0. then [| 1. |] else if t = 0. then [| 1. |] else
let sq_t = sqrt t in let sq_t = sqrt t in
(*
[| (sq_pi_over_two /. sq_t) *. Gsl.Sf.erf sq_t |] [| (sq_pi_over_two /. sq_t) *. Gsl.Sf.erf sq_t |]
*)
[| (sq_pi_over_two /. sq_t) *. erf_float sq_t |]
end end
| _ -> | _ ->
begin begin
@ -87,3 +91,5 @@ let chop f g =
if (abs_float f) < cutoff then 0. if (abs_float f) < cutoff then 0.
else f *. (g ()) else f *. (g ())

15
Utils/math_functions.c Normal file
View File

@ -0,0 +1,15 @@
#include <math.h>
#include <caml/mlvalues.h>
#include <caml/alloc.h>
CAMLprim value erf_float_bytecode(value x)
{
return copy_double(erf(Double_val(x)));
}
CAMLprim double erf_float(double x)
{
return erf(x);
}

2
_tags
View File

@ -1 +1,3 @@
true: package(str,gsl,zarith) true: package(str,gsl,zarith)
<*.byte> : linkdep(Utils/math_functions.o)
<*.native>: linkdep(Utils/math_functions.o)

8
myocamlbuild.ml Normal file
View File

@ -0,0 +1,8 @@
open Ocamlbuild_plugin;;
dispatch (function
| After_rules ->
pdep ["link"] "linkdep" (fun param -> [param])
| _ -> ())