Source file sum.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
31
32
33
34
35
36
37
38
39
40
(* gsl-ocaml - OCaml interface to GSL                       *)
(* Copyright (©) 2002-2012 - Olivier Andrieu                *)
(* Distributed under the terms of the GPL version 3         *)

let () = Error.init ()

type ws

external _alloc : int -> ws = "ml_gsl_sum_levin_u_alloc"
external _free : ws -> unit = "ml_gsl_sum_levin_u_free"

let make size =
  let ws = _alloc size in
  Gc.finalise _free ws;
  ws

external accel : float array -> ws -> Fun.result = "ml_gsl_sum_levin_u_accel"

type ws_info = { size : int; terms_used : int; sum_plain : float }

external get_info : ws -> ws_info = "ml_gsl_sum_levin_u_getinfo"

module Trunc = struct
  type ws

  external _alloc : int -> ws = "ml_gsl_sum_levin_utrunc_alloc"
  external _free : ws -> unit = "ml_gsl_sum_levin_utrunc_free"

  let make size =
    let ws = _alloc size in
    Gc.finalise _free ws;
    ws

  external accel : float array -> ws -> Fun.result
    = "ml_gsl_sum_levin_utrunc_accel"

  type ws_info = { size : int; terms_used : int; sum_plain : float }

  external get_info : ws -> ws_info = "ml_gsl_sum_levin_utrunc_getinfo"
end