csnip
0.1
src
csnip
runif.h
Go to the documentation of this file.
1
#ifndef CSNIP_RUNIF_H
2
#define CSNIP_RUNIF_H
3
9
#include <
csnip/rng.h
>
10
11
/* Generation of integer uniform random variables
12
*
13
* Each variant generates uniform integer random variables in { 0, 1,
14
* ..., max } (the upper bound, max, is inclusive).
15
*
16
* The generated random variables are uniform, provided that the
17
* underlying random number generator produces uniform numbers.
18
*/
19
unsigned
long
long
int
csnip_runif_getull(
const
csnip_rng
* R,
20
unsigned
long
long
int
max);
21
unsigned
long
csnip_runif_getul(
const
csnip_rng
* R,
22
unsigned
long
max);
23
unsigned
int
csnip_runif_getu(
const
csnip_rng
* R,
unsigned
int
max);
24
25
#define csnip_runif_Geti(R, max) \
26
_Generic((max), \
27
unsigned long long int: \
28
csnip_runif_getull((R), (unsigned long long int)(max)), \
29
long long int: \
30
(long long int)csnip_runif_getull((R), (long long int)(max)), \
31
unsigned long int: \
32
csnip_runif_getul((R), (unsigned long int)(max)), \
33
long int: \
34
(long int)csnip_runif_getul((R), (long int)(max)), \
35
unsigned int: \
36
csnip_runif_getu((R), (unsigned int)(max)), \
37
int: \
38
(int)csnip_runif_getu((R), (int)(max)), \
39
default: \
40
csnip_runif_getu((R), (unsigned int)(max)))
41
42
/* Generation of floating point uniform random variables */
43
long
double
csnip_runif_getld(
const
csnip_rng
* R,
long
double
lim);
44
double
csnip_runif_getd(
const
csnip_rng
* R,
double
lim);
45
float
csnip_runif_getf(
const
csnip_rng
* R,
float
lim);
46
47
#define csnip_runif_Getf(R, lim) \
48
_Generic((lim), \
49
long double: csnip_runif_getld((R), (lim)), \
50
double: csnip_runif_getd((R), (lim)), \
51
float: csnip_runif_getf((R), (lim)))
52
53
#endif
/* CSNIP_RUNIF_H */
54
55
#if defined(CSNIP_SHORT_NAMES) && !defined(CSNIP_RUNIF_HAVE_SHORT_NAMES)
56
#define runif_getull csnip_runif_getull
57
#define runif_getul csnip_runif_getul
58
#define runif_getu csnip_runif_getu
59
#define runif_Geti csnip_runif_Geti
60
#define runif_getld csnip_runif_getld
61
#define runif_getd csnip_runif_getd
62
#define runif_getf csnip_runif_getf
63
#define runif_Getf csnip_runif_Getf
64
#define CSNIP_RUNIF_HAVE_SHORT_NAMES
65
#endif
/* CSNIP_SHORT_NAMES && !CSNIP_RUNIF_HAVE_SHORT_NAMES */
rng.h
csnip_rng_T
Method table for a random number generator.
Definition:
rng.h:12
Generated by
1.9.1