3
Copyright (c) 2013-2017 Gustav Hartvigsson
5
Permission is hereby granted, free of charge, to any person obtaining a copy
6
of this software and associated documentation files (the "Software"), to deal
7
in the Software without restriction, including without limitation the rights
8
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
copies of the Software, and to permit persons to whom the Software is
10
furnished to do so, subject to the following conditions:
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/C-LANG/mt19937-64.c
27
with the following license:
29
Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura,
32
Redistribution and use in source and binary forms, with or without
33
modification, are permitted provided that the following conditions
36
1. Redistributions of source code must retain the above copyright
37
notice, this list of conditions and the following disclaimer.
39
2. Redistributions in binary form must reproduce the above copyright
40
notice, this list of conditions and the following disclaimer in the
41
documentation and/or other materials provided with the distribution.
43
3. The names of its contributors may not be used to endorse or promote
44
products derived from this software without specific prior written
47
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
51
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
52
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
53
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
54
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
55
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
56
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
57
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70
* @defgroup Random Random
76
* An opaque data type that represents the a random value generator.
78
* SRandom is the perfered psuedo random number generator in libssts.
79
* It is object oriented and as such can be very versitile.
81
* What it uses internally (right now) is an adapted version of mt19937-64 by
82
* Makoto Matsumoto and Takuji Nishimura. (see:
83
* http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/C-LANG/mt19937-64.c)
85
* It will genrate a 64 bit random number. To use this
87
typedef struct SRandom SRandom;
95
s_random_free (SRandom * self);
99
s_random_new_with_seed (sulong seed);
103
s_random_reseed (SRandom * self, sulong seed);
107
s_random_next (SRandom * self);
111
s_random_current (SRandom * self);
114
* Generate a random number between @f$0@f$ and @f$2^{63}-1@f$
118
s_random_next_long (SRandom * self);
121
* Generate a random real number in the interval @f$[0 ... 1]@f$.
125
s_random_next_real (SRandom * self);
128
* Get the current random as a number between @f$0@f$ and @f$2^{63}-1@f$
132
s_random_current_long (SRandom * self);
135
* Get the current random as a real number in the interval @f$[0 ... 1]@f$.
139
s_random_current_real (SRandom * self);
142
/* Get entropy from the system, how this is done under the hood is platform
145
* @note Do not abuse this as a source of random numbers, that will deplete the
146
* entropy pool, which is not desirable.
150
s_random_get_entropy ();