gsl-ocaml / lib / rng.mli

(* gsl-ocaml - OCaml interface to GSL                       *)
(* Copyright (©) 2002-2005 - Olivier Andrieu                *)
(* Distributed under the terms of the LGPL version 2.1      *)

(** Random Number Generation *)

type rng_type =
  | BOROSH13
  | COVEYOU
  | CMRG
  | FISHMAN18
  | FISHMAN20
  | FISHMAN2X
  | GFSR4
  | KNUTHRAN
  | KNUTHRAN2
  | KNUTHRAN2002
  | LECUYER21
  | MINSTD
  | MRG
  | MT19937
  | MT19937_1999
  | MT19937_1998
  | R250
  | RAN0
  | RAN1
  | RAN2
  | RAN3
  | RAND
  | RAND48
  | RANDOM128_BSD
  | RANDOM128_GLIBC2
  | RANDOM128_LIBC5
  | RANDOM256_BSD
  | RANDOM256_GLIBC2
  | RANDOM256_LIBC5
  | RANDOM32_BSD
  | RANDOM32_GLIBC2
  | RANDOM32_LIBC5
  | RANDOM64_BSD
  | RANDOM64_GLIBC2
  | RANDOM64_LIBC5
  | RANDOM8_BSD
  | RANDOM8_GLIBC2
  | RANDOM8_LIBC5
  | RANDOM_BSD
  | RANDOM_GLIBC2
  | RANDOM_LIBC5
  | RANDU
  | RANF
  | RANLUX
  | RANLUX389
  | RANLXD1
  | RANLXD2
  | RANLXS0
  | RANLXS1
  | RANLXS2
  | RANMAR
  | SLATEC
  | TAUS
  | TAUS_2
  | TAUS_113
  | TRANSPUTER
  | TT800
  | UNI
  | UNI32
  | VAX
  | WATERMAN14
  | ZUF

type t

(** {3 Default values} *)

external default : unit -> rng_type 
    = "ml_gsl_rng_get_default"
external default_seed : unit -> nativeint 
    = "ml_gsl_rng_get_default_seed"

external set_default : rng_type -> unit
    = "ml_gsl_rng_set_default"
external set_default_seed : nativeint -> unit
    = "ml_gsl_rng_set_default_seed"

external env_setup : unit -> unit 
    = "ml_gsl_rng_env_setup"


(** {3 Creating} *)

val make : rng_type -> t

external set  : t -> nativeint -> unit = "ml_gsl_rng_set"
external name : t -> string = "ml_gsl_rng_name"
external get_type :  t-> rng_type = "ml_gsl_rng_get_type"

(** warning : the nativeint used for seeds are in fact unsigned but
   ocaml treats them as signed.
   But you can still print them using %nu with printf functions. *)

external max : t -> nativeint = "ml_gsl_rng_max"
external min : t -> nativeint = "ml_gsl_rng_min"

external memcpy : t -> t -> unit = "ml_gsl_rng_memcpy"
external clone  : t -> t = "ml_gsl_rng_clone"

external dump_state : t -> string * string = "ml_gsl_rng_dump_state"
external set_state  : t -> string * string -> unit = "ml_gsl_rng_set_state"

(** {3 Sampling} *)

external get : t -> nativeint = "ml_gsl_rng_get"
external uniform : t -> float = "ml_gsl_rng_uniform"
external uniform_pos : t -> float = "ml_gsl_rng_uniform_pos"
external uniform_int : t -> int -> int = "ml_gsl_rng_uniform_int" "noalloc"

(** These function fill the array with random numbers : *)

external uniform_arr     : t -> float array -> unit 
    = "ml_gsl_rng_uniform_arr" "noalloc"
external uniform_pos_arr : t -> float array -> unit 
    = "ml_gsl_rng_uniform_pos_arr" "noalloc"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.