| 1 |
|
| 2 |
|
| 3 |
#ifndef eslRANDOM_INCLUDED |
| 4 |
#define eslRANDOM_INCLUDED |
| 5 |
#include <esl_config.h> |
| 6 |
|
| 7 |
#include <stdio.h> |
| 8 |
#include <stdint.h> |
| 9 |
|
| 10 |
#define eslRND_FAST 0 |
| 11 |
#define eslRND_MERSENNE 1 |
| 12 |
|
| 13 |
typedef struct { |
| 14 |
int type; |
| 15 |
int mti; |
| 16 |
uint32_t mt[624]; |
| 17 |
uint32_t x; |
| 18 |
uint32_t seed; |
| 19 |
} ESL_RANDOMNESS; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
extern ESL_RANDOMNESS *esl_randomness_Create (uint32_t seed); |
| 25 |
extern ESL_RANDOMNESS *esl_randomness_CreateFast(uint32_t seed); |
| 26 |
extern ESL_RANDOMNESS *esl_randomness_CreateTimeseeded(void); |
| 27 |
extern void esl_randomness_Destroy(ESL_RANDOMNESS *r); |
| 28 |
extern int esl_randomness_Init(ESL_RANDOMNESS *r, uint32_t seed); |
| 29 |
extern uint32_t esl_randomness_GetSeed(const ESL_RANDOMNESS *r); |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
extern double esl_random (ESL_RANDOMNESS *r); |
| 34 |
extern uint32_t esl_random_uint32(ESL_RANDOMNESS *r); |
| 35 |
extern int esl_rnd_Roll (ESL_RANDOMNESS *r, int n); |
| 36 |
extern uint32_t esl_rnd_mix3(uint32_t a, uint32_t b, uint32_t c); |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
extern int esl_randomness_Dump(FILE *fp, ESL_RANDOMNESS *r); |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
extern double esl_rnd_UniformPositive(ESL_RANDOMNESS *r); |
| 45 |
extern double esl_rnd_Gaussian (ESL_RANDOMNESS *rng, double mean, double stddev); |
| 46 |
extern double esl_rnd_Gamma (ESL_RANDOMNESS *rng, double a); |
| 47 |
extern int esl_rnd_Dirichlet(ESL_RANDOMNESS *rng, const double *alpha, int K, double *p); |
| 48 |
extern int esl_rnd_Deal (ESL_RANDOMNESS *rng, int m, int n, int *deal); |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
extern int esl_rnd_DChoose (ESL_RANDOMNESS *r, const double *p, int N); |
| 53 |
extern int esl_rnd_FChoose (ESL_RANDOMNESS *r, const float *p, int N); |
| 54 |
extern int esl_rnd_DChooseCDF(ESL_RANDOMNESS *r, const double *cdf, int N); |
| 55 |
extern int esl_rnd_FChooseCDF(ESL_RANDOMNESS *r, const float *cdf, int N); |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
extern int esl_rnd_mem (ESL_RANDOMNESS *rng, void *buf, int n); |
| 60 |
extern int esl_rnd_floatstring(ESL_RANDOMNESS *rng, char *s); |
| 61 |
|
| 62 |
#endif |