2014-09-16 13:09:14 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Freie Universität Berlin
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
2013-11-27 16:28:31 +01:00
|
|
|
|
|
|
|
/**
|
2013-11-27 17:54:30 +01:00
|
|
|
* @defgroup sys_random Random
|
|
|
|
* @ingroup sys
|
|
|
|
* @brief Random number generator
|
2013-11-27 16:28:31 +01:00
|
|
|
*/
|
2014-02-11 18:15:43 +01:00
|
|
|
|
2014-10-14 11:33:31 +02:00
|
|
|
#ifndef RANDOM_H
|
|
|
|
#define RANDOM_H
|
|
|
|
|
2013-08-20 08:56:22 +02:00
|
|
|
#include <inttypes.h>
|
|
|
|
|
2014-10-10 11:51:11 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-08-26 21:58:45 +02:00
|
|
|
#ifndef PRNG_FLOAT
|
|
|
|
# define PRNG_FLOAT (0)
|
|
|
|
#endif
|
2013-08-20 08:56:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief initializes mt[N] with a seed
|
|
|
|
*
|
|
|
|
* @param s seed for the PRNG
|
|
|
|
*/
|
2013-08-22 01:08:56 +02:00
|
|
|
void genrand_init(uint32_t s);
|
2013-08-20 08:56:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief initialize by an array with array-length
|
|
|
|
* init_key is the array for initializing keys
|
|
|
|
* key_length is its length
|
|
|
|
* slight change for C++, 2004/2/26
|
|
|
|
*
|
|
|
|
* @param init_key array of keys (seeds) to initialize the PRNG
|
|
|
|
* @param key_length number of lements in init_key
|
|
|
|
*/
|
2013-08-22 01:08:56 +02:00
|
|
|
void genrand_init_by_array(uint32_t init_key[], int key_length);
|
2013-08-20 08:56:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief generates a random number on [0,0xffffffff]-interval
|
|
|
|
* @return a random number on [0,0xffffffff]-interval
|
|
|
|
*/
|
|
|
|
uint32_t genrand_uint32(void);
|
|
|
|
|
|
|
|
|
|
|
|
#if PRNG_FLOAT
|
|
|
|
/* These real versions are due to Isaku Wada, 2002/01/09 added */
|
|
|
|
|
|
|
|
/**
|
2013-08-22 01:08:56 +02:00
|
|
|
* @brief generates a random number on [0,1)-real-interval
|
|
|
|
* @return a random number on [0,1)-real-interval
|
2013-08-20 08:56:22 +02:00
|
|
|
*/
|
2013-08-22 01:08:56 +02:00
|
|
|
double genrand_real(void);
|
2013-08-20 08:56:22 +02:00
|
|
|
|
|
|
|
/**
|
2013-08-22 01:08:56 +02:00
|
|
|
* @brief generates a random number on [0,1]-real-interval
|
|
|
|
* @return a random number on [0,1]-real-interval
|
2013-08-20 08:56:22 +02:00
|
|
|
*/
|
2013-08-22 01:08:56 +02:00
|
|
|
double genrand_real_inclusive(void);
|
2013-08-20 08:56:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief generates a random number on (0,1)-real-interval
|
|
|
|
* @return a random number on (0,1)-real-interval
|
|
|
|
*/
|
2013-08-22 01:08:56 +02:00
|
|
|
double genrand_real_exclusive(void);
|
2013-08-20 08:56:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief generates a random number on [0,1) with 53-bit resolution
|
|
|
|
* @return a random number on [0,1) with 53-bit resolution
|
|
|
|
*/
|
|
|
|
double genrand_res53(void);
|
|
|
|
|
|
|
|
#endif /* PRNG_FLOAT */
|
2014-10-10 11:51:11 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2014-10-14 11:33:31 +02:00
|
|
|
|
|
|
|
#endif /* RANDOM_H */
|