vSMC
vSMC: Scalable Monte Carlo
threefry.h
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/rngc/threefry.h
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2015, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef VSMC_RNGC_THREEFRY_H
33 #define VSMC_RNGC_THREEFRY_H
34 
35 #include <vsmc/internal/config.h>
36 
39 typedef struct {
40  uint32_t v[2];
42 
45 typedef struct {
46  uint32_t v[4];
48 
51 typedef struct {
52  uint64_t v[2];
54 
57 typedef struct {
58  uint64_t v[4];
60 
63 typedef struct {
64  uint32_t v[2];
66 
69 typedef struct {
70  uint32_t v[4];
72 
75 typedef struct {
76  uint64_t v[2];
78 
81 typedef struct {
82  uint64_t v[4];
84 
85 typedef struct {
86  uint32_t v[3];
88 
89 typedef struct {
90  uint32_t v[5];
92 
93 typedef struct {
94  uint64_t v[3];
96 
97 typedef struct {
98  uint64_t v[5];
100 
103 typedef struct {
109 
112 typedef struct {
118 
121 typedef struct {
127 
130 typedef struct {
136 
138 {
139  if (++ctr->v[0] != 0)
140  return;
141  if (++ctr->v[1] != 0)
142  return;
143 }
144 
146 {
147  if (++ctr->v[0] != 0)
148  return;
149  if (++ctr->v[1] != 0)
150  return;
151  if (++ctr->v[2] != 0)
152  return;
153  if (++ctr->v[3] != 0)
154  return;
155 }
156 
158 {
159  if (++ctr->v[0] != 0)
160  return;
161  if (++ctr->v[1] != 0)
162  return;
163 }
164 
166 {
167  if (++ctr->v[0] != 0)
168  return;
169  if (++ctr->v[1] != 0)
170  return;
171  if (++ctr->v[2] != 0)
172  return;
173  if (++ctr->v[3] != 0)
174  return;
175 }
176 
179 {
180  par->v[0] = key->v[0];
181  par->v[1] = key->v[1];
182 
183  par->v[2] = UINT32_C(0x1BD11BDA);
184  par->v[2] ^= par->v[0];
185  par->v[2] ^= par->v[1];
186 }
187 
190 {
191  par->v[0] = key->v[0];
192  par->v[1] = key->v[1];
193  par->v[2] = key->v[2];
194  par->v[3] = key->v[3];
195 
196  par->v[4] = UINT32_C(0x1BD11BDA);
197  par->v[4] ^= par->v[0];
198  par->v[4] ^= par->v[1];
199  par->v[4] ^= par->v[2];
200  par->v[4] ^= par->v[3];
201 }
202 
205 {
206  par->v[0] = key->v[0];
207  par->v[1] = key->v[1];
208 
209  par->v[2] = UINT64_C(0x1BD11BDAA9FC1A22);
210  par->v[2] ^= par->v[0];
211  par->v[2] ^= par->v[1];
212 }
213 
216 {
217  par->v[0] = key->v[0];
218  par->v[1] = key->v[1];
219  par->v[2] = key->v[2];
220  par->v[3] = key->v[3];
221 
222  par->v[4] = UINT64_C(0x1BD11BDAA9FC1A22);
223  par->v[4] ^= par->v[0];
224  par->v[4] ^= par->v[1];
225  par->v[4] ^= par->v[2];
226  par->v[4] ^= par->v[3];
227 }
228 
231 {
232  state->v[0] += state->v[1];
233  state->v[1] = ((state->v[1]) << r) | ((state->v[1]) >> (32 - r));
234  state->v[1] ^= state->v[0];
235 }
236 
238  vsmc_threefry4x32_ctr_t *state, uint32_t r0, uint32_t r2, int i0, int i2)
239 {
240  state->v[0] += state->v[i0];
241  state->v[i0] = ((state->v[i0]) << r0) | ((state->v[i0]) >> (32 - r0));
242  state->v[i0] ^= state->v[0];
243 
244  state->v[2] += state->v[i2];
245  state->v[i2] = ((state->v[i2]) << r2) | ((state->v[i2]) >> (32 - r2));
246  state->v[i2] ^= state->v[2];
247 }
248 
251 {
252  state->v[0] += state->v[1];
253  state->v[1] = ((state->v[1]) << r) | ((state->v[1]) >> (64 - r));
254  state->v[1] ^= state->v[0];
255 }
256 
258  vsmc_threefry4x64_ctr_t *state, uint64_t r0, uint64_t r2, int i0, int i2)
259 {
260  state->v[0] += state->v[i0];
261  state->v[i0] = ((state->v[i0]) << r0) | ((state->v[i0]) >> (64 - r0));
262  state->v[i0] ^= state->v[0];
263 
264  state->v[2] += state->v[i2];
265  state->v[i2] = ((state->v[i2]) << r2) | ((state->v[i2]) >> (64 - r2));
266  state->v[i2] ^= state->v[2];
267 }
268 
271  uint32_t inc, int i0, int i1)
272 {
273  state->v[0] += par->v[i0];
274  state->v[1] += par->v[i1];
275  state->v[1] += inc;
276 }
277 
280  uint32_t inc, int i0, int i1, int i2, int i3)
281 {
282  state->v[0] += par->v[i0];
283  state->v[1] += par->v[i1];
284  state->v[2] += par->v[i2];
285  state->v[3] += par->v[i3];
286  state->v[3] += inc;
287 }
288 
291  uint64_t inc, int i0, int i1)
292 {
293  state->v[0] += par->v[i0];
294  state->v[1] += par->v[i1];
295  state->v[1] += inc;
296 }
297 
300  uint64_t inc, int i0, int i1, int i2, int i3)
301 {
302  state->v[0] += par->v[i0];
303  state->v[1] += par->v[i1];
304  state->v[2] += par->v[i2];
305  state->v[3] += par->v[i3];
306  state->v[3] += inc;
307 }
308 
312  const vsmc_threefry2x32_ctr_t *ctr, const vsmc_threefry2x32_key_t *key,
314 {
315  *state = *ctr;
317  vsmc_threefry2x32_initpar(key, &par);
318 
319  vsmc_threefry2x32_insertkey(state, &par, 0, 0, 1); // N = 0
320  vsmc_threefry2x32_rotate(state, 13); // N = 1
321  vsmc_threefry2x32_rotate(state, 15); // N = 2
322  vsmc_threefry2x32_rotate(state, 26); // N = 3
323  vsmc_threefry2x32_rotate(state, 6); // N = 4
324  vsmc_threefry2x32_insertkey(state, &par, 1, 1, 2); // N = 4
325  vsmc_threefry2x32_rotate(state, 17); // N = 5
326  vsmc_threefry2x32_rotate(state, 29); // N = 6
327  vsmc_threefry2x32_rotate(state, 16); // N = 7
328  vsmc_threefry2x32_rotate(state, 24); // N = 8
329  vsmc_threefry2x32_insertkey(state, &par, 2, 2, 0); // N = 8
330  vsmc_threefry2x32_rotate(state, 13); // N = 9
331  vsmc_threefry2x32_rotate(state, 15); // N = 10
332  vsmc_threefry2x32_rotate(state, 26); // N = 11
333  vsmc_threefry2x32_rotate(state, 6); // N = 12
334  vsmc_threefry2x32_insertkey(state, &par, 3, 0, 1); // N = 12
335  vsmc_threefry2x32_rotate(state, 17); // N = 13
336  vsmc_threefry2x32_rotate(state, 29); // N = 14
337  vsmc_threefry2x32_rotate(state, 16); // N = 15
338  vsmc_threefry2x32_rotate(state, 24); // N = 16
339  vsmc_threefry2x32_insertkey(state, &par, 4, 1, 2); // N = 16
340  vsmc_threefry2x32_rotate(state, 13); // N = 17
341  vsmc_threefry2x32_rotate(state, 15); // N = 18
342  vsmc_threefry2x32_rotate(state, 26); // N = 19
343  vsmc_threefry2x32_rotate(state, 6); // N = 20
344  vsmc_threefry2x32_insertkey(state, &par, 5, 2, 0); // N = 20
345 }
346 
350  const vsmc_threefry4x32_ctr_t *ctr, const vsmc_threefry4x32_key_t *key,
352 {
353  *state = *ctr;
355  vsmc_threefry4x32_initpar(key, &par);
356 
357  vsmc_threefry4x32_insertkey(state, &par, 0, 0, 1, 2, 3); // N = 0
358  vsmc_threefry4x32_rotate(state, 10, 26, 1, 3); // N = 1
359  vsmc_threefry4x32_rotate(state, 11, 21, 3, 1); // N = 2
360  vsmc_threefry4x32_rotate(state, 13, 27, 1, 3); // N = 3
361  vsmc_threefry4x32_rotate(state, 23, 5, 3, 1); // N = 4
362  vsmc_threefry4x32_insertkey(state, &par, 1, 1, 2, 3, 4); // N = 4
363  vsmc_threefry4x32_rotate(state, 6, 20, 1, 3); // N = 5
364  vsmc_threefry4x32_rotate(state, 17, 11, 3, 1); // N = 6
365  vsmc_threefry4x32_rotate(state, 25, 10, 1, 3); // N = 7
366  vsmc_threefry4x32_rotate(state, 18, 20, 3, 1); // N = 8
367  vsmc_threefry4x32_insertkey(state, &par, 2, 2, 3, 4, 0); // N = 8
368  vsmc_threefry4x32_rotate(state, 10, 26, 1, 3); // N = 9
369  vsmc_threefry4x32_rotate(state, 11, 21, 3, 1); // N = 10
370  vsmc_threefry4x32_rotate(state, 13, 27, 1, 3); // N = 11
371  vsmc_threefry4x32_rotate(state, 23, 5, 3, 1); // N = 12
372  vsmc_threefry4x32_insertkey(state, &par, 3, 3, 4, 0, 1); // N = 12
373  vsmc_threefry4x32_rotate(state, 6, 20, 1, 3); // N = 13
374  vsmc_threefry4x32_rotate(state, 17, 11, 3, 1); // N = 14
375  vsmc_threefry4x32_rotate(state, 25, 10, 1, 3); // N = 15
376  vsmc_threefry4x32_rotate(state, 18, 20, 3, 1); // N = 16
377  vsmc_threefry4x32_insertkey(state, &par, 4, 4, 0, 1, 2); // N = 16
378  vsmc_threefry4x32_rotate(state, 10, 26, 1, 3); // N = 17
379  vsmc_threefry4x32_rotate(state, 11, 21, 3, 1); // N = 18
380  vsmc_threefry4x32_rotate(state, 13, 27, 1, 3); // N = 19
381  vsmc_threefry4x32_rotate(state, 23, 5, 3, 1); // N = 20
382  vsmc_threefry4x32_insertkey(state, &par, 5, 0, 1, 2, 3); // N = 20
383 }
384 
388  const vsmc_threefry2x64_ctr_t *ctr, const vsmc_threefry2x64_key_t *key,
390 {
391  *state = *ctr;
393  vsmc_threefry2x64_initpar(key, &par);
394 
395  vsmc_threefry2x64_insertkey(state, &par, 0, 0, 1); // N = 0
396  vsmc_threefry2x64_rotate(state, 16); // N = 1
397  vsmc_threefry2x64_rotate(state, 42); // N = 2
398  vsmc_threefry2x64_rotate(state, 12); // N = 3
399  vsmc_threefry2x64_rotate(state, 31); // N = 4
400  vsmc_threefry2x64_insertkey(state, &par, 1, 1, 2); // N = 4
401  vsmc_threefry2x64_rotate(state, 16); // N = 5
402  vsmc_threefry2x64_rotate(state, 32); // N = 6
403  vsmc_threefry2x64_rotate(state, 24); // N = 7
404  vsmc_threefry2x64_rotate(state, 21); // N = 8
405  vsmc_threefry2x64_insertkey(state, &par, 2, 2, 0); // N = 8
406  vsmc_threefry2x64_rotate(state, 16); // N = 9
407  vsmc_threefry2x64_rotate(state, 42); // N = 10
408  vsmc_threefry2x64_rotate(state, 12); // N = 11
409  vsmc_threefry2x64_rotate(state, 31); // N = 12
410  vsmc_threefry2x64_insertkey(state, &par, 3, 0, 1); // N = 12
411  vsmc_threefry2x64_rotate(state, 16); // N = 13
412  vsmc_threefry2x64_rotate(state, 32); // N = 14
413  vsmc_threefry2x64_rotate(state, 24); // N = 15
414  vsmc_threefry2x64_rotate(state, 21); // N = 16
415  vsmc_threefry2x64_insertkey(state, &par, 4, 1, 2); // N = 16
416  vsmc_threefry2x64_rotate(state, 16); // N = 17
417  vsmc_threefry2x64_rotate(state, 42); // N = 18
418  vsmc_threefry2x64_rotate(state, 12); // N = 19
419  vsmc_threefry2x64_rotate(state, 31); // N = 20
420  vsmc_threefry2x64_insertkey(state, &par, 5, 2, 0); // N = 20
421 }
422 
426  const vsmc_threefry4x64_ctr_t *ctr, const vsmc_threefry4x64_key_t *key,
428 {
429  *state = *ctr;
431  vsmc_threefry4x64_initpar(key, &par);
432 
433  vsmc_threefry4x64_insertkey(state, &par, 0, 0, 1, 2, 3); // N = 0
434  vsmc_threefry4x64_rotate(state, 14, 16, 1, 3); // N = 1
435  vsmc_threefry4x64_rotate(state, 52, 57, 3, 1); // N = 2
436  vsmc_threefry4x64_rotate(state, 23, 40, 1, 3); // N = 3
437  vsmc_threefry4x64_rotate(state, 5, 37, 3, 1); // N = 4
438  vsmc_threefry4x64_insertkey(state, &par, 1, 1, 2, 3, 4); // N = 4
439  vsmc_threefry4x64_rotate(state, 25, 33, 1, 3); // N = 5
440  vsmc_threefry4x64_rotate(state, 46, 12, 3, 1); // N = 6
441  vsmc_threefry4x64_rotate(state, 58, 22, 1, 3); // N = 7
442  vsmc_threefry4x64_rotate(state, 32, 32, 3, 1); // N = 8
443  vsmc_threefry4x64_insertkey(state, &par, 2, 2, 3, 4, 0); // N = 8
444  vsmc_threefry4x64_rotate(state, 14, 16, 1, 3); // N = 9
445  vsmc_threefry4x64_rotate(state, 52, 57, 3, 1); // N = 10
446  vsmc_threefry4x64_rotate(state, 23, 40, 1, 3); // N = 11
447  vsmc_threefry4x64_rotate(state, 5, 37, 3, 1); // N = 12
448  vsmc_threefry4x64_insertkey(state, &par, 3, 3, 4, 0, 1); // N = 12
449  vsmc_threefry4x64_rotate(state, 25, 33, 1, 3); // N = 13
450  vsmc_threefry4x64_rotate(state, 46, 12, 3, 1); // N = 14
451  vsmc_threefry4x64_rotate(state, 58, 22, 1, 3); // N = 15
452  vsmc_threefry4x64_rotate(state, 32, 32, 3, 1); // N = 16
453  vsmc_threefry4x64_insertkey(state, &par, 4, 4, 0, 1, 2); // N = 16
454  vsmc_threefry4x64_rotate(state, 14, 16, 1, 3); // N = 17
455  vsmc_threefry4x64_rotate(state, 52, 57, 3, 1); // N = 18
456  vsmc_threefry4x64_rotate(state, 23, 40, 1, 3); // N = 19
457  vsmc_threefry4x64_rotate(state, 5, 37, 3, 1); // N = 20
458  vsmc_threefry4x64_insertkey(state, &par, 5, 0, 1, 2, 3); // N = 20
459 }
460 
464  vsmc_threefry2x32 *rng, uint32_t seed)
465 {
466  rng->ctr.v[0] = 0;
467  rng->ctr.v[1] = 0;
468  rng->key.v[0] = seed;
469  rng->key.v[1] = 0;
470  rng->index = 2;
471 }
472 
476  vsmc_threefry4x32 *rng, uint32_t seed)
477 {
478  rng->ctr.v[0] = 0;
479  rng->ctr.v[1] = 0;
480  rng->ctr.v[2] = 0;
481  rng->ctr.v[3] = 0;
482  rng->key.v[0] = seed;
483  rng->key.v[1] = 0;
484  rng->key.v[2] = 0;
485  rng->key.v[3] = 0;
486  rng->index = 4;
487 }
488 
492  vsmc_threefry2x64 *rng, uint64_t seed)
493 {
494  rng->ctr.v[0] = 0;
495  rng->ctr.v[1] = 0;
496  rng->key.v[0] = seed;
497  rng->key.v[1] = 0;
498  rng->index = 2;
499 }
500 
504  vsmc_threefry4x64 *rng, uint64_t seed)
505 {
506  rng->ctr.v[0] = 0;
507  rng->ctr.v[1] = 0;
508  rng->ctr.v[2] = 0;
509  rng->ctr.v[3] = 0;
510  rng->key.v[0] = seed;
511  rng->key.v[1] = 0;
512  rng->key.v[2] = 0;
513  rng->key.v[3] = 0;
514  rng->index = 4;
515 }
516 
520 {
521  if (rng->index == 2) {
522  vsmc_threefry2x32_inc(&rng->ctr);
523  vsmc_threefry2x32_gen(&rng->ctr, &rng->key, &rng->state);
524  rng->index = 0;
525  }
526 
527  return rng->state.v[rng->index++];
528 }
529 
533 {
534  if (rng->index == 4) {
535  vsmc_threefry4x32_inc(&rng->ctr);
536  vsmc_threefry4x32_gen(&rng->ctr, &rng->key, &rng->state);
537  rng->index = 0;
538  }
539 
540  return rng->state.v[rng->index++];
541 }
542 
546 {
547  if (rng->index == 2) {
548  vsmc_threefry2x64_inc(&rng->ctr);
549  vsmc_threefry2x64_gen(&rng->ctr, &rng->key, &rng->state);
550  rng->index = 0;
551  }
552 
553  return rng->state.v[rng->index++];
554 }
555 
559 {
560  if (rng->index == 4) {
561  vsmc_threefry4x64_inc(&rng->ctr);
562  vsmc_threefry4x64_gen(&rng->ctr, &rng->key, &rng->state);
563  rng->index = 0;
564  }
565 
566  return rng->state.v[rng->index++];
567 }
568 
569 #endif // VSMC_RNGC_THREEFRY_H
#define UINT64_C(x)
Definition: opencl.h:42
static void vsmc_threefry4x32_initpar(const vsmc_threefry4x32_key_t *key, vsmc_threefry4x32_par_t *par)
Definition: threefry.h:188
static void vsmc_threefry4x32_rotate(vsmc_threefry4x32_ctr_t *state, uint32_t r0, uint32_t r2, int i0, int i2)
Definition: threefry.h:237
static void vsmc_threefry2x32_init(vsmc_threefry2x32 *rng, uint32_t seed)
Initialize Threefry2x32 RNG state.
Definition: threefry.h:463
static void vsmc_threefry4x32_inc(vsmc_threefry4x32_ctr_t *ctr)
Definition: threefry.h:145
uint32_t index
Definition: threefry.h:107
uint uint32_t
Definition: opencl.h:39
static void vsmc_threefry2x64_inc(vsmc_threefry2x64_ctr_t *ctr)
Definition: threefry.h:157
ulong uint64_t
Definition: opencl.h:40
vsmc_threefry2x32_key_t key
Definition: threefry.h:106
static void vsmc_threefry4x64_init(vsmc_threefry4x64 *rng, uint64_t seed)
Initialize Threefry4x64 RNG state.
Definition: threefry.h:503
uint64_t index
Definition: threefry.h:125
uint64_t index
Definition: threefry.h:134
Threefry2x64 counter type.
Definition: threefry.h:51
static void vsmc_threefry2x64_init(vsmc_threefry2x64 *rng, uint64_t seed)
Initialize Threefry2x64 RNG state.
Definition: threefry.h:491
static void vsmc_threefry2x32_gen(const vsmc_threefry2x32_ctr_t *ctr, const vsmc_threefry2x32_key_t *key, vsmc_threefry2x32_ctr_t *state)
Generate Threefry2x32 RNG state.
Definition: threefry.h:311
vsmc_threefry2x64_ctr_t ctr
Definition: threefry.h:123
static void vsmc_threefry4x64_insertkey(vsmc_threefry4x64_ctr_t *state, const vsmc_threefry4x64_par_t *par, uint64_t inc, int i0, int i1, int i2, int i3)
Definition: threefry.h:298
Threefry4x64 counter type.
Definition: threefry.h:57
static void vsmc_threefry2x64_rotate(vsmc_threefry2x64_ctr_t *state, uint64_t r)
Definition: threefry.h:249
static void vsmc_threefry4x64_initpar(const vsmc_threefry4x64_key_t *key, vsmc_threefry4x64_par_t *par)
Definition: threefry.h:214
static void vsmc_threefry2x32_initpar(const vsmc_threefry2x32_key_t *key, vsmc_threefry2x32_par_t *par)
Definition: threefry.h:177
vsmc_threefry4x32_ctr_t state
Definition: threefry.h:113
vsmc_threefry4x32_key_t key
Definition: threefry.h:115
static void vsmc_threefry4x64_gen(const vsmc_threefry4x64_ctr_t *ctr, const vsmc_threefry4x64_key_t *key, vsmc_threefry4x64_ctr_t *state)
Generate Threefry4x64 RNG state.
Definition: threefry.h:425
static void vsmc_threefry4x32_init(vsmc_threefry4x32 *rng, uint32_t seed)
Initialize Threefry4x32 RNG state.
Definition: threefry.h:475
vsmc_threefry4x64_key_t key
Definition: threefry.h:133
static void vsmc_threefry4x32_insertkey(vsmc_threefry4x32_ctr_t *state, const vsmc_threefry4x32_par_t *par, uint32_t inc, int i0, int i1, int i2, int i3)
Definition: threefry.h:278
vsmc_threefry2x32_ctr_t state
Definition: threefry.h:104
Threefry2x32 counter type.
Definition: threefry.h:39
Threefry4x32 key type.
Definition: threefry.h:69
vsmc_threefry4x64_ctr_t state
Definition: threefry.h:131
static uint64_t vsmc_threefry2x64_rand(vsmc_threefry2x64 *rng)
Generate random 64-bits integers from Threefry2x64 RNG.
Definition: threefry.h:545
#define VSMC_STATIC_INLINE
Definition: opencl.h:48
Threefry2x32 RNG state structure.
Definition: threefry.h:103
Threefry2x64 RNG state structure.
Definition: threefry.h:121
static uint32_t vsmc_threefry2x32_rand(vsmc_threefry2x32 *rng)
Generate random 32-bits integers from Threefry2x32 RNG.
Definition: threefry.h:519
Threefry4x32 counter type.
Definition: threefry.h:45
vsmc_threefry4x32_ctr_t ctr
Definition: threefry.h:114
static void vsmc_threefry2x32_insertkey(vsmc_threefry2x32_ctr_t *state, const vsmc_threefry2x32_par_t *par, uint32_t inc, int i0, int i1)
Definition: threefry.h:269
Threefry4x32 RNG state structure.
Definition: threefry.h:112
Threefry4x64 RNG state structure.
Definition: threefry.h:130
static void vsmc_threefry2x64_gen(const vsmc_threefry2x64_ctr_t *ctr, const vsmc_threefry2x64_key_t *key, vsmc_threefry2x64_ctr_t *state)
Generate Threefry2x64 RNG state.
Definition: threefry.h:387
Threefry2x32 key type.
Definition: threefry.h:63
static void vsmc_threefry2x64_insertkey(vsmc_threefry2x64_ctr_t *state, const vsmc_threefry2x64_par_t *par, uint64_t inc, int i0, int i1)
Definition: threefry.h:289
vsmc_threefry2x64_key_t key
Definition: threefry.h:124
static uint64_t vsmc_threefry4x64_rand(vsmc_threefry4x64 *rng)
Generate random 64-bits integers from Threefry4x64 RNG.
Definition: threefry.h:558
static void vsmc_threefry4x64_rotate(vsmc_threefry4x64_ctr_t *state, uint64_t r0, uint64_t r2, int i0, int i2)
Definition: threefry.h:257
uint32_t index
Definition: threefry.h:116
static void vsmc_threefry2x64_initpar(const vsmc_threefry2x64_key_t *key, vsmc_threefry2x64_par_t *par)
Definition: threefry.h:203
vsmc_threefry4x64_ctr_t ctr
Definition: threefry.h:132
Threefry4x64 key type.
Definition: threefry.h:81
static uint32_t vsmc_threefry4x32_rand(vsmc_threefry4x32 *rng)
Generate random 32-bits integers from Threefry4x32 RNG.
Definition: threefry.h:532
#define UINT32_C(x)
Definition: opencl.h:41
static void vsmc_threefry4x32_gen(const vsmc_threefry4x32_ctr_t *ctr, const vsmc_threefry4x32_key_t *key, vsmc_threefry4x32_ctr_t *state)
Generate Threefry4x32 RNG state.
Definition: threefry.h:349
static void vsmc_threefry2x32_rotate(vsmc_threefry2x32_ctr_t *state, uint32_t r)
Definition: threefry.h:229
vsmc_threefry2x64_ctr_t state
Definition: threefry.h:122
Threefry2x64 key type.
Definition: threefry.h:75
static void vsmc_threefry4x64_inc(vsmc_threefry4x64_ctr_t *ctr)
Definition: threefry.h:165
vsmc_threefry2x32_ctr_t ctr
Definition: threefry.h:105
static void vsmc_threefry2x32_inc(vsmc_threefry2x32_ctr_t *ctr)
Definition: threefry.h:137