move MT19937 random generator to ddsrt
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
dd9aceb713
commit
6e87841ea5
13 changed files with 345 additions and 264 deletions
|
@ -12,13 +12,34 @@
|
|||
#ifndef DDSRT_RANDOM_H
|
||||
#define DDSRT_RANDOM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
DDS_EXPORT long ddsrt_random(void);
|
||||
#define DDSRT_MT19937_N 624
|
||||
|
||||
typedef struct ddsrt_prng_seed {
|
||||
uint32_t key[8];
|
||||
} ddsrt_prng_seed_t;
|
||||
|
||||
typedef struct ddsrt_prng {
|
||||
uint32_t mt[DDSRT_MT19937_N];
|
||||
uint32_t mti;
|
||||
} ddsrt_prng_t;
|
||||
|
||||
DDS_EXPORT void ddsrt_random_init (void);
|
||||
DDS_EXPORT void ddsrt_random_fini (void);
|
||||
|
||||
DDS_EXPORT void ddsrt_prng_init_simple (ddsrt_prng_t *prng, uint32_t seed);
|
||||
DDS_EXPORT bool ddsrt_prng_makeseed (struct ddsrt_prng_seed *seed);
|
||||
DDS_EXPORT void ddsrt_prng_init (ddsrt_prng_t *prng, const struct ddsrt_prng_seed *seed);
|
||||
DDS_EXPORT uint32_t ddsrt_prng_random (ddsrt_prng_t *prng);
|
||||
|
||||
DDS_EXPORT uint32_t ddsrt_random (void);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue