QGIS API Documentation
2.6.0-Brighton
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
src
analysis
vector
mersenne-twister.h
Go to the documentation of this file.
1
/*
2
* The Mersenne Twister pseudo-random number generator (PRNG)
3
*
4
* This is an implementation of fast PRNG called MT19937,
5
* meaning it has a period of 2^19937-1, which is a Mersenne
6
* prime.
7
*
8
* This PRNG is fast and suitable for non-cryptographic code.
9
* For instance, it would be perfect for Monte Carlo simulations,
10
* etc.
11
*
12
* This code has been designed as a drop-in replacement for libc rand and
13
* srand(). If you need to mix them, you should encapsulate this code in a
14
* namespace.
15
*
16
* Written by Christian Stigen Larsen
17
* 2012-01-11 -- http://csl.sublevel3.org
18
*
19
* Distributed under the modified BSD license.
20
*/
21
22
#ifndef MERSENNE_TWISTER_H
23
#define MERSENNE_TWISTER_H
24
25
#ifndef _MSC_VER
26
#include <stdint.h>
27
#else
28
typedef
__int32 int32_t;
29
typedef
unsigned
__int32 uint32_t;
30
typedef
__int64 int64_t;
31
typedef
unsigned
__int64 uint64_t;
32
#endif
33
#include <limits>
34
35
#ifdef __cplusplus
36
extern
"C"
37
{
38
#endif
39
40
/*
41
* Maximum number you can get from rand().
42
*/
43
#define MD_RAND_MAX std::numeric_limits<int32_t>::max()
44
45
/*
46
* Initialize the number generator with given seed.
47
* (LIBC REPLACEMENT FUNCTION)
48
*/
49
void
mt_srand
(
unsigned
seed_value );
50
51
/*
52
* Extract a pseudo-random integer in the range 0 ... MD_RAND_MAX.
53
* (LIBC REPLACEMENT FUNCTION)
54
*/
55
int
mt_rand
();
56
57
/*
58
* Extract a pseudo-random unsigned 32-bit integer in the range 0 ... MD_UINT32_MAX
59
*/
60
uint32_t
rand_u32
();
61
62
/*
63
* Combine two unsigned 32-bit pseudo-random numbers into one 64-bit
64
*/
65
uint64_t
rand_u64
();
66
67
/*
68
* Initialize Mersenne Twister with given seed value.
69
*/
70
void
seed
( uint32_t seed_value );
71
72
/*
73
* Return a random float in the CLOSED range [0, 1]
74
* Mnemonic: randf_co = random float 0=closed 1=closed
75
*/
76
float
randf_cc
();
77
78
/*
79
* Return a random float in the OPEN range [0, 1>
80
* Mnemonic: randf_co = random float 0=closed 1=open
81
*/
82
float
randf_co
();
83
84
/*
85
* Return a random float in the OPEN range <0, 1>
86
* Mnemonic: randf_oo = random float 0=open 1=open
87
*/
88
float
randf_oo
();
89
90
/*
91
* Return a random double in the CLOSED range [0, 1]
92
* Mnemonic: randd_co = random double 0=closed 1=closed
93
*/
94
double
randd_cc
();
95
96
/*
97
* Return a random double in the OPEN range [0, 1>
98
* Mnemonic: randd_co = random double 0=closed 1=open
99
*/
100
double
randd_co
();
101
102
/*
103
* Return a random double in the OPEN range <0, 1>
104
* Mnemonic: randd_oo = random double 0=open 1=open
105
*/
106
double
randd_oo
();
107
108
#ifdef __cplusplus
109
}
// extern "C"
110
#endif
111
112
#endif // MERSENNE_TWISTER_H
Generated on Fri Oct 31 2014 15:49:45 for QGIS API Documentation by
1.8.1.2