00001 00031 #ifndef DSFMT_H 00032 #define DSFMT_H 00033 00034 #include <stdio.h> 00035 00036 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) 00037 #include <inttypes.h> 00038 #elif defined(_MSC_VER) 00039 typedef unsigned int uint32_t; 00040 typedef unsigned long long uint64_t; 00041 #define inline 00042 #else 00043 #include <inttypes.h> 00044 #if defined(__GNUC__) 00045 #define inline __inline__ 00046 #else 00047 #define inline 00048 #endif 00049 #endif 00050 00051 #ifndef PRIu64 00052 #if defined(_MSC_VER) 00053 #define PRIu64 "I64u" 00054 #define PRIx64 "I64x" 00055 #else 00056 #define PRIu64 "llu" 00057 #define PRIx64 "llx" 00058 #endif 00059 #endif 00060 00061 #ifndef UINT64_C 00062 #define UINT64_C(v) (v ## ULL) 00063 #endif 00064 00065 #ifdef __GNUC__ 00066 inline double genrand_close1_open2(void); 00067 inline static double genrand_close_open(void) __attribute__((always_inline)); 00068 inline static double genrand_open_close(void) __attribute__((always_inline)); 00069 inline static double genrand_open_open(void) __attribute__((always_inline)); 00070 #else 00071 inline double genrand_close1_open2(void); 00072 inline static double genrand_close_open(void); 00073 inline static double genrand_open_close(void); 00074 inline static double genrand_open_open(void); 00075 #endif 00076 00077 void fill_array_open_close(double array[], int size); 00078 void fill_array_close_open(double array[], int size); 00079 void fill_array_open_open(double array[], int size); 00080 void fill_array_close1_open2(double array[], int size); 00081 char *get_idstring(void); 00082 int get_min_array_size(void); 00083 void init_gen_rand(uint32_t seed); 00084 void init_by_array(uint32_t init_key[], int key_length); 00085 00093 inline static double genrand_close_open(void) { 00094 return genrand_close1_open2() - 1.0L; 00095 } 00096 00104 inline static double genrand_open_close(void) { 00105 return 2.0L - genrand_close1_open2(); 00106 } 00107 00115 inline static double genrand_open_open(void) { 00116 union { 00117 uint64_t u; 00118 double d; 00119 } conv; 00120 00121 conv.d = genrand_close1_open2(); 00122 conv.u |= 1; 00123 return conv.d - 1.0L; 00124 } 00125 00126 #endif /* DSFMT_H */