SFMT19937: sfmt19937.h Source File

- Main Page
- Data Structures
- Files

- File List
- Globals

# sfmt19937.h

Go to the documentation of this file.

    00001
    00033 #ifndef SFMT19937_H
    00034 #define SFMT19937_H
    00035
    00036 #include <stdio.h>
    00037
    00038 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
    00039   #include <inttypes.h>
    00040   #define INLINE inline
    00041 #elif defined(_MSC_VER)
    00042   typedef unsigned int uint32_t;
    00043   typedef unsigned long long uint64_t;
    00044   #define INLINE
    00045 #else
    00046   #include <inttypes.h>
    00047   #if defined(__GNUC__)
    00048     #define INLINE __inline__
    00049   #endif
    00050 #endif
    00051
    00052 #ifndef PRIu64
    00053   #if defined(_MSC_VER)
    00054     #define PRIu64 "I64u"
    00055     #define PRIx64 "I64x"
    00056   #else
    00057     #define PRIu64 "llu"
    00058     #define PRIx64 "llx"
    00059   #endif
    00060 #endif
    00061
    00062 INLINE uint32_t gen_rand32(void);
    00063 INLINE uint64_t gen_rand64(void);
    00064 INLINE void fill_array32(uint32_t array[], int size);
    00065 INLINE void fill_array64(uint64_t array[], int size);
    00066 void init_gen_rand(uint32_t seed);
    00067 void init_by_array(uint32_t init_key[], int key_length);
    00068
    00069 /* These real versions are due to Isaku Wada */
    00070 /* generates a random number on [0,1]-real-interval */
    00071 INLINE static double genrand_real1(void)
    00072 {
    00073     return gen_rand32()*(1.0/4294967295.0);
    00074     /* divided by 2^32-1 */
    00075 }
    00076
    00077 /* generates a random number on [0,1)-real-interval */
    00078 INLINE static double genrand_real2(void)
    00079 {
    00080     return gen_rand32()*(1.0/4294967296.0);
    00081     /* divided by 2^32 */
    00082 }
    00083
    00084 /* generates a random number on (0,1)-real-interval */
    00085 INLINE static double genrand_real3(void)
    00086 {
    00087     return (((double)gen_rand32()) + 0.5)*(1.0/4294967296.0);
    00088     /* divided by 2^32 */
    00089 }
    00090 /* These real versions are due to Isaku Wada */
    00091
    00092 /* generates a random number on [0,1) with 53-bit resolution*/
    00093 INLINE static double genrand_res53(void)
    00094 {
    00095     return gen_rand64()*(1.0/18446744073709551616.0L);
    00096 }
    00097 #endif