TPCCLIB
Loading...
Searching...
No Matches
tpcrand.h
Go to the documentation of this file.
1
7#ifndef _TPCRAND_H_
8#define _TPCRAND_H_
9/*****************************************************************************/
10
11/*****************************************************************************/
12#include "tpcclibConfig.h"
13/*****************************************************************************/
14#include <stdio.h>
15#include <stdlib.h>
16#include <string.h>
17#include <math.h>
18#include <sys/time.h>
19#include <stdint.h>
20#include <inttypes.h>
21/*****************************************************************************/
22#include "tpcextensions.h"
23/*****************************************************************************/
24
25/*****************************************************************************/
27#define TPCCLIB_MERTWI_NN 312
29#define TPCCLIB_MERTWI_A UINT64_C(0xB5026F5AA96619E9)
32typedef struct MERTWI {
34 unsigned int n;
36 unsigned int m;
38 uint64_t a;
40 uint64_t um;
42 uint64_t lm;
46 uint64_t mti;
47} MERTWI;
48/*****************************************************************************/
49
50/*****************************************************************************/
51/* mertwi */
52extern uint32_t mertwiSeed32(void);
53extern uint64_t mertwiSeed64(void);
54extern void mertwiInit(MERTWI *mt);
55extern void mertwiInitWithSeed64(MERTWI *mt, uint64_t seed);
56extern void mertwiInitByArray64(MERTWI *mt, uint64_t init_key[], uint64_t key_length);
57extern uint64_t mertwiRandomInt64(MERTWI *mt);
58extern int64_t mertwiRandomInt63(MERTWI *mt);
59extern double mertwiRandomDouble1(MERTWI *mt);
60extern double mertwiRandomDouble2(MERTWI *mt);
61extern double mertwiRandomDouble3(MERTWI *mt);
62extern double mertwiRandomGaussian(MERTWI *mt);
63extern double mertwiRandomExponential(MERTWI *mt, double mean);
64extern int mertwiRandomBetween(MERTWI *mt, unsigned int nr, double *d, double low, double up, int type);
65/*****************************************************************************/
66
67/*****************************************************************************/
68/* gaussdev */
69extern unsigned int drandSeed(short int seed);
70extern double drand();
71extern int drandRange(unsigned int nr, double *d, double low, double up, int type);
72extern double drandGaussian();
73extern double drandExponential(double mean);
74/*****************************************************************************/
75
76/*****************************************************************************/
77/* shuffle */
78extern void randomShuffle(int *array, unsigned int n, MERTWI *mt);
79extern void randomShuffleUnsigned(unsigned int *array, unsigned int n, MERTWI *mt);
80extern void randomPermutation(int *array, unsigned int n, int a, MERTWI *mt);
81extern void randomPermutationUnsigned(unsigned int *array, unsigned int n, unsigned int a, MERTWI *mt);
82/*****************************************************************************/
83
84/*****************************************************************************/
85/* halton */
86extern int haltonElement(const int i, const int dim, double *r);
87extern int haltonPrime(const int N);
88/*****************************************************************************/
89
90/*****************************************************************************/
91#endif /* TPCRAND */
uint64_t mt[TPCCLIB_MERTWI_NN]
Definition tpcrand.h:44
uint64_t mti
Definition tpcrand.h:46
unsigned int m
Definition tpcrand.h:36
uint64_t lm
Definition tpcrand.h:42
uint64_t a
Definition tpcrand.h:38
uint64_t um
Definition tpcrand.h:40
unsigned int n
Definition tpcrand.h:34
Header file for library libtpcextensions.
double drand()
Definition gaussdev.c:66
int drandRange(unsigned int nr, double *d, double low, double up, int type)
Definition gaussdev.c:90
int mertwiRandomBetween(MERTWI *mt, unsigned int nr, double *d, double low, double up, int type)
Fill the given double array with random numbers with uniform distribution between the specified limit...
Definition mertwi.c:270
#define TPCCLIB_MERTWI_NN
Definition tpcrand.h:27
uint64_t mertwiRandomInt64(MERTWI *mt)
Generate a random number on [0, 2^64-1]-interval using Mersenne Twister MT19937.
Definition mertwi.c:153
double drandExponential(double mean)
Get pseudo-random number with exponential distribution.
Definition gaussdev.c:178
void randomShuffle(int *array, unsigned int n, MERTWI *mt)
Random shuffle.
Definition shuffle.c:27
void mertwiInitWithSeed64(MERTWI *mt, uint64_t seed)
Initialize the state vector mt[] inside data structure for Mersenne Twister MT19937 pseudo-random num...
Definition mertwi.c:94
double mertwiRandomDouble1(MERTWI *mt)
Generate a 64-bit double precision floating point pseudo-random number in the range of [0,...
Definition mertwi.c:216
int haltonElement(const int i, const int dim, double *r)
Calculation of an element of quasi-random low-discrepancy Halton sequence.
Definition halton.c:38
void mertwiInitByArray64(MERTWI *mt, uint64_t init_key[], uint64_t key_length)
Initialize the state vector mt[] inside data structure for Mersenne Twister MT19937 pseudo-random num...
Definition mertwi.c:113
double mertwiRandomGaussian(MERTWI *mt)
Generate a 64-bit double precision floating point pseudo-random number with normal (Gaussian) distrib...
Definition mertwi.c:354
double mertwiRandomExponential(MERTWI *mt, double mean)
Generate pseudo-random number with exponential distribution and specified mean.
Definition mertwi.c:322
void randomPermutationUnsigned(unsigned int *array, unsigned int n, unsigned int a, MERTWI *mt)
Random permutation for an array of unsigned integers.
Definition shuffle.c:106
int haltonPrime(const int N)
Subfunction for calculation of quasi-random Halton sequence.
Definition halton.c:75
uint64_t mertwiSeed64(void)
Make uint64_t seed for pseudo-random number generators.
Definition mertwi.c:76
void randomShuffleUnsigned(unsigned int *array, unsigned int n, MERTWI *mt)
Random shuffle.
Definition shuffle.c:54
void randomPermutation(int *array, unsigned int n, int a, MERTWI *mt)
Random permutation for an array of signed integers.
Definition shuffle.c:80
double mertwiRandomDouble2(MERTWI *mt)
Generate a 64-bit double precision floating point pseudo-random number in the range of [0,...
Definition mertwi.c:232
double drandGaussian()
Get pseudo-random number with normal (Gaussian) distribution with mean 0 and SD 1.
Definition gaussdev.c:144
void mertwiInit(MERTWI *mt)
Definition mertwi.c:28
int64_t mertwiRandomInt63(MERTWI *mt)
Generate a random number on [0, 2^63-1]-interval using Mersenne Twister MT19937.
Definition mertwi.c:197
double mertwiRandomDouble3(MERTWI *mt)
Generate a 64-bit double precision floating point pseudo-random number in the range of (0,...
Definition mertwi.c:248
uint32_t mertwiSeed32(void)
Make uint32_t seed for pseudo-random number generators.
Definition mertwi.c:48
unsigned int drandSeed(short int seed)
Make and optionally set the seed for rand(), drand, drandRange, and drandGaussian().
Definition gaussdev.c:27