Next: random.sfc32, Previous: random, Up: Top [Contents]
%--------------------------------------------------%
% vim: ft=mercury ts=4 sts=4 sw=4 et
%--------------------------------------------------%
% Copyright (C) 2019, 2022, 2025 The Mercury team.
% This file is distributed under the terms specified in COPYING.LIB.
%--------------------------------------------------%
%
% File: random.sfc16.m.
% Main author: Mark Brown
% Stability: high.
%
% 16-bit Small Fast Counting generator, by Chris Doty-Humphrey.
%
% http://pracrand.sourceforge.net/
%
% From the above:
% "[A] good small chaotic RNG driven by a bad smaller linear RNG.
% The combination gives it the strengths of each - good chaotic behavior,
% but enough structure to avoid short cycles."
%
%--------------------------------------------------%
%--------------------------------------------------%
:- module random.sfc16.
:- interface.
%--------------------------------------------------%
% A fast, 16-bit SFC generator.
%
:- type random.
:- instance random(random).
% Initialise a 16-bit SFC generator with the default seed.
% The resulting generator produces the same sequence every time.
%
:- func init = random.
% Initialise a 16-bit SFC generator with the given seed.
%
:- func seed(uint64) = random.
% Generate a uniformly distributed pseudo-random unsigned integer
% of 8, 16, 32 or 64 bits, respectively.
%
:- pred generate_uint8(uint8::out, random::in, random::out) is det.
:- pred generate_uint16(uint16::out, random::in, random::out) is det.
:- pred generate_uint32(uint32::out, random::in, random::out) is det.
:- pred generate_uint64(uint64::out, random::in, random::out) is det.
%--------------------------------------------------%
%--------------------------------------------------%