vSMC
vSMC: Scalable Monte Carlo
Classes | Macros | Typedefs | Functions
urng.h File Reference
#include <vsmc/rng/internal/common.h>
#include <Random123/threefry.h>
#include <Random123/philox.h>

Go to the source code of this file.

Classes

struct  philox2x32_rng_t
 
struct  philox2x64_rng_t
 
struct  philox4x32_rng_t
 
struct  philox4x64_rng_t
 
struct  threefry2x32_rng_t
 
struct  threefry2x64_rng_t
 
struct  threefry4x32_rng_t
 
struct  threefry4x64_rng_t
 

Macros

#define cburng2x32_init   threefry2x32_init
 
#define cburng2x32_rand   threefry2x32_rand
 
#define cburng2x64_init   threefry2x64_init
 
#define cburng2x64_rand   threefry2x64_rand
 
#define cburng4x32_init   threefry4x32_init
 
#define cburng4x32_rand   threefry4x32_rand
 
#define cburng4x64_init   threefry4x64_init
 
#define cburng4x64_rand   threefry4x64_rand
 
#define VSMC_DEFINE_RNG_URNG_INIT(RNG, N, W)
 
#define VSMC_DEFINE_RNG_URNG_RAND(RNG, N, W)
 
#define VSMC_DEFINE_RNG_URNG_RNG_T(RNG, N, W)
 

Typedefs

typedef threefry2x32_rng_t cburng2x32_rng_t
 
typedef threefry2x64_rng_t cburng2x64_rng_t
 
typedef threefry4x32_rng_t cburng4x32_rng_t
 
typedef threefry4x64_rng_t cburng4x64_rng_t
 

Functions

static void philox2x32_init (philox2x32_rng_t *rng, uint32_t seed)
 
static uint32_t philox2x32_rand (philox2x32_rng_t *rng)
 
static void philox2x64_init (philox2x64_rng_t *rng, uint64_t seed)
 
static uint64_t philox2x64_rand (philox2x64_rng_t *rng)
 
static void philox4x32_init (philox4x32_rng_t *rng, uint32_t seed)
 
static uint32_t philox4x32_rand (philox4x32_rng_t *rng)
 
static void philox4x64_init (philox4x64_rng_t *rng, uint64_t seed)
 
static uint64_t philox4x64_rand (philox4x64_rng_t *rng)
 
static void threefry2x32_init (threefry2x32_rng_t *rng, uint32_t seed)
 
static uint32_t threefry2x32_rand (threefry2x32_rng_t *rng)
 
static void threefry2x64_init (threefry2x64_rng_t *rng, uint64_t seed)
 
static uint64_t threefry2x64_rand (threefry2x64_rng_t *rng)
 
static void threefry4x32_init (threefry4x32_rng_t *rng, uint32_t seed)
 
static uint32_t threefry4x32_rand (threefry4x32_rng_t *rng)
 
static void threefry4x64_init (threefry4x64_rng_t *rng, uint64_t seed)
 
static uint64_t threefry4x64_rand (threefry4x64_rng_t *rng)
 

Macro Definition Documentation

#define VSMC_DEFINE_RNG_URNG_INIT (   RNG,
  N,
 
)
Value:
VSMC_STATIC_INLINE void RNG##N##x##W##_init( \
RNG##N##x##W##_rng_t *rng, uint##W##_t seed) \
{ \
RNG##N##x##W##_ctr_t init_ctr = {{}}; \
RNG##N##x##W##_ukey_t ukey = {{}}; \
rng->ctr = init_ctr; \
rng->rnd = init_ctr; \
ukey.v[0] = seed; \
rng->key = RNG##N##x##W##keyinit(ukey); \
rng->remain = 0; \
}
#define VSMC_STATIC_INLINE
Definition: common.h:70

Definition at line 187 of file urng.h.

#define VSMC_DEFINE_RNG_URNG_RAND (   RNG,
  N,
 
)
Value:
VSMC_STATIC_INLINE uint##W##_t RNG##N##x##W##_rand( \
RNG##N##x##W##_rng_t *rng) \
{ \
unsigned char remain = rng->remain; \
RNG##N##x##W##_ctr_t rnd = rng->rnd; \
\
if (remain > 0) { \
--remain; \
rng->remain = remain; \
return rnd.v[remain]; \
} \
\
RNG##N##x##W##_ctr_t ctr = rng->ctr; \
RNG##N##x##W##_key_t key = rng->key; \
\
remain = N - 1; \
ctr.v[0]++; \
rnd = RNG##N##x##W(ctr, key); \
\
rng->remain = remain; \
rng->rnd = rnd; \
rng->ctr = ctr; \
rng->key = key; \
\
return rnd.v[remain]; \
}
#define VSMC_STATIC_INLINE
Definition: common.h:70

Definition at line 200 of file urng.h.

#define VSMC_DEFINE_RNG_URNG_RNG_T (   RNG,
  N,
 
)
Value:
typedef struct { \
RNG##N##x##W##_key_t key; \
RNG##N##x##W##_ctr_t ctr; \
RNG##N##x##W##_ctr_t rnd; \
unsigned char remain; \
} RNG##N##x##W##_rng_t;

Definition at line 179 of file urng.h.