SFMT.h

Go to the documentation of this file.
00001 
00031 #ifndef SFMT_H
00032 #define SFMT_H
00033 
00034 #include <stdio.h>
00035 
00036 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
00037   #include <inttypes.h>
00038 #elif defined(_MSC_VER) || defined(__BORLANDC__)
00039   typedef unsigned int uint32_t;
00040   typedef unsigned __int64 uint64_t;
00041   #define inline __inline
00042 #else
00043   #include <inttypes.h>
00044   #if defined(__GNUC__)
00045     #define inline __inline__
00046   #endif
00047 #endif
00048 
00049 #ifndef PRIu64
00050   #if defined(_MSC_VER) || defined(__BORLANDC__)
00051     #define PRIu64 "I64u"
00052     #define PRIx64 "I64x"
00053   #else
00054     #define PRIu64 "llu"
00055     #define PRIx64 "llx"
00056   #endif
00057 #endif
00058 
00059 #if defined(__GNUC__)
00060 #define ALWAYSINLINE __attribute__((always_inline))
00061 #endif
00062 
00063 uint32_t gen_rand32(void);
00064 uint64_t gen_rand64(void);
00065 void fill_array32(uint32_t *array, int size);
00066 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 const char *get_idstring(void);
00070 int get_min_array_size32(void);
00071 int get_min_array_size64(void);
00072 
00073 /* These real versions are due to Isaku Wada */
00075 inline static double to_real1(uint32_t v)
00076 {
00077     return v * (1.0/4294967295.0); 
00078     /* divided by 2^32-1 */ 
00079 }
00080 
00082 inline static double genrand_real1(void)
00083 {
00084     return to_real1(gen_rand32());
00085 }
00086 
00088 inline static double to_real2(uint32_t v)
00089 {
00090     return v * (1.0/4294967296.0); 
00091     /* divided by 2^32 */
00092 }
00093 
00095 inline static double genrand_real2(void)
00096 {
00097     return to_real2(gen_rand32());
00098 }
00099 
00101 inline static double to_real3(uint32_t v)
00102 {
00103     return (((double)v) + 0.5)*(1.0/4294967296.0); 
00104     /* divided by 2^32 */
00105 }
00106 
00108 inline static double genrand_real3(void)
00109 {
00110     return to_real3(gen_rand32());
00111 }
00115 inline static double to_res53(uint64_t v) 
00116 { 
00117     return v * (1.0/18446744073709551616.0L);
00118 }
00119 
00121 inline static double genrand_res53(void) 
00122 { 
00123     return to_res53(gen_rand64());
00124 } 
00125 #endif

Generated on Sat Jun 2 10:53:08 2007 for SFMT by  doxygen 1.4.7