+ #if defined(__GNUC__)
+ #define inline __inline__
+ #else
+ #define inline
+ #endif
+#endif
+
+#ifndef PRIu64
+ #if defined(_MSC_VER) || defined(__BORLANDC__)
+ #define PRIu64 "I64u"
+ #define PRIx64 "I64x"
+ #else
+ #define PRIu64 "llu"
+ #define PRIx64 "llx"
+ #endif
+#endif
+
+#ifndef UINT64_C
+ #define UINT64_C(v) (v ## ULL)
+#endif
+
+inline double genrand_close1_open2(void);
+#if defined(__GNUC__)
+inline static double genrand_close_open(void) __attribute__((always_inline));
+inline static double genrand_open_close(void) __attribute__((always_inline));
+inline static double genrand_open_open(void) __attribute__((always_inline));
+#elif defined(_MSC_VER) && _MSC_VER >= 1200
+__forceinline static double genrand_close_open(void);
+__forceinline static double genrand_open_close(void);
+__forceinline static double genrand_open_open(void);
+#else
+inline static double genrand_close_open(void);
+inline static double genrand_open_close(void);
+inline static double genrand_open_open(void);
+#endif
+
+void fill_array_open_close(double array[], int size);
+void fill_array_close_open(double array[], int size);
+void fill_array_open_open(double array[], int size);
+void fill_array_close1_open2(double array[], int size);
+const char *get_idstring(void);
+int get_min_array_size(void);
+void init_gen_rand(uint32_t seed);
+void init_by_array(uint32_t init_key[], int key_length);
+
+/**
+ * This function generates and returns double precision pseudorandom
+ * number which distributes uniformly in the range [0, 1).
+ * init_gen_rand() or init_by_array() must be called before this
+ * function.
+ * @return double precision floating point pseudorandom number
+ */
+inline static double genrand_close_open(void) {
+ return genrand_close1_open2() - 1.0;
+}
+
+/**
+ * This function generates and returns double precision pseudorandom
+ * number which distributes uniformly in the range (0, 1].
+ * init_gen_rand() or init_by_array() must be called before this
+ * function.
+ * @return double precision floating point pseudorandom number
+ */
+inline static double genrand_open_close(void) {
+ return 2.0 - genrand_close1_open2();
+}
+
+/**
+ * This function generates and returns double precision pseudorandom
+ * number which distributes uniformly in the range (0, 1).
+ * init_gen_rand() or init_by_array() must be called before this
+ * function.
+ * @return double precision floating point pseudorandom number
+ */
+inline static double genrand_open_open(void) {
+ union {
+ uint64_t u;
+ double d;
+ } conv;
+
+ conv.d = genrand_close1_open2();
+ conv.u |= 1;
+ return conv.d - 1.0;
+}
+
+#endif /* DSFMT_H */
diff --git a/dSFMT/html/annotated.html b/dSFMT/html/annotated.html
new file mode 100644
index 0000000..9687ffd
--- /dev/null
+++ b/dSFMT/html/annotated.html
@@ -0,0 +1,26 @@
+
+
+dSFMT: Data Structures
+
+
+
+
+
+
+dSFMT Data Structures Here are the data structures with brief descriptions:
+ W128_T 128-bit data structure
+
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/d_s_f_m_t_8c.html b/dSFMT/html/d_s_f_m_t_8c.html
new file mode 100644
index 0000000..c6b4e7b
--- /dev/null
+++ b/dSFMT/html/d_s_f_m_t_8c.html
@@ -0,0 +1,895 @@
+
+
+dSFMT: dSFMT.c File Reference
+
+
+
+
+
+
+dSFMT.c File Reference double precision SIMD-oriented Fast Mersenne Twister (dSFMT) based on IEEE 754 format. More...
+
+#include <string.h>
+#include <assert.h>
+#include "dSFMT.h "
+#include "dSFMT-params.h"
+
+
+Data Structures
+union W128_T
+
+ 128-bit data structure More...
+Typedefs
+typedef W128_T w128_t
+
+ 128-bit data type
+Functions
+static void lshift128 (w128_t *out, const w128_t *in, int shift)
+
+ This function simulates SIMD 128-bit left shift by the standard C.
+static void gen_rand_all (void)
+
+ This function fills the internal state array with double precision floating point pseudorandom numbers of the IEEE 754 format.
+static void gen_rand_array (w128_t array[], int size)
+
+ This function fills the user-specified array with double precision floating point pseudorandom numbers of the IEEE 754 format.
+static uint32_t ini_func1 (uint32_t x)
+
+ This function represents a function used in the initialization by init_by_array.
+static uint32_t ini_func2 (uint32_t x)
+
+ This function represents a function used in the initialization by init_by_array.
+static void convert_co (w128_t array[], int size)
+
+ This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range [0, 1).
+static void convert_oc (w128_t array[], int size)
+
+ This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range (0, 1].
+static void convert_oo (w128_t array[], int size)
+
+ This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range (0, 1).
+static int sfmt_idxof (int i)
+
+ This function simulate a 32-bit array index overlapped to 64-bit array of LITTLE ENDIAN in BIG ENDIAN machine.
+static void initial_mask (void)
+
+ This function initializes the internal state array to fit the IEEE 754 format.
+static void period_certification ()
+
+ This function certificate the period of 2^{SFMT_MEXP}-1.
+static void do_recursion (w128_t *r, w128_t *a, w128_t *b, w128_t *c, w128_t *lung)
+
+ This function represents the recursion formula.
+const char * get_idstring (void)
+
+ This function returns the identification string.
+int get_min_array_size (void)
+
+ This function returns the minimum size of array used for fill_array functions.
+double genrand_close1_open2 (void)
+
+ This function generates and returns double precision pseudorandom number which distributes uniformly in the range [1, 2).
+void fill_array_close1_open2 (double array[], int size)
+
+ This function generates double precision floating point pseudorandom numbers which distribute in the range [1, 2) to the specified array[] by one call.
+void fill_array_open_close (double array[], int size)
+
+ This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1] to the specified array[] by one call.
+void fill_array_close_open (double array[], int size)
+
+ This function generates double precision floating point pseudorandom numbers which distribute in the range [0, 1) to the specified array[] by one call.
+void fill_array_open_open (double array[], int size)
+
+ This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1) to the specified array[] by one call.
+void init_gen_rand (uint32_t seed)
+
+ This function initializes the internal state array with a 32-bit integer seed.
+void init_by_array (uint32_t init_key[], int key_length)
+
+ This function initializes the internal state array, with an array of 32-bit integers used as the seeds.
+Variables
+static w128_t sfmt [SFMT_N+1]
+
+ the 128-bit internal state array
+static double * psfmt64 = &sfmt [0].d[0]
+
+ the double pointer to the 128-bit internal state array
+static int sfmt_idx
+
+ index counter to the internal state array as double
+static int is_sfmt_initialized = 0
+
+ a flag: it is 0 if and only if the internal state is not yet initialized.
+
+Detailed Description
+double precision SIMD-oriented Fast Mersenne Twister (dSFMT) based on IEEE 754 format.
+
+
Author: Mutsuo Saito (Hiroshima University)
+Makoto Matsumoto (Hiroshima University)
+Copyright (C) 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. All rights reserved.
+The new BSD License is applied to this software, see LICENSE.txt
Typedef Documentation
+
+
+
+
+
+
+128-bit data type
+
+
+
+
+
Function Documentation
+
+
+
+
+
+ static void convert_co
+ (
+ w128_t
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range [0, 1).
+
+
Parameters:
+
+ array array of double precision floating point numbers
+ size size of the array
+
+
+
+
+
+
+
+
+
+
+ static void convert_oc
+ (
+ w128_t
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range (0, 1].
+
+
Parameters:
+
+ array array of double precision floating point numbers
+ size size of the array
+
+
+
+
+
+
+
+
+
+
+ static void convert_oo
+ (
+ w128_t
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range (0, 1).
+
+
Parameters:
+
+ array array of double precision floating point numbers
+ size size of the array
+
+
+
+
+
+
+
+
+
+
+ static void do_recursion
+ (
+ w128_t *
+ r ,
+
+
+
+
+ w128_t *
+ a ,
+
+
+
+
+ w128_t *
+ b ,
+
+
+
+
+ w128_t *
+ c ,
+
+
+
+
+ w128_t *
+ lung
+
+
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function represents the recursion formula.
+
+
Parameters:
+
+ r output
+ a a 128-bit part of the internal state array
+ b a 128-bit part of the internal state array
+ c a 128-bit part of the internal state array
+ lung a 128-bit part of the internal state array
+
+
+
+
+
+
+
+
+
+
+ void fill_array_close1_open2
+ (
+ double
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+
+
+
+
+
+
+
+This function generates double precision floating point pseudorandom numbers which distribute in the range [1, 2) to the specified array[] by one call.
+
+The number of pseudorandom numbers is specified by the argument size , which must be at least (SFMT_MEXP / 128) * 2 and a multiple of two. The function get_min_array_size() returns this minimum size. The generation by this function is much faster than the following fill_array_xxx functions.
+For initialization, init_gen_rand() or init_by_array() must be called before the first call of this function. This function can not be used after calling genrand_xxx functions, without initialization.
+
Parameters:
+
+ array an array where pseudorandom numbers are filled by this function. The pointer to the array must be "aligned" (namely, must be a multiple of 16) in the SIMD version, since it refers to the address of a 128-bit integer. In the standard C version, the pointer is arbitrary.
+ size the number of 64-bit pseudorandom integers to be generated. size must be a multiple of 2, and greater than or equal to (SFMT_MEXP / 128) * 2.
+
+
+
Note: memalign or posix_memalign is available to get aligned memory. Mac OSX doesn't have these functions, but malloc of OSX returns the pointer to the aligned memory block.
+
+
+
+
+
+
+
+
+ void fill_array_close_open
+ (
+ double
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+
+
+
+
+
+
+
+This function generates double precision floating point pseudorandom numbers which distribute in the range [0, 1) to the specified array[] by one call.
+
+This function is the same as fill_array_close1_open2() except the distribution range.
+
Parameters:
+
+ array an array where pseudorandom numbers are filled by this function.
+ size the number of pseudorandom numbers to be generated. see also
+
+
+
See also: fill_array_close1_open2()
+
+
+
+
+
+
+
+
+ void fill_array_open_close
+ (
+ double
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+
+
+
+
+
+
+
+This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1] to the specified array[] by one call.
+
+This function is the same as fill_array_close1_open2() except the distribution range.
+
Parameters:
+
+ array an array where pseudorandom numbers are filled by this function.
+ size the number of pseudorandom numbers to be generated. see also
+
+
+
See also: fill_array_close1_open2()
+
+
+
+
+
+
+
+
+ void fill_array_open_open
+ (
+ double
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+
+
+
+
+
+
+
+This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1) to the specified array[] by one call.
+
+This function is the same as fill_array_close1_open2() except the distribution range.
+
Parameters:
+
+ array an array where pseudorandom numbers are filled by this function.
+ size the number of pseudorandom numbers to be generated. see also
+
+
+
See also: fill_array_close1_open2()
+
+
+
+
+
+
+
+
+ static void gen_rand_all
+ (
+ void
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function fills the internal state array with double precision floating point pseudorandom numbers of the IEEE 754 format.
+
+
+
+
+
+
+
+
+
+ static void gen_rand_array
+ (
+ w128_t
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function fills the user-specified array with double precision floating point pseudorandom numbers of the IEEE 754 format.
+
+
Parameters:
+
+ array an 128-bit array to be filled by pseudorandom numbers.
+ size number of 128-bit pseudorandom numbers to be generated.
+
+
+
+
+
+
+
+
+
+
+ double genrand_close1_open2
+ (
+ void
+
+ )
+ [inline]
+
+
+
+
+
+
+This function generates and returns double precision pseudorandom number which distributes uniformly in the range [1, 2).
+
+This is the primitive and faster than generating numbers in other ranges. init_gen_rand() or init_by_array() must be called before this function.
Returns: double precision floating point pseudorandom number
+
+
+
+
+
+
+
+
+ const char* get_idstring
+ (
+ void
+
+ )
+
+
+
+
+
+
+
+This function returns the identification string.
+
+The string shows the Mersenne exponent, and all parameters of this generator.
Returns: id string.
+
+
+
+
+
+
+
+
+ int get_min_array_size
+ (
+ void
+
+ )
+
+
+
+
+
+
+
+This function returns the minimum size of array used for fill_array functions.
+
+
Returns: minimum size of array used for fill_array functions.
+
+
+
+
+
+
+
+
+ static uint32_t ini_func1
+ (
+ uint32_t
+ x
+ )
+ [inline, static]
+
+
+
+
+
+
+This function represents a function used in the initialization by init_by_array.
+
+
Parameters:
+
+
+
Returns: 32-bit integer
+
+
+
+
+
+
+
+
+ static uint32_t ini_func2
+ (
+ uint32_t
+ x
+ )
+ [inline, static]
+
+
+
+
+
+
+This function represents a function used in the initialization by init_by_array.
+
+
Parameters:
+
+
+
Returns: 32-bit integer
+
+
+
+
+
+
+
+
+ void init_by_array
+ (
+ uint32_t
+ init_key [],
+
+
+
+
+ int
+ key_length
+
+
+
+ )
+
+
+
+
+
+
+
+This function initializes the internal state array, with an array of 32-bit integers used as the seeds.
+
+
Parameters:
+
+ init_key the array of 32-bit integers, used as a seed.
+ key_length the length of init_key.
+
+
+
+
+
+
+
+
+
+
+ void init_gen_rand
+ (
+ uint32_t
+ seed
+ )
+
+
+
+
+
+
+
+This function initializes the internal state array with a 32-bit integer seed.
+
+
Parameters:
+
+ seed a 32-bit integer used as the seed.
+
+
+
+
+
+
+
+
+
+
+ void initial_mask
+ (
+ void
+
+ )
+ [static]
+
+
+
+
+
+
+This function initializes the internal state array to fit the IEEE 754 format.
+
+
+
+
+
+
+
+
+
+ static void lshift128
+ (
+ w128_t *
+ out ,
+
+
+
+
+ const w128_t *
+ in ,
+
+
+
+
+ int
+ shift
+
+
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function simulates SIMD 128-bit left shift by the standard C.
+
+The 128-bit integer given in in is shifted by (shift * 8) bits. This function simulates the LITTLE ENDIAN SIMD.
Parameters:
+
+ out the output of this function
+ in the 128-bit data to be shifted
+ shift the shift value
+
+
+
+
+
+
+
+
+
+
+ static void period_certification
+ (
+ void
+
+ )
+ [static]
+
+
+
+
+
+
+This function certificate the period of 2^{SFMT_MEXP}-1.
+
+
+
+
+
+
+
+
+
+ static int sfmt_idxof
+ (
+ int
+ i
+ )
+ [inline, static]
+
+
+
+
+
+
+This function simulate a 32-bit array index overlapped to 64-bit array of LITTLE ENDIAN in BIG ENDIAN machine.
+
+
+
+
+
Variable Documentation
+
+
+
+
+
+
+a flag: it is 0 if and only if the internal state is not yet initialized.
+
+
+
+
+
+
+
+
+
+
+the double pointer to the 128-bit internal state array
+
+
+
+
+
+
+
+
+
+
+the 128-bit internal state array
+
+
+
+
+
+
+
+
+
+
+index counter to the internal state array as double
+
+
+
+
+
Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/d_s_f_m_t_8h-source.html b/dSFMT/html/d_s_f_m_t_8h-source.html
new file mode 100644
index 0000000..27a45ac
--- /dev/null
+++ b/dSFMT/html/d_s_f_m_t_8h-source.html
@@ -0,0 +1,102 @@
+
+
+dSFMT: dSFMT.h Source File
+
+
+
+
+
+
+dSFMT.h Go to the documentation of this file. 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) || defined(__BORLANDC__)
+ 00039 typedef unsigned int uint32_t;
+ 00040 typedef unsigned long long uint64_t;
+ 00041 #define inline __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) || defined(__BORLANDC__)
+ 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 inline double genrand_close1_open2 (void );
+ 00066 #if defined(__GNUC__)
+ 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 #elif defined(_MSC_VER) && _MSC_VER >= 1200
+ 00071 __forceinline static double genrand_close_open (void );
+ 00072 __forceinline static double genrand_open_close (void );
+ 00073 __forceinline static double genrand_open_open (void );
+ 00074 #else
+ 00075 inline static double genrand_close_open (void );
+ 00076 inline static double genrand_open_close (void );
+ 00077 inline static double genrand_open_open (void );
+ 00078 #endif
+ 00079
+ 00080 void fill_array_open_close (double array[], int size);
+ 00081 void fill_array_close_open (double array[], int size);
+ 00082 void fill_array_open_open (double array[], int size);
+ 00083 void fill_array_close1_open2 (double array[], int size);
+ 00084 const char *get_idstring (void );
+ 00085 int get_min_array_size (void );
+ 00086 void init_gen_rand (uint32_t seed);
+ 00087 void init_by_array (uint32_t init_key[], int key_length);
+ 00088
+00096 inline static double genrand_close_open (void ) {
+ 00097 return genrand_close1_open2 () - 1.0;
+ 00098 }
+ 00099
+00107 inline static double genrand_open_close (void ) {
+ 00108 return 2.0 - genrand_close1_open2 ();
+ 00109 }
+ 00110
+00118 inline static double genrand_open_open (void ) {
+ 00119 union {
+ 00120 uint64_t u;
+ 00121 double d;
+ 00122 } conv;
+ 00123
+ 00124 conv.d = genrand_close1_open2 ();
+ 00125 conv.u |= 1;
+ 00126 return conv.d - 1.0;
+ 00127 }
+ 00128
+ 00129 #endif
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/d_s_f_m_t_8h.html b/dSFMT/html/d_s_f_m_t_8h.html
new file mode 100644
index 0000000..1c3786e
--- /dev/null
+++ b/dSFMT/html/d_s_f_m_t_8h.html
@@ -0,0 +1,516 @@
+
+
+dSFMT: dSFMT.h File Reference
+
+
+
+
+
+
+dSFMT.h File Reference double precision SIMD oriented Fast Mersenne Twister(dSFMT) pseudorandom number generator based on IEEE 754 format. More...
+
+#include <stdio.h>
+#include <inttypes.h>
+
+
+Go to the source code of this file.
+
+Defines
+#define inline
+
+#define PRIu64 "llu"
+
+#define PRIx64 "llx"
+
+#define UINT64_C (v) (v ## ULL)
+
+Functions
+double genrand_close1_open2 (void)
+
+ This function generates and returns double precision pseudorandom number which distributes uniformly in the range [1, 2).
+static double genrand_close_open (void)
+
+ This function generates and returns double precision pseudorandom number which distributes uniformly in the range [0, 1).
+static double genrand_open_close (void)
+
+ This function generates and returns double precision pseudorandom number which distributes uniformly in the range (0, 1].
+static double genrand_open_open (void)
+
+ This function generates and returns double precision pseudorandom number which distributes uniformly in the range (0, 1).
+void fill_array_open_close (double array[], int size)
+
+ This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1] to the specified array[] by one call.
+void fill_array_close_open (double array[], int size)
+
+ This function generates double precision floating point pseudorandom numbers which distribute in the range [0, 1) to the specified array[] by one call.
+void fill_array_open_open (double array[], int size)
+
+ This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1) to the specified array[] by one call.
+void fill_array_close1_open2 (double array[], int size)
+
+ This function generates double precision floating point pseudorandom numbers which distribute in the range [1, 2) to the specified array[] by one call.
+const char * get_idstring (void)
+
+ This function returns the identification string.
+int get_min_array_size (void)
+
+ This function returns the minimum size of array used for fill_array functions.
+void init_gen_rand (uint32_t seed)
+
+ This function initializes the internal state array with a 32-bit integer seed.
+void init_by_array (uint32_t init_key[], int key_length)
+
+ This function initializes the internal state array, with an array of 32-bit integers used as the seeds.
+
+Detailed Description
+double precision SIMD oriented Fast Mersenne Twister(dSFMT) pseudorandom number generator based on IEEE 754 format.
+
+
Author: Mutsuo Saito (Hiroshima University)
+Makoto Matsumoto (Hiroshima University)
+Copyright (C) 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. All rights reserved.
+The new BSD License is applied to this software. see LICENSE.txt
+
Note: We assume that your system has inttypes.h. If your system doesn't have inttypes.h, you have to typedef uint32_t and uint64_t, and you have to define PRIu64 and PRIx64 in this file as follows: typedef unsigned int uint32_t
+ typedef unsigned long long uint64_t
+ #define PRIu64 "llu"
+ #define PRIx64 "llx"
+ uint32_t must be exactly 32-bit unsigned integer type (no more, no less), and uint64_t must be exactly 64-bit unsigned integer type. PRIu64 and PRIx64 are used for printf function to print 64-bit unsigned int and 64-bit unsigned int in hexadecimal format.
+Define Documentation
+
+
+
+
+
+
+
+ #define PRIu64 "llu"
+
+
+
+
+
+
+
+
+
+
+ #define PRIx64 "llx"
+
+
+
+
+
+
+
+
+
+
+ #define UINT64_C
+ (
+ v
+
+ )
+ (v ## ULL)
+
+
+
+
+
+
Function Documentation
+
+
+
+
+
+ void fill_array_close1_open2
+ (
+ double
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+
+
+
+
+
+
+
+This function generates double precision floating point pseudorandom numbers which distribute in the range [1, 2) to the specified array[] by one call.
+
+The number of pseudorandom numbers is specified by the argument size , which must be at least (SFMT_MEXP / 128) * 2 and a multiple of two. The function get_min_array_size() returns this minimum size. The generation by this function is much faster than the following fill_array_xxx functions.
+For initialization, init_gen_rand() or init_by_array() must be called before the first call of this function. This function can not be used after calling genrand_xxx functions, without initialization.
+
Parameters:
+
+ array an array where pseudorandom numbers are filled by this function. The pointer to the array must be "aligned" (namely, must be a multiple of 16) in the SIMD version, since it refers to the address of a 128-bit integer. In the standard C version, the pointer is arbitrary.
+ size the number of 64-bit pseudorandom integers to be generated. size must be a multiple of 2, and greater than or equal to (SFMT_MEXP / 128) * 2.
+
+
+
Note: memalign or posix_memalign is available to get aligned memory. Mac OSX doesn't have these functions, but malloc of OSX returns the pointer to the aligned memory block.
+
+
+
+
+
+
+
+
+ void fill_array_close_open
+ (
+ double
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+
+
+
+
+
+
+
+This function generates double precision floating point pseudorandom numbers which distribute in the range [0, 1) to the specified array[] by one call.
+
+This function is the same as fill_array_close1_open2() except the distribution range.
+
Parameters:
+
+ array an array where pseudorandom numbers are filled by this function.
+ size the number of pseudorandom numbers to be generated. see also
+
+
+
See also: fill_array_close1_open2()
+
+
+
+
+
+
+
+
+ void fill_array_open_close
+ (
+ double
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+
+
+
+
+
+
+
+This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1] to the specified array[] by one call.
+
+This function is the same as fill_array_close1_open2() except the distribution range.
+
Parameters:
+
+ array an array where pseudorandom numbers are filled by this function.
+ size the number of pseudorandom numbers to be generated. see also
+
+
+
See also: fill_array_close1_open2()
+
+
+
+
+
+
+
+
+ void fill_array_open_open
+ (
+ double
+ array [],
+
+
+
+
+ int
+ size
+
+
+
+ )
+
+
+
+
+
+
+
+This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1) to the specified array[] by one call.
+
+This function is the same as fill_array_close1_open2() except the distribution range.
+
Parameters:
+
+ array an array where pseudorandom numbers are filled by this function.
+ size the number of pseudorandom numbers to be generated. see also
+
+
+
See also: fill_array_close1_open2()
+
+
+
+
+
+
+
+
+ double genrand_close1_open2
+ (
+ void
+
+ )
+ [inline]
+
+
+
+
+
+
+This function generates and returns double precision pseudorandom number which distributes uniformly in the range [1, 2).
+
+This is the primitive and faster than generating numbers in other ranges. init_gen_rand() or init_by_array() must be called before this function.
Returns: double precision floating point pseudorandom number
+
+
+
+
+
+
+
+
+ static double genrand_close_open
+ (
+ void
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function generates and returns double precision pseudorandom number which distributes uniformly in the range [0, 1).
+
+init_gen_rand() or init_by_array() must be called before this function.
Returns: double precision floating point pseudorandom number
+
+
+
+
+
+
+
+
+ static double genrand_open_close
+ (
+ void
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function generates and returns double precision pseudorandom number which distributes uniformly in the range (0, 1].
+
+init_gen_rand() or init_by_array() must be called before this function.
Returns: double precision floating point pseudorandom number
+
+
+
+
+
+
+
+
+ static double genrand_open_open
+ (
+ void
+
+ )
+ [inline, static]
+
+
+
+
+
+
+This function generates and returns double precision pseudorandom number which distributes uniformly in the range (0, 1).
+
+init_gen_rand() or init_by_array() must be called before this function.
Returns: double precision floating point pseudorandom number
+
+
+
+
+
+
+
+
+ const char* get_idstring
+ (
+ void
+
+ )
+
+
+
+
+
+
+
+This function returns the identification string.
+
+The string shows the Mersenne exponent, and all parameters of this generator.
Returns: id string.
+
+
+
+
+
+
+
+
+ int get_min_array_size
+ (
+ void
+
+ )
+
+
+
+
+
+
+
+This function returns the minimum size of array used for fill_array functions.
+
+
Returns: minimum size of array used for fill_array functions.
+
+
+
+
+
+
+
+
+ void init_by_array
+ (
+ uint32_t
+ init_key [],
+
+
+
+
+ int
+ key_length
+
+
+
+ )
+
+
+
+
+
+
+
+This function initializes the internal state array, with an array of 32-bit integers used as the seeds.
+
+
Parameters:
+
+ init_key the array of 32-bit integers, used as a seed.
+ key_length the length of init_key.
+
+
+
+
+
+
+
+
+
+
+ void init_gen_rand
+ (
+ uint32_t
+ seed
+ )
+
+
+
+
+
+
+
+This function initializes the internal state array with a 32-bit integer seed.
+
+
Parameters:
+
+ seed a 32-bit integer used as the seed.
+
+
+
+
+
+
Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/doxygen.css b/dSFMT/html/doxygen.css
new file mode 100644
index 0000000..5d58369
--- /dev/null
+++ b/dSFMT/html/doxygen.css
@@ -0,0 +1,358 @@
+BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV {
+ font-family: Geneva, Arial, Helvetica, sans-serif;
+}
+BODY,TD {
+ font-size: 90%;
+}
+H1 {
+ text-align: center;
+ font-size: 160%;
+}
+H2 {
+ font-size: 120%;
+}
+H3 {
+ font-size: 100%;
+}
+CAPTION { font-weight: bold }
+DIV.qindex {
+ width: 100%;
+ background-color: #e8eef2;
+ border: 1px solid #84b0c7;
+ text-align: center;
+ margin: 2px;
+ padding: 2px;
+ line-height: 140%;
+}
+DIV.nav {
+ width: 100%;
+ background-color: #e8eef2;
+ border: 1px solid #84b0c7;
+ text-align: center;
+ margin: 2px;
+ padding: 2px;
+ line-height: 140%;
+}
+DIV.navtab {
+ background-color: #e8eef2;
+ border: 1px solid #84b0c7;
+ text-align: center;
+ margin: 2px;
+ margin-right: 15px;
+ padding: 2px;
+}
+TD.navtab {
+ font-size: 70%;
+}
+A.qindex {
+ text-decoration: none;
+ font-weight: bold;
+ color: #1A419D;
+}
+A.qindex:visited {
+ text-decoration: none;
+ font-weight: bold;
+ color: #1A419D
+}
+A.qindex:hover {
+ text-decoration: none;
+ background-color: #ddddff;
+}
+A.qindexHL {
+ text-decoration: none;
+ font-weight: bold;
+ background-color: #6666cc;
+ color: #ffffff;
+ border: 1px double #9295C2;
+}
+A.qindexHL:hover {
+ text-decoration: none;
+ background-color: #6666cc;
+ color: #ffffff;
+}
+A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff }
+A.el { text-decoration: none; font-weight: bold }
+A.elRef { font-weight: bold }
+A.code:link { text-decoration: none; font-weight: normal; color: #0000FF}
+A.code:visited { text-decoration: none; font-weight: normal; color: #0000FF}
+A.codeRef:link { font-weight: normal; color: #0000FF}
+A.codeRef:visited { font-weight: normal; color: #0000FF}
+A:hover { text-decoration: none; background-color: #f2f2ff }
+DL.el { margin-left: -1cm }
+.fragment {
+ font-family: monospace, fixed;
+ font-size: 95%;
+}
+PRE.fragment {
+ border: 1px solid #CCCCCC;
+ background-color: #f5f5f5;
+ margin-top: 4px;
+ margin-bottom: 4px;
+ margin-left: 2px;
+ margin-right: 8px;
+ padding-left: 6px;
+ padding-right: 6px;
+ padding-top: 4px;
+ padding-bottom: 4px;
+}
+DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
+
+DIV.groupHeader {
+ margin-left: 16px;
+ margin-top: 12px;
+ margin-bottom: 6px;
+ font-weight: bold;
+}
+DIV.groupText { margin-left: 16px; font-style: italic; font-size: 90% }
+BODY {
+ background: white;
+ color: black;
+ margin-right: 20px;
+ margin-left: 20px;
+}
+TD.indexkey {
+ background-color: #e8eef2;
+ font-weight: bold;
+ padding-right : 10px;
+ padding-top : 2px;
+ padding-left : 10px;
+ padding-bottom : 2px;
+ margin-left : 0px;
+ margin-right : 0px;
+ margin-top : 2px;
+ margin-bottom : 2px;
+ border: 1px solid #CCCCCC;
+}
+TD.indexvalue {
+ background-color: #e8eef2;
+ font-style: italic;
+ padding-right : 10px;
+ padding-top : 2px;
+ padding-left : 10px;
+ padding-bottom : 2px;
+ margin-left : 0px;
+ margin-right : 0px;
+ margin-top : 2px;
+ margin-bottom : 2px;
+ border: 1px solid #CCCCCC;
+}
+TR.memlist {
+ background-color: #f0f0f0;
+}
+P.formulaDsp { text-align: center; }
+IMG.formulaDsp { }
+IMG.formulaInl { vertical-align: middle; }
+SPAN.keyword { color: #008000 }
+SPAN.keywordtype { color: #604020 }
+SPAN.keywordflow { color: #e08000 }
+SPAN.comment { color: #800000 }
+SPAN.preprocessor { color: #806020 }
+SPAN.stringliteral { color: #002080 }
+SPAN.charliteral { color: #008080 }
+.mdescLeft {
+ padding: 0px 8px 4px 8px;
+ font-size: 80%;
+ font-style: italic;
+ background-color: #FAFAFA;
+ border-top: 1px none #E0E0E0;
+ border-right: 1px none #E0E0E0;
+ border-bottom: 1px none #E0E0E0;
+ border-left: 1px none #E0E0E0;
+ margin: 0px;
+}
+.mdescRight {
+ padding: 0px 8px 4px 8px;
+ font-size: 80%;
+ font-style: italic;
+ background-color: #FAFAFA;
+ border-top: 1px none #E0E0E0;
+ border-right: 1px none #E0E0E0;
+ border-bottom: 1px none #E0E0E0;
+ border-left: 1px none #E0E0E0;
+ margin: 0px;
+}
+.memItemLeft {
+ padding: 1px 0px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: solid;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.memItemRight {
+ padding: 1px 8px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: solid;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.memTemplItemLeft {
+ padding: 1px 0px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: none;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.memTemplItemRight {
+ padding: 1px 8px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: none;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.memTemplParams {
+ padding: 1px 0px 0px 8px;
+ margin: 4px;
+ border-top-width: 1px;
+ border-right-width: 1px;
+ border-bottom-width: 1px;
+ border-left-width: 1px;
+ border-top-color: #E0E0E0;
+ border-right-color: #E0E0E0;
+ border-bottom-color: #E0E0E0;
+ border-left-color: #E0E0E0;
+ border-top-style: solid;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-left-style: none;
+ color: #606060;
+ background-color: #FAFAFA;
+ font-size: 80%;
+}
+.search { color: #003399;
+ font-weight: bold;
+}
+FORM.search {
+ margin-bottom: 0px;
+ margin-top: 0px;
+}
+INPUT.search { font-size: 75%;
+ color: #000080;
+ font-weight: normal;
+ background-color: #e8eef2;
+}
+TD.tiny { font-size: 75%;
+}
+a {
+ color: #1A41A8;
+}
+a:visited {
+ color: #2A3798;
+}
+.dirtab { padding: 4px;
+ border-collapse: collapse;
+ border: 1px solid #84b0c7;
+}
+TH.dirtab { background: #e8eef2;
+ font-weight: bold;
+}
+HR { height: 1px;
+ border: none;
+ border-top: 1px solid black;
+}
+
+/* Style for detailed member documentation */
+.memtemplate {
+ font-size: 80%;
+ color: #606060;
+ font-weight: normal;
+}
+.memnav {
+ background-color: #e8eef2;
+ border: 1px solid #84b0c7;
+ text-align: center;
+ margin: 2px;
+ margin-right: 15px;
+ padding: 2px;
+}
+.memitem {
+ padding: 4px;
+ background-color: #eef3f5;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #dedeee;
+ -moz-border-radius: 8px 8px 8px 8px;
+}
+.memname {
+ white-space: nowrap;
+ font-weight: bold;
+}
+.memdoc{
+ padding-left: 10px;
+}
+.memproto {
+ background-color: #d5e1e8;
+ width: 100%;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #84b0c7;
+ font-weight: bold;
+ -moz-border-radius: 8px 8px 8px 8px;
+}
+.paramkey {
+ text-align: right;
+}
+.paramtype {
+ white-space: nowrap;
+}
+.paramname {
+ color: #602020;
+ font-style: italic;
+}
+/* End Styling for detailed member documentation */
+
+/* for the tree view */
+.ftvtree {
+ font-family: sans-serif;
+ margin:0.5em;
+}
+.directory { font-size: 9pt; font-weight: bold; }
+.directory h3 { margin: 0px; margin-top: 1em; font-size: 11pt; }
+.directory > h3 { margin-top: 0; }
+.directory p { margin: 0px; white-space: nowrap; }
+.directory div { display: none; margin: 0px; }
+.directory img { vertical-align: -30%; }
+
diff --git a/dSFMT/html/doxygen.png b/dSFMT/html/doxygen.png
new file mode 100644
index 0000000..f0a274b
Binary files /dev/null and b/dSFMT/html/doxygen.png differ
diff --git a/dSFMT/html/files.html b/dSFMT/html/files.html
new file mode 100644
index 0000000..8a8d4cc
--- /dev/null
+++ b/dSFMT/html/files.html
@@ -0,0 +1,27 @@
+
+
+dSFMT: File Index
+
+
+
+
+
+
+dSFMT File List Here is a list of all files with brief descriptions:
+ dSFMT.c Double precision SIMD-oriented Fast Mersenne Twister (dSFMT) based on IEEE 754 format
+ dSFMT.h [code] Double precision SIMD oriented Fast Mersenne Twister(dSFMT) pseudorandom number generator based on IEEE 754 format
+
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/functions.html b/dSFMT/html/functions.html
new file mode 100644
index 0000000..5c5042a
--- /dev/null
+++ b/dSFMT/html/functions.html
@@ -0,0 +1,36 @@
+
+
+dSFMT: Data Fields
+
+
+
+
+
+
+
+Here is a list of all struct and union fields with links to the structures/unions they belong to:
+
+
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/functions_vars.html b/dSFMT/html/functions_vars.html
new file mode 100644
index 0000000..d183f4d
--- /dev/null
+++ b/dSFMT/html/functions_vars.html
@@ -0,0 +1,36 @@
+
+
+dSFMT: Data Fields - Variables
+
+
+
+
+
+
+
+
+
+
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/globals.html b/dSFMT/html/globals.html
new file mode 100644
index 0000000..f8ce9ee
--- /dev/null
+++ b/dSFMT/html/globals.html
@@ -0,0 +1,103 @@
+
+
+dSFMT: Data Fields
+
+
+
+
+
+
+
+
+
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
+
+
+
+
+
+
+
+
+
+
+
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/globals_defs.html b/dSFMT/html/globals_defs.html
new file mode 100644
index 0000000..eaf5cfd
--- /dev/null
+++ b/dSFMT/html/globals_defs.html
@@ -0,0 +1,40 @@
+
+
+dSFMT: Data Fields
+
+
+
+
+
+
+
+
+
+
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/globals_func.html b/dSFMT/html/globals_func.html
new file mode 100644
index 0000000..099b0c6
--- /dev/null
+++ b/dSFMT/html/globals_func.html
@@ -0,0 +1,60 @@
+
+
+dSFMT: Data Fields
+
+
+
+
+
+
+
+
+
+
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/globals_type.html b/dSFMT/html/globals_type.html
new file mode 100644
index 0000000..8d5537e
--- /dev/null
+++ b/dSFMT/html/globals_type.html
@@ -0,0 +1,37 @@
+
+
+dSFMT: Data Fields
+
+
+
+
+
+
+
+
+
+
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/globals_vars.html b/dSFMT/html/globals_vars.html
new file mode 100644
index 0000000..b868bc9
--- /dev/null
+++ b/dSFMT/html/globals_vars.html
@@ -0,0 +1,40 @@
+
+
+dSFMT: Data Fields
+
+
+
+
+
+
+
+
+
+
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/howto-compile.html b/dSFMT/html/howto-compile.html
new file mode 100644
index 0000000..831bc15
--- /dev/null
+++ b/dSFMT/html/howto-compile.html
@@ -0,0 +1,414 @@
+
+
+
+
+
+ How to compile dSFMT
+
+
+
+ How to compile dSFMT
+
+
+ This document explains how to compile dSFMT for users who
+ are using UNIX like systems (for example Linux, Free BSD,
+ cygwin, osx, etc) on terminal. I can't help those who use IDE
+ (Integrated Development Environment,) please see your IDE's help
+ to use SIMD feature of your CPU.
+
+
+ 1. First Step: Compile test programs using Makefile.
+ 1-1. Compile standard C test program.
+
+ Check if dSFMT.c and Makefile are in your current directory.
+ If not, cd to the directory where they exist.
+ Then, type
+
+
+ make std
+
+
+ If it causes an error, try to type
+
+
+ cc -DSFMT_MEXP=19937 -o test-std-M19937 test.c
+
+
+ or try to type
+
+
+ gcc -DSFMT_MEXP=19937 -o test-std-M19937 test.c
+
+
+ If success, then check the test program. Type
+
+
+ ./test-std-M19937 -v
+
+
+ You will see many random numbers displayed on your screen.
+ If you want to check these random numbers are correct output,
+ redirect output to a file and diff it with
+ dSFMT.19937.out.txt , like this:
+
+ ./test-std-M19937 -v > foo.txt
+diff -w foo.txt dSFMT.19937.out.txt
+
+
+ Silence means they are the same because diff
+ reports the difference of two files.
+
+
+ If you want to know the generation speed of dSFMT, type
+
+
+ ./test-std-M19937 -s
+
+
+ It is very slow. To make it fast, compile it
+ with -O3 option. If your compiler is gcc, you
+ should specify -fno-strict-aliasing option
+ with -O3 . type
+
+
+ gcc -O3 -fno-strict-aliasing -DSFMT_MEXP=19937 -o test-std-M19937 test.c
+./test-std-M19937 -s
+
+
+ If you are using gcc 4.0, you will get more performance of dSFMT
+ by giving additional options
+ --param max-inline-insns-single=1800 ,
+ --param inline-unit-growth=500 and
+ --param large-function-growth=900 .
+
+
+ 1-2. Compile SSE2 test program.
+
+ If your CPU supports SSE2 and you can use gcc version 3.4 or later,
+ you can make test-sse2-M19937. To do this, type
+
+
+ make sse2
+
+ or type
+
+ gcc -O3 -msse2 -fno-strict-aliasing -DHAVE_SSE2=1 -DSFMT_MEXP=19937 -o test-sse2-M19937 test.c
+
+ If everything works well,
+
+ ./test-sse2-M19937 -s
+
+ shows much shorter time than test-std-M19937 -s .
+
+ 1-3. Compile AltiVec test program.
+
+ If you are using Macintosh computer with PowerPC G4 or G5, and
+ your gcc version is later 3.3, you can make test-alti-M19937. To
+ do this, type
+
+
+ make osx-alti
+
+ or type
+
+ gcc -O3 -faltivec -fno-strict-aliasing -DHAVE_ALTIVEC=1 -DSFMT_MEXP=19937 -o test-alti-M19937 test.c
+
+ If everything works well,
+
+ ./test-alti-M19937 -s
+
+ shows much shorter time than test-std-M19937 -s .
+
+ 1-4. Compile and check output automatically.
+
+ To make test program and check output
+ automatically for all supported SFMT_MEXPs of dSFMT, type
+
+
+ make std-check
+
+
+ To check test program optimized for SSE2, type
+
+
+ make sse2-check
+
+
+ To check test program optimized for OSX PowerPC AltiVec, type
+
+
+ make osx-alti-check
+
+
+ These commands may take some time.
+
+
+ 2. Second Step: Use dSFMT pseudorandom number generator with
+ your C program.
+ 2-1. Use sequential call and static link.
+
+ Here is a very simple program sample1.c which
+ calculates PI using Monte-Carlo method.
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "dSFMT.h"
+
+int main(int argc, char* argv[]) {
+ int i, cnt, seed;
+ double x, y, pi;
+ const int NUM = 10000;
+
+ if (argc >= 2) {
+ seed = strtol(argv[1], NULL, 10);
+ } else {
+ seed = 12345;
+ }
+ cnt = 0;
+ init_gen_rand(seed);
+ for (i = 0; i < NUM; i++) {
+ x = genrand_close_open();
+ y = genrand_close_open();
+ if (x * x + y * y < 1.0) {
+ cnt++;
+ }
+ }
+ pi = (double)cnt / NUM * 4;
+ printf("%f\n", pi);
+ return 0;
+}
+
+
+ To compile sample1.c with dSFMT.c with the period of
+ 2607 , type
+
+ gcc -DSFMT_MEXP=607 -o sample1 dSFMT.c sample1.c
+
+ If your CPU supports SSE2 and you want to use optimized dSFMT for
+ SSE2, type
+
+ gcc -msse2 -DSFMT_MEXP=607 -DHAVE_SSE2 -o sample1 dSFMT.c sample1.c
+
+ If your Computer is Apple PowerPC G4 or G5 and you want to use
+ optimized dSFMT for AltiVec, type
+
+ gcc -faltivec -DSFMT_MEXP=607 -DHAVE_ALTIVEC -o sample1 dSFMT.c sample1.c
+
+
+ 2-2. Use block call and static link.
+
+ Here is sample2.c which modifies sample1.c.
+ The block call fill_array_close_open is much faster than
+ sequential call, but it needs an aligned memory. The standard function
+ to get an aligned memory is posix_memalign , but
+ it isn't usable in every OS.
+
+
+
+#include <stdio.h>
+#define _XOPEN_SOURCE 600
+#include <stdlib.h>
+#include "dSFMT.h"
+
+int main(int argc, char* argv[]) {
+ int i, j, cnt, seed;
+ double x, y, pi;
+ const int NUM = 10000;
+ const int R_SIZE = 2 * NUM;
+ int size;
+ double *array;
+
+ if (argc >= 2) {
+ seed = strtol(argv[1], NULL, 10);
+ } else {
+ seed = 12345;
+ }
+ size = get_min_array_size();
+ if (size < R_SIZE) {
+ size = R_SIZE;
+ }
+#if defined(__APPLE__) || \
+ (defined(__FreeBSD__) && __FreeBSD__ >= 3 && __FreeBSD__ <= 6)
+ printf("malloc used\n");
+ array = malloc(sizeof(double) * size);
+ if (array == NULL) {
+ printf("can't allocate memory.\n");
+ return 1;
+ }
+#elif defined(_POSIX_C_SOURCE)
+ printf("posix_memalign used\n");
+ if (posix_memalign((void **)&array, 16, sizeof(double) * size) != 0) {
+ printf("can't allocate memory.\n");
+ return 1;
+ }
+#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
+ printf("memalign used\n");
+ array = memalign(16, sizeof(double) * size);
+ if (array == NULL) {
+ printf("can't allocate memory.\n");
+ return 1;
+ }
+#else /* in this case, gcc doesn't support SSE2 */
+ printf("malloc used\n");
+ array = malloc(sizeof(double) * size);
+ if (array == NULL) {
+ printf("can't allocate memory.\n");
+ return 1;
+ }
+#endif
+ cnt = 0;
+ j = 0;
+ init_gen_rand(seed);
+ fill_array_close_open(array, size);
+ for (i = 0; i < NUM; i++) {
+ x = array[j++];
+ y = array[j++];
+ if (x * x + y * y < 1.0) {
+ cnt++;
+ }
+ }
+ free(array);
+ pi = (double)cnt / NUM * 4;
+ printf("%f\n", pi);
+ return 0;
+}
+
+
+ To compile sample2.c with dSFMT.c with the period of
+ 22281 , type
+
+ gcc -DSFMT_MEXP=2281 -o sample2 dSFMT.c sample2.c
+
+ If your CPU supports SSE2 and you want to use optimized dSFMT for
+ SSE2, type
+
+ gcc -msse2 -DSFMT_MEXP=2281 -DHAVE_SSE2 -o sample2 dSFMT.c sample2.c
+
+ If your computer is Apple PowerPC G4 or G5 and you want to use
+ optimized dSFMT for AltiVec, type
+
+ gcc -faltivec -DSFMT_MEXP=2281 -DHAVE_ALTIVEC -o sample2 dSFMT.c sample2.c
+
+ 2-3. Use sequential call and inline functions.
+
+ Here is sample3.c which modifies sample1.c.
+ This is very similar to sample1.c. The difference is only one line.
+ It include "dSFMT.c" instead of "dSFMT.h"
+ .
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "dSFMT.c"
+
+int main(int argc, char* argv[]) {
+ int i, cnt, seed;
+ double x, y, pi;
+ const int NUM = 10000;
+
+ if (argc >= 2) {
+ seed = strtol(argv[1], NULL, 10);
+ } else {
+ seed = 12345;
+ }
+ cnt = 0;
+ init_gen_rand(seed);
+ for (i = 0; i < NUM; i++) {
+ x = genrand_close_open();
+ y = genrand_close_open();
+ if (x * x + y * y < 1.0) {
+ cnt++;
+ }
+ }
+ pi = (double)cnt / NUM * 4;
+ printf("%f\n", pi);
+ return 0;
+}
+
+
+ To compile sample3.c , type
+
+ gcc -DSFMT_MEXP=19937 -o sample3 sample3.c
+
+ If your CPU supports SSE2 and you want to use optimized SFMT for
+ SSE2, type
+
+ gcc -msse2 -DSFMT_MEXP=19937 -DHAVE_SSE2 -o sample3 sample3.c
+
+ If your computer is Apple PowerPC G4 or G5, and you want to use
+ optimized dSFMT for AltiVec, type
+
+ gcc -faltivec -DSFMT_MEXP=19937 -DHAVE_ALTIVEC -o sample3 sample3.c
+
+
+ Inline sequential call is little bit faster than static link,
+ but it's not a good manner. And fill_array_xxx is faster than
+ inline sequential call.
+
+ 2-4. Initialize dSFMT using init_by_array function.
+
+ Here is sample4.c which modifies sample1.c.
+ The 32-bit integer seed can only make 232 kinds of
+ initial state, to avoid this problem, dSFMT
+ provides init_by_array function. This sample
+ uses init_by_array function which initialize the internal state
+ array with an array of 32-bit. The size of an array can be
+ larger than the internal state array and all elements of the
+ array are used for initialization, but too large array is
+ wasteful.
+
+
+
+#include <stdio.h>
+#include <string.h>
+#include "dSFMT.h"
+
+int main(int argc, char* argv[]) {
+ int i, cnt, seed_cnt;
+ double x, y, pi;
+ const int NUM = 10000;
+ uint32_t seeds[100];
+
+ if (argc >= 2) {
+ seed_cnt = 0;
+ for (i = 0; (i < 100) && (i < strlen(argv[1])); i++) {
+ seeds[i] = argv[1][i];
+ seed_cnt++;
+ }
+ } else {
+ seeds[0] = 12345;
+ seed_cnt = 1;
+ }
+ cnt = 0;
+ init_by_array(seeds, seed_cnt);
+ for (i = 0; i < NUM; i++) {
+ x = genrand_close_open();
+ y = genrand_close_open();
+ if (x * x + y * y < 1.0) {
+ cnt++;
+ }
+ }
+ pi = (double)cnt / NUM * 4;
+ printf("%f\n", pi);
+ return 0;
+}
+
+
+ To compile sample4.c , type
+
+ gcc -DSFMT_MEXP=1279 -o sample4 dSFMT.c sample4.c
+
+ Now, seed can be a string. Like this:
+
+ ./sample4 your-full-name
+
+
+
diff --git a/dSFMT/html/index.html b/dSFMT/html/index.html
new file mode 100644
index 0000000..c5a81de
--- /dev/null
+++ b/dSFMT/html/index.html
@@ -0,0 +1,62 @@
+
+
+dSFMT: Main Page
+
+
+
+
+
+dSFMT Documentation
+
+
1.2 This is double precision SIMD oriented Fast Mersenne Twister pseudorandom number generator (dSFMT). This program is based on the IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Std 754-1985) format.
+This Project provides pseudorandom number generators of various Mersenne Prime Period: from 2607 -1 to 2216091 -1.
+To get dSFMT which has the period of 2607 -1, you have to specify -DMEXP=607 as a compile option. For example,
gcc -DSFMT_MEXP=607 -msse2 -DHAVE_SSE2 -c dSFMT.c
+ will make dSFMT which has the period of 2607 -1 and is optimized for SSE2.
+See How to compile to compile your program with SFMT optimized for SIMD.
+
+void init_gen_rand() initializes the generator with a 32-bit integer seed. void init_by_array() initializes the generator with an array of 32-bit integers as the seeds. const char * get_idstring() returns the IDSTRING which identify the generator. int get_min_array_size() returns the minimum size of array used for fill_array functions. inline double genrand_close1_open2() generates and returns a double precision pseudorandom number which distributes uniformly in the range [1, 2). This is the primitive and faster than generating numbers in other ranges. inline double genrand_close_open() generates and returns a double precision pseudorandom number which distributes uniformly in the range [0, 1). inline double genrand_open_close() generates and returns a double precision pseudorandom number which distributes uniformly in the range (0, 1]. inline double genrand_open_open() generates and returns a double precision pseudorandom number which distributes uniformly in the range (0, 1). void fill_array_close1_open2() fills the user-specified array with double precision pseudorandom numbers which distribute uniformly in the range [1, 2). void fill_array_close_open() fills the user-specified array with double precision pseudorandom numbers which distribute uniformly in the range [0, 1). void fill_array_open_close() fills the user-specified array with double precision pseudorandom numbers which distribute uniformly in the range (0, 1]. void fill_array_open_open() fills the user-specified array with double precision pseudorandom numbers which distribute uniformly in the range (0, 1).
+
+
Author: Mutsuo Saito (saito@our-domain) Hiroshima University
+Makoto Matsumoto (m-mat@our-domain) Hiroshima University
+Please change our-domain to math.sci.hiroshima-u.ac.jp
+
Date: 2007-08-22
+Copyright (C) 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. All rights reserved.
+The new BSD License is applied to this software.
Copyright (c) 2007, Mutsuo Saito, Makoto Matsumoto and Hiroshima University.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of the Hiroshima University nor the names of
+ its contributors may be used to endorse or promote products
+ derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/mainpage_8txt.html b/dSFMT/html/mainpage_8txt.html
new file mode 100644
index 0000000..bbfe618
--- /dev/null
+++ b/dSFMT/html/mainpage_8txt.html
@@ -0,0 +1,26 @@
+
+
+dSFMT: mainpage.txt File Reference
+
+
+
+
+
+
+mainpage.txt File Reference
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/html/tab_b.gif b/dSFMT/html/tab_b.gif
new file mode 100644
index 0000000..0d62348
Binary files /dev/null and b/dSFMT/html/tab_b.gif differ
diff --git a/dSFMT/html/tab_l.gif b/dSFMT/html/tab_l.gif
new file mode 100644
index 0000000..9b1e633
Binary files /dev/null and b/dSFMT/html/tab_l.gif differ
diff --git a/dSFMT/html/tab_r.gif b/dSFMT/html/tab_r.gif
new file mode 100644
index 0000000..ce9dd9f
Binary files /dev/null and b/dSFMT/html/tab_r.gif differ
diff --git a/dSFMT/html/tabs.css b/dSFMT/html/tabs.css
new file mode 100644
index 0000000..a61552a
--- /dev/null
+++ b/dSFMT/html/tabs.css
@@ -0,0 +1,102 @@
+/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */
+
+DIV.tabs
+{
+ float : left;
+ width : 100%;
+ background : url("tab_b.gif") repeat-x bottom;
+ margin-bottom : 4px;
+}
+
+DIV.tabs UL
+{
+ margin : 0px;
+ padding-left : 10px;
+ list-style : none;
+}
+
+DIV.tabs LI, DIV.tabs FORM
+{
+ display : inline;
+ margin : 0px;
+ padding : 0px;
+}
+
+DIV.tabs FORM
+{
+ float : right;
+}
+
+DIV.tabs A
+{
+ float : left;
+ background : url("tab_r.gif") no-repeat right top;
+ border-bottom : 1px solid #84B0C7;
+ font-size : x-small;
+ font-weight : bold;
+ text-decoration : none;
+}
+
+DIV.tabs A:hover
+{
+ background-position: 100% -150px;
+}
+
+DIV.tabs A:link, DIV.tabs A:visited,
+DIV.tabs A:active, DIV.tabs A:hover
+{
+ color: #1A419D;
+}
+
+DIV.tabs SPAN
+{
+ float : left;
+ display : block;
+ background : url("tab_l.gif") no-repeat left top;
+ padding : 5px 9px;
+ white-space : nowrap;
+}
+
+DIV.tabs INPUT
+{
+ float : right;
+ display : inline;
+ font-size : 1em;
+}
+
+DIV.tabs TD
+{
+ font-size : x-small;
+ font-weight : bold;
+ text-decoration : none;
+}
+
+
+
+/* Commented Backslash Hack hides rule from IE5-Mac \*/
+DIV.tabs SPAN {float : none;}
+/* End IE5-Mac hack */
+
+DIV.tabs A:hover SPAN
+{
+ background-position: 0% -150px;
+}
+
+DIV.tabs LI#current A
+{
+ background-position: 100% -150px;
+ border-width : 0px;
+}
+
+DIV.tabs LI#current SPAN
+{
+ background-position: 0% -150px;
+ padding-bottom : 6px;
+}
+
+DIV.nav
+{
+ background : none;
+ border : none;
+ border-bottom : 1px solid #84B0C7;
+}
diff --git a/dSFMT/html/union_w128___t.html b/dSFMT/html/union_w128___t.html
new file mode 100644
index 0000000..06afb9a
--- /dev/null
+++ b/dSFMT/html/union_w128___t.html
@@ -0,0 +1,87 @@
+
+
+dSFMT: W128_T Union Reference
+
+
+
+
+
+
+W128_T Union Reference 128-bit data structure
+More...
+
+
+
+Data Fields
+uint64_t u [2]
+
+uint32_t u32 [4]
+
+double d [2]
+
+
+Detailed Description
+128-bit data structure
+
+
Field Documentation
+
+
+
+
+
+
+
The documentation for this union was generated from the following file:
+Generated on Wed Aug 22 16:08:11 2007 for dSFMT by
+
+ 1.4.7
+
+
diff --git a/dSFMT/test.c b/dSFMT/test.c
new file mode 100644
index 0000000..d962dd5
--- /dev/null
+++ b/dSFMT/test.c
@@ -0,0 +1,606 @@
+#include
+#include
+#include
+#include
+#include
+#include "dSFMT.c"
+
+#define NUM_RANDS 50000
+#define TIC_MAG 1
+#define TIC_COUNT 2000
+
+w128_t dummy[NUM_RANDS / 2 + 1];
+
+#ifdef __GNUC__
+void check_co(void) __attribute__((noinline));
+void check_oc(void) __attribute__((noinline));
+void check_oo(void) __attribute__((noinline));
+void check_12(void) __attribute__((noinline));
+void test_co(void) __attribute__((noinline));
+void test_oc(void) __attribute__((noinline));
+void test_oo(void) __attribute__((noinline));
+void test_12(void) __attribute__((noinline));
+void test_seq_co(void) __attribute__((noinline));
+void test_seq_oc(void) __attribute__((noinline));
+void test_seq_oo(void) __attribute__((noinline));
+void test_seq_12(void) __attribute__((noinline));
+#else
+void check_co(void);
+void check_oc(void);
+void check_oo(void);
+void check_12(void);
+void test_co(void);
+void test_oc(void);
+void test_oo(void);
+void test_12(void);
+void test_seq_co(void);
+void test_seq_oc(void);
+void test_seq_oo(void);
+void test_seq_12(void);
+#endif
+
+void check_co(void) {
+ int i;
+ union W64_T {
+ uint64_t u;
+ double d;
+ };
+ w128_t little[SFMT_N+1];
+ union W64_T *array = (union W64_T *)dummy;
+ union W64_T *plittle = (union W64_T *)little;
+ union W64_T r;
+ int lsize = SFMT_N * 2 + 2;
+
+ printf("generated randoms [0,1)\n");
+ init_gen_rand(1234);
+ fill_array_close_open(&plittle[0].d, lsize);
+ fill_array_close_open(&array[0].d, 5000);
+ init_gen_rand(1234);
+ for (i = 0; i < lsize; i++) {
+ r.d = genrand_close_open();
+ if (r.d != plittle[i].d) {
+ printf("\n[0,1) mismatch i = %d: r = %1.15f(%016"PRIx64"), "
+ "plittle = %1.15f(%016"PRIx64")\n", i, r.d, r.u,
+ plittle[i].d, plittle[i].u);
+ exit(1);
+ }
+ if (i < 1000) {
+ printf("%1.15f ", plittle[i].d);
+ if (i % 4 == 3) {
+ printf("\n");
+ }
+ }
+ }
+ for (i = 0; i < 5000; i++) {
+ r.d = genrand_close_open();
+ if (r.d != array[i].d) {
+ printf("\n[0,1) mismatch i = %d: r = %1.15f(%016"PRIx64"), "
+ "array = %1.15f(%016"PRIx64")\n", i + lsize, r.d, r.u,
+ array[i].d, array[i].u);
+ exit(1);
+ }
+ if (i + lsize < 1000) {
+ printf("%1.15f ", array[i].d);
+ if ((i + lsize) % 4 == 3) {
+ printf("\n");
+ }
+ }
+ }
+}
+
+void check_oc(void) {
+ int i;
+ union W64_T {
+ uint64_t u;
+ double d;
+ };
+ union W64_T *array = (union W64_T *)dummy;
+ union W64_T r;
+
+ printf("generated randoms (0, 1]\n");
+ init_gen_rand(1234);
+ fill_array_open_close(&array[0].d, 5000);
+ init_gen_rand(1234);
+ for (i = 0; i < 5000; i++) {
+ r.d = genrand_open_close();
+ if (r.d != array[i].d) {
+ printf("\n(0,1] mismatch i = %d: r = %1.15f(%016"PRIx64"), "
+ "array = %1.15f(%016"PRIx64")\n", i, r.d, r.u,
+ array[i].d, array[i].u);
+ exit(1);
+ }
+ if (i < 1000) {
+ printf("%1.15f ", array[i].d);
+ if (i % 4 == 3) {
+ printf("\n");
+ }
+ }
+ }
+}
+
+void check_oo(void) {
+ int i;
+ union W64_T {
+ uint64_t u;
+ double d;
+ };
+ union W64_T *array = (union W64_T *)dummy;
+ union W64_T r;
+
+ printf("generated randoms (0,1)\n");
+ init_gen_rand(1234);
+ fill_array_open_open(&array[0].d, 5000);
+ init_gen_rand(1234);
+ for (i = 0; i < 5000; i++) {
+ r.d = genrand_open_open();
+ if (r.d != array[i].d) {
+ printf("\n(0,1) mismatch i = %d: r = %1.15f(%016"PRIx64"), "
+ "array = %1.15f(%016"PRIx64")\n", i, r.d, r.u,
+ array[i].d, array[i].u);
+ exit(1);
+ }
+ if (i < 1000) {
+ printf("%1.15f ", array[i].d);
+ if (i % 4 == 3) {
+ printf("\n");
+ }
+ }
+ }
+}
+
+void check_12(void) {
+ int i;
+ union W64_T {
+ uint64_t u;
+ double d;
+ };
+ w128_t little[SFMT_N+1];
+ union W64_T *array = (union W64_T *)dummy;
+ union W64_T *plittle = (union W64_T *)little;
+ union W64_T r;
+ int lsize = SFMT_N * 2 + 2;
+
+ printf("generated randoms [1, 2)\n");
+ init_gen_rand(1234);
+ fill_array_close1_open2(&plittle[0].d, lsize);
+ fill_array_close1_open2(&array[0].d, 5000);
+ init_gen_rand(1234);
+ for (i = 0; i < lsize; i++) {
+ r.d = genrand_close1_open2();
+ if (r.d != plittle[i].d) {
+ printf("\n[1, 2) mismatch i = %d: r = %1.15f(%016"PRIx64"), "
+ "plittle = %1.15f(%016"PRIx64")\n", i, r.d, r.u,
+ plittle[i].d, plittle[i].u);
+ exit(1);
+ }
+ if (i < 1000) {
+ printf("%1.15f ", plittle[i].d);
+ if (i % 4 == 3) {
+ printf("\n");
+ }
+ }
+ }
+ for (i = 0; i < 5000; i++) {
+ r.d = genrand_close1_open2();
+ if (r.d != array[i].d) {
+ printf("\n[1, 2) mismatch i = %d: r = %1.15f(%016"PRIx64"), "
+ "array = %1.15f(%016"PRIx64")\n", i + lsize, r.d, r.u,
+ array[i].d, array[i].u);
+ exit(1);
+ }
+ if (i + lsize < 1000) {
+ printf("%1.15f ", array[i].d);
+ if ((i + lsize) % 4 == 3) {
+ printf("\n");
+ }
+ }
+ }
+}
+
+void test_co(void) {
+ uint32_t i, j;
+ uint64_t clo;
+ uint64_t sum;
+ uint64_t min;
+ double *array = (double *)dummy;
+
+ init_gen_rand(1234);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ fill_array_close_open(array, NUM_RANDS);
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ printf("BLOCK [0, 1) AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+}
+
+void test_oc(void) {
+ uint32_t i, j;
+ uint64_t clo;
+ uint64_t sum;
+ uint64_t min;
+ double *array = (double *)dummy;
+
+ init_gen_rand(1234);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ fill_array_open_close(array, NUM_RANDS);
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ printf("BLOCK (0, 1] AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+}
+
+void test_oo(void) {
+ uint32_t i, j;
+ uint64_t clo;
+ uint64_t sum;
+ uint64_t min;
+ double *array = (double *)dummy;
+
+ init_gen_rand(1234);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ fill_array_open_open(array, NUM_RANDS);
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ printf("BLOCK (0, 1) AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+}
+
+void test_12(void) {
+ uint32_t i, j;
+ uint64_t clo;
+ uint64_t sum;
+ uint64_t min;
+ double *array = (double *)dummy;
+
+ init_gen_rand(1234);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ fill_array_close1_open2(array, NUM_RANDS);
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ printf("BLOCK [1, 2) AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+}
+
+void test_seq_co(void) {
+ uint32_t i, j, k;
+ uint64_t clo;
+ uint64_t sum;
+ uint64_t min;
+ double *array = (double *)dummy;
+ double r;
+ double total = 0;
+
+ min = LONG_MAX;
+ sum = 0;
+ r = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ r += genrand_close_open();
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = r;
+ printf("SEQ [0, 1) 1 AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ array[k] = genrand_close_open();
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = 0;
+ for (k = 0; k < NUM_RANDS; k++) {
+ total += array[k];
+ }
+ printf("SEQ [0, 1) 2 AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ array[k] = 1.0;
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = 0;
+ for (k = 0; k < NUM_RANDS; k++) {
+ total += array[k];
+ }
+ printf("ADD AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+}
+
+void test_seq_oc(void) {
+ uint32_t i, j, k;
+ uint64_t clo;
+ uint64_t sum;
+ uint64_t min;
+ double *array = (double *)dummy;
+ double r;
+ double total = 0;
+
+ min = LONG_MAX;
+ sum = 0;
+ r = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ r += genrand_open_close();
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = r;
+ printf("SEQ (0, 1] 1 AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ array[k] = genrand_open_close();
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = 0;
+ for (k = 0; k < NUM_RANDS; k++) {
+ total += array[k];
+ }
+ printf("SEQ (0, 1] 2 AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ array[k] = 1.0;
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = 0;
+ for (k = 0; k < NUM_RANDS; k++) {
+ total += array[k];
+ }
+ printf("ADD AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+}
+
+void test_seq_oo(void) {
+ uint32_t i, j, k;
+ uint64_t clo;
+ uint64_t sum;
+ uint64_t min;
+ double *array = (double *)dummy;
+ double r;
+ double total = 0;
+
+ min = LONG_MAX;
+ sum = 0;
+ r = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ r += genrand_open_open();
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = r;
+ printf("SEQ (0, 1) 1 AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ array[k] = genrand_open_open();
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = 0;
+ for (k = 0; k < NUM_RANDS; k++) {
+ total += array[k];
+ }
+ printf("SEQ (0, 1) 2 AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ array[k] = 1.0;
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = 0;
+ for (k = 0; k < NUM_RANDS; k++) {
+ total += array[k];
+ }
+ printf("ADD AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+}
+
+void test_seq_12(void) {
+ uint32_t i, j, k;
+ uint64_t clo;
+ uint64_t sum;
+ uint64_t min;
+ double *array = (double *)dummy;
+ double r;
+ double total = 0;
+
+ min = LONG_MAX;
+ sum = 0;
+ r = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ r += genrand_close1_open2();
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = r;
+ printf("SEQ [1, 2) 1 AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ array[k] = genrand_close1_open2();
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = 0;
+ for (k = 0; k < NUM_RANDS; k++) {
+ total += array[k];
+ }
+ printf("SEQ [1, 2) 2 AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+ min = LONG_MAX;
+ sum = 0;
+ for (i = 0; i < 10; i++) {
+ clo = clock();
+ for (j = 0; j < TIC_COUNT; j++) {
+ for (k = 0; k < NUM_RANDS; k++) {
+ array[k] = 1.0;
+ }
+ }
+ clo = clock() - clo;
+ sum += clo;
+ if (clo < min) {
+ min = clo;
+ }
+ }
+ total = 0;
+ for (k = 0; k < NUM_RANDS; k++) {
+ total += array[k];
+ }
+ printf("ADD AVE:%4"PRIu64"ms.\n", (sum * 100) / CLOCKS_PER_SEC);
+ printf("total = %f\n", total);
+}
+
+int main(int argc, char *argv[]) {
+ if ((argc >= 2) && (strncmp(argv[1],"-v",2) == 0)) {
+ printf("%s\n", get_idstring());
+ check_12();
+ } else if ((argc >= 2) && (strncmp(argv[1],"-s",2) == 0)) {
+ printf("consumed time for generating %u randoms.\n",
+ NUM_RANDS * TIC_COUNT);
+ test_co();
+ test_oc();
+ test_oo();
+ test_12();
+ test_seq_co();
+ test_seq_oc();
+ test_seq_oo();
+ test_seq_12();
+ } else {
+ check_co();
+ check_oc();
+ check_oo();
+ check_12();
+ }
+ return 0;
+}