efros_freeman
0.1
Main Page
Related Pages
Data Structures
Files
File List
Globals
random_number.h
Go to the documentation of this file.
1
/*
2
Copyright (c) 2016 rafael grompone von gioi <grompone@gmail.com>
3
4
Quilting is free software: you can redistribute it and/or modify
5
it under the terms of the GNU Affero General Public License as
6
published by the Free Software Foundation, either version 3 of the
7
License, or (at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU Affero General Public License for more details.
13
14
You should have received a copy of the GNU Affero General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
/**
19
* @file random_number.h
20
* @brief this header file contains all definitions.
21
*
22
* @author rafael grompone von gioi
23
*
24
* @date 05/02/2011
25
*/
26
27
#ifndef RANDOM_NUMBER_H_
28
#define RANDOM_NUMBER_H_
29
30
/*----------------------------------------------------------------------------*/
31
/* random_number generator limites. */
32
#define RANDOM_MIN 1
33
#define RANDOM_MAX 2147483562
34
35
/*----------------------------------------------------------------------------*/
36
/* Uniform random number generator in [1,2147483562].
37
38
This algorithm is described and analyzed on:
39
40
"Efficient and Portable Combined Random Number Generators"
41
by Pierre L'Ecuyer, Communications of the ACM, vol. 31, num. 6,
42
pp. 742-749 and 774, June 1988.
43
44
This code is a modification from the code available at
45
http://cg.scs.carleton.ca/~luc/lecuyer.c
46
on February 5, 2011.
47
48
The algorithm is based on two combined Multiplicative Linear
49
Congruential Generators (MLCGs). The generator produces double
50
numbers in the range (0,1), (it will never return 0.0 or 1.0).
51
The period of the generator is about 2.30584 x 10^18,
52
in the order of 2^61.
53
54
A normal call is in the form 'uniform_rand(NULL)'.
55
But it can also be called giving a pointer to long with a seed:
56
long seed = 263287632;
57
uniform_rand(&seed);
58
This is usually done only once. The function 'rand_time_seed'
59
performs this initilization with the current time.
60
61
The state of the generator is determined by the static variables
62
s1 and s2, that must take values in the following intervals:
63
64
s1 in [1,2147483562]
65
s2 in [1,2147483398]
66
*/
67
long
random_number
(
long
* seed);
68
69
#endif
Generated on Tue Dec 20 2016 13:56:24 for efros_freeman by
1.8.1.2