package grenier
A collection of various algorithms in OCaml
Install
Dune Dependency
Authors
Maintainers
Sources
grenier-v0.11.tbz
sha256=658e1ad6fc5fdce0871975b3ebcb3ec760248be63cdb9ea965e3121cc7478d77
sha512=d9ff83f1b025f34c22af5921444993df219761dcee8d8cb5a940f266df8677278967434b22314c5c82d5d983e4c94c04cd52c4717d5c1f22fbd3a022631fae1c
doc/src/grenier.pcg/pcg.ml.html
Source file pcg.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 41 42 43 44 45 46 47 48 49 50 51 52 53 54
module State : sig type t val create : unit -> t val get : t -> int64 val set : t -> int64 -> unit val inc_get : t -> int64 val inc_set : t -> int64 -> unit end = struct type t = (int64, Bigarray.int64_elt, Bigarray.c_layout) Bigarray.Array1.t let create () : t = Bigarray.Array1.create Bigarray.int64 Bigarray.c_layout 2 let get (t : t) = Bigarray.Array1.unsafe_get t 0 let set (t : t) v = Bigarray.Array1.unsafe_set t 0 v let inc_get (t : t) = Bigarray.Array1.unsafe_get t 1 let inc_set (t : t) v = Bigarray.Array1.unsafe_set t 1 v end type t = State.t let pure_advance state inc = Int64.(add (mul state 6364136223846793005L) inc) let pure_peek s = let (lsl) = Int64.shift_left and (lsr) = Int64.shift_right_logical and (lor) = Int64.logor and (lxor) = Int64.logxor in let x = ((s lsr 18) lxor s) lsr 27 and r = Int64.to_int (s lsr 59) in (x lsr r) lor (x lsl ((-r) land 31)) let advance t = State.set t (pure_advance (State.get t) (State.inc_get t)) let reseed t ~state ~seq = State.set t 0L; State.inc_set t Int64.(logor (shift_left seq 1) 1L); advance t; State.set t (Int64.add (State.get t) seq); advance t let create ~state ~seq = let t = State.create () in reseed t ~state ~seq; t let get_int32 t = let s = State.get t in advance t; Int64.to_int32 (pure_peek s) let get_int t = let s = State.get t in advance t; Int64.to_int (pure_peek s)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>