COMBINATORIAL_BLAS
1.3
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
graph500-1.2
generator
splittable_mrg.h
Go to the documentation of this file.
1
/* Copyright (C) 2010 The Trustees of Indiana University. */
2
/* */
3
/* Use, modification and distribution is subject to the Boost Software */
4
/* License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at */
5
/* http://www.boost.org/LICENSE_1_0.txt) */
6
/* */
7
/* Authors: Jeremiah Willcock */
8
/* Andrew Lumsdaine */
9
10
#ifndef SPLITTABLE_MRG_H
11
#define SPLITTABLE_MRG_H
12
13
#include <stdint.h>
14
15
/* Multiple recursive generator from L'Ecuyer, P., Blouin, F., and */
16
/* Couture, R. 1993. A search for good multiple recursive random number */
17
/* generators. ACM Trans. Model. Comput. Simul. 3, 2 (Apr. 1993), 87-98. */
18
/* DOI= http://doi.acm.org/10.1145/169702.169698 -- particular generator */
19
/* used is from table 3, entry for m = 2^31 - 1, k = 5 (same generator */
20
/* is used in GNU Scientific Library). */
21
22
/* See notes at top of splittable_mrg.c for information on this */
23
/* implementation. */
24
25
#ifdef __cplusplus
26
extern
"C"
{
27
#endif
28
29
typedef
struct
mrg_transition_matrix
{
30
uint_fast32_t
s
,
t
,
u
,
v
,
w
;
31
/* Cache for other parts of matrix (see mrg_update_cache function) */
32
uint_fast32_t
a
,
b
,
c
,
d
;
33
}
mrg_transition_matrix
;
34
35
typedef
struct
mrg_state
{
36
uint_fast32_t
z1
,
z2
,
z3
,
z4
,
z5
;
37
}
mrg_state
;
38
39
/* Returns integer value in [0, 2^31-1) */
40
uint_fast32_t
mrg_get_uint
(
const
mrg_transition_matrix
* mat,
mrg_state
* state);
41
42
/* Returns real value in [0, 1) */
43
double
mrg_get_double
(
const
mrg_transition_matrix
* mat,
mrg_state
* state);
44
45
/* Returns integer value in [0, 2^31-1) using original transition matrix */
46
uint_fast32_t
mrg_get_uint_orig
(
mrg_state
* state);
47
48
/* Returns real value in [0, 1) using original transition matrix */
49
double
mrg_get_double_orig
(
mrg_state
* state);
50
51
void
mrg_init
(
mrg_transition_matrix
* tm,
mrg_state
* st);
52
53
void
mrg_seed
(
mrg_state
* st,
const
uint_fast32_t seed[5]);
54
55
/* Split a transition matrix; the result of this function is pre-cached so it
56
* does not need to be called for individual splits of the PRNG state. */
57
void
mrg_split_matrix
(
const
mrg_transition_matrix
* tm_in,
58
mrg_transition_matrix
* tm_out,
59
unsigned
int
n);
60
61
/* The variable st_out should be an array of length n; all other parameters are
62
* single elements.
63
*
64
* The state st_in should not be used for random number generation after this
65
* function is called. */
66
void
mrg_split_state
(
const
mrg_transition_matrix
* tm_in,
67
const
mrg_state
* st_in,
68
mrg_state
* st_out,
69
unsigned
int
n);
70
71
/* Skip the PRNG ahead _exponent_ steps. This code treats the exponent as a
72
* 192-bit word, even though the PRNG period is less than that. */
73
void
mrg_skip
(
mrg_state
* state,
74
uint_least64_t exponent_high,
75
uint_least64_t exponent_middle,
76
uint_least64_t exponent_low);
77
78
#ifdef __cplusplus
79
}
80
#endif
81
82
#endif
/* SPLITTABLE_MRG_H */
Generated on Wed Feb 6 2013 01:36:32 for COMBINATORIAL_BLAS by
1.8.1.1