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 #elif defined(_MSC_VER)
00041   typedef unsigned int uint32_t;
00042   typedef unsigned long long uint64_t;
00043   #define inline
00044 #else
00045   #include <inttypes.h>
00046   #if defined(__GNUC__)
00047     #define inline __inline__
00048   #else
00049     #define inline
00050   #endif
00051 #endif
00052 
00053 #ifndef PRIu64
00054   #if defined(_MSC_VER)
00055     #define PRIu64 "I64u"
00056     #define PRIx64 "I64x"
00057   #else
00058     #define PRIu64 "llu"
00059     #define PRIx64 "llx"
00060   #endif
00061 #endif
00062 
00063 inline uint32_t gen_rand32(void);
00064 inline uint64_t gen_rand64(void);
00065 inline void fill_array32(uint32_t array[], int size);
00066 inline void fill_array64(uint64_t array[], int size);
00067 void init_gen_rand(uint32_t seed);
00068 void init_by_array(uint32_t init_key[], int key_length);
00069 
00070 /* These real versions are due to Isaku Wada */
00072 inline static double to_real1(uint32_t v)
00073 {
00074     return v * (1.0/4294967295.0); 
00075     /* divided by 2^32-1 */ 
00076 }
00077 
00079 inline static double genrand_real1(void)
00080 {
00081     return to_real1(gen_rand32());
00082 }
00083 
00085 inline static double to_real2(uint32_t v)
00086 {
00087     return v * (1.0/4294967296.0); 
00088     /* divided by 2^32 */
00089 }
00090 
00092 inline static double genrand_real2(void)
00093 {
00094     return to_real2(gen_rand32());
00095 }
00096 
00098 inline static double to_real3(uint32_t v)
00099 {
00100     return (((double)v) + 0.5)*(1.0/4294967296.0); 
00101     /* divided by 2^32 */
00102 }
00103 
00105 inline static double genrand_real3(void)
00106 {
00107     return to_real3(gen_rand32());
00108 }
00112 inline static double to_res53(uint64_t v) 
00113 { 
00114     return v * (1.0/18446744073709551616.0L);
00115 }
00116 
00118 inline static double genrand_res53(void) 
00119 { 
00120     return to_res53(gen_rand64());
00121 } 
00122 #endif

Generated on Wed Jan 31 09:31:58 2007 for SFMT19937 by  doxygen 1.4.7