dSFMT.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. #pragma once
  2. /**
  3. * @file dSFMT.h
  4. *
  5. * @brief double precision SIMD oriented Fast Mersenne Twister(dSFMT)
  6. * pseudorandom number generator based on IEEE 754 format.
  7. *
  8. * @author Mutsuo Saito (Hiroshima University)
  9. * @author Makoto Matsumoto (Hiroshima University)
  10. *
  11. * Copyright (C) 2007, 2008 Mutsuo Saito, Makoto Matsumoto and
  12. * Hiroshima University. All rights reserved.
  13. * Copyright (C) 2012 Mutsuo Saito, Makoto Matsumoto,
  14. * Hiroshima University and The University of Tokyo.
  15. * All rights reserved.
  16. *
  17. * The new BSD License is applied to this software.
  18. * see LICENSE.txt
  19. *
  20. * @note We assume that your system has inttypes.h. If your system
  21. * doesn't have inttypes.h, you have to typedef uint32_t and uint64_t,
  22. * and you have to define PRIu64 and PRIx64 in this file as follows:
  23. * @verbatim
  24. typedef unsigned int uint32_t
  25. typedef unsigned long long uint64_t
  26. #define PRIu64 "llu"
  27. #define PRIx64 "llx"
  28. @endverbatim
  29. * uint32_t must be exactly 32-bit unsigned integer type (no more, no
  30. * less), and uint64_t must be exactly 64-bit unsigned integer type.
  31. * PRIu64 and PRIx64 are used for printf function to print 64-bit
  32. * unsigned int and 64-bit unsigned int in hexadecimal format.
  33. */
  34. #ifndef DSFMT_H
  35. #define DSFMT_H
  36. #if defined(__cplusplus)
  37. extern "C" {
  38. #endif
  39. #include <stdio.h>
  40. #include <assert.h>
  41. #if !defined(DSFMT_MEXP)
  42. #ifdef __GNUC__
  43. #warning "DSFMT_MEXP is not defined. I assume DSFMT_MEXP is 19937."
  44. #endif
  45. #define DSFMT_MEXP 19937
  46. #endif
  47. /*-----------------
  48. BASIC DEFINITIONS
  49. -----------------*/
  50. /* Mersenne Exponent. The period of the sequence
  51. * is a multiple of 2^DSFMT_MEXP-1.
  52. * #define DSFMT_MEXP 19937 */
  53. /** DSFMT generator has an internal state array of 128-bit integers,
  54. * and N is its size. */
  55. #define DSFMT_N ((DSFMT_MEXP - 128) / 104 + 1)
  56. /** N32 is the size of internal state array when regarded as an array
  57. * of 32-bit integers.*/
  58. #define DSFMT_N32 (DSFMT_N * 4)
  59. /** N64 is the size of internal state array when regarded as an array
  60. * of 64-bit integers.*/
  61. #define DSFMT_N64 (DSFMT_N * 2)
  62. #if !defined(DSFMT_BIG_ENDIAN)
  63. # if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN)
  64. # if __BYTE_ORDER == __BIG_ENDIAN
  65. # define DSFMT_BIG_ENDIAN 1
  66. # endif
  67. # elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN)
  68. # if _BYTE_ORDER == _BIG_ENDIAN
  69. # define DSFMT_BIG_ENDIAN 1
  70. # endif
  71. # elif defined(__BYTE_ORDER__) && defined(__BIG_ENDIAN__)
  72. # if __BYTE_ORDER__ == __BIG_ENDIAN__
  73. # define DSFMT_BIG_ENDIAN 1
  74. # endif
  75. # elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
  76. # if BYTE_ORDER == BIG_ENDIAN
  77. # define DSFMT_BIG_ENDIAN 1
  78. # endif
  79. # elif defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN) \
  80. || defined(__BIG_ENDIAN__) || defined(BIG_ENDIAN)
  81. # define DSFMT_BIG_ENDIAN 1
  82. # endif
  83. #endif
  84. #if defined(DSFMT_BIG_ENDIAN) && defined(__amd64)
  85. # undef DSFMT_BIG_ENDIAN
  86. #endif
  87. #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
  88. # include <inttypes.h>
  89. #elif defined(_MSC_VER) || defined(__BORLANDC__)
  90. # if !defined(DSFMT_UINT32_DEFINED) && !defined(SFMT_UINT32_DEFINED)
  91. typedef unsigned int uint32_t;
  92. typedef unsigned __int64 uint64_t;
  93. # ifndef UINT64_C
  94. # define UINT64_C(v) (v ## ui64)
  95. # endif
  96. # define DSFMT_UINT32_DEFINED
  97. # if !defined(inline) && !defined(__cplusplus)
  98. # define inline __inline
  99. # endif
  100. # endif
  101. #else
  102. # include <inttypes.h>
  103. # if !defined(inline) && !defined(__cplusplus)
  104. # if defined(__GNUC__)
  105. # define inline __inline__
  106. # else
  107. # define inline
  108. # endif
  109. # endif
  110. #endif
  111. #ifndef PRIu64
  112. # if defined(_MSC_VER) || defined(__BORLANDC__)
  113. # define PRIu64 "I64u"
  114. # define PRIx64 "I64x"
  115. # else
  116. # define PRIu64 "llu"
  117. # define PRIx64 "llx"
  118. # endif
  119. #endif
  120. #ifndef UINT64_C
  121. # define UINT64_C(v) (v ## ULL)
  122. #endif
  123. /*------------------------------------------
  124. 128-bit SIMD like data type for standard C
  125. ------------------------------------------*/
  126. #if defined(HAVE_ALTIVEC)
  127. # if !defined(__APPLE__)
  128. # include <altivec.h>
  129. # endif
  130. /** 128-bit data structure */
  131. union W128_T {
  132. vector unsigned int s;
  133. uint64_t u[2];
  134. uint32_t u32[4];
  135. double d[2];
  136. };
  137. #elif defined(HAVE_SSE2)
  138. # include <emmintrin.h>
  139. /** 128-bit data structure */
  140. union W128_T {
  141. __m128i si;
  142. __m128d sd;
  143. uint64_t u[2];
  144. uint32_t u32[4];
  145. double d[2];
  146. };
  147. #else /* standard C */
  148. /** 128-bit data structure */
  149. union W128_T {
  150. uint64_t u[2];
  151. uint32_t u32[4];
  152. double d[2];
  153. };
  154. #endif
  155. /** 128-bit data type */
  156. typedef union W128_T w128_t;
  157. /** the 128-bit internal state array */
  158. struct DSFMT_T {
  159. w128_t status[DSFMT_N + 1];
  160. int idx;
  161. };
  162. typedef struct DSFMT_T dsfmt_t;
  163. /** dsfmt internal state vector */
  164. extern dsfmt_t dsfmt_global_data;
  165. /** dsfmt mexp for check */
  166. extern const int dsfmt_global_mexp;
  167. void dsfmt_gen_rand_all(dsfmt_t *dsfmt);
  168. void dsfmt_fill_array_open_close(dsfmt_t *dsfmt, double array[], int size);
  169. void dsfmt_fill_array_close_open(dsfmt_t *dsfmt, double array[], int size);
  170. void dsfmt_fill_array_open_open(dsfmt_t *dsfmt, double array[], int size);
  171. void dsfmt_fill_array_close1_open2(dsfmt_t *dsfmt, double array[], int size);
  172. void dsfmt_chk_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed, int mexp);
  173. void dsfmt_chk_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[],
  174. int key_length, int mexp);
  175. const char *dsfmt_get_idstring(void);
  176. int dsfmt_get_min_array_size(void);
  177. #if defined(__GNUC__)
  178. # define DSFMT_PRE_INLINE inline static
  179. # define DSFMT_PST_INLINE __attribute__((always_inline))
  180. #elif defined(_MSC_VER) && _MSC_VER >= 1200
  181. # define DSFMT_PRE_INLINE __forceinline static
  182. # define DSFMT_PST_INLINE
  183. #else
  184. # define DSFMT_PRE_INLINE inline static
  185. # define DSFMT_PST_INLINE
  186. #endif
  187. DSFMT_PRE_INLINE uint32_t dsfmt_genrand_uint32(dsfmt_t *dsfmt) DSFMT_PST_INLINE;
  188. DSFMT_PRE_INLINE double dsfmt_genrand_close1_open2(dsfmt_t *dsfmt)
  189. DSFMT_PST_INLINE;
  190. DSFMT_PRE_INLINE double dsfmt_genrand_close_open(dsfmt_t *dsfmt)
  191. DSFMT_PST_INLINE;
  192. DSFMT_PRE_INLINE double dsfmt_genrand_open_close(dsfmt_t *dsfmt)
  193. DSFMT_PST_INLINE;
  194. DSFMT_PRE_INLINE double dsfmt_genrand_open_open(dsfmt_t *dsfmt)
  195. DSFMT_PST_INLINE;
  196. DSFMT_PRE_INLINE uint32_t dsfmt_gv_genrand_uint32(void) DSFMT_PST_INLINE;
  197. DSFMT_PRE_INLINE double dsfmt_gv_genrand_close1_open2(void) DSFMT_PST_INLINE;
  198. DSFMT_PRE_INLINE double dsfmt_gv_genrand_close_open(void) DSFMT_PST_INLINE;
  199. DSFMT_PRE_INLINE double dsfmt_gv_genrand_open_close(void) DSFMT_PST_INLINE;
  200. DSFMT_PRE_INLINE double dsfmt_gv_genrand_open_open(void) DSFMT_PST_INLINE;
  201. DSFMT_PRE_INLINE void dsfmt_gv_fill_array_open_close(double array[], int size)
  202. DSFMT_PST_INLINE;
  203. DSFMT_PRE_INLINE void dsfmt_gv_fill_array_close_open(double array[], int size)
  204. DSFMT_PST_INLINE;
  205. DSFMT_PRE_INLINE void dsfmt_gv_fill_array_open_open(double array[], int size)
  206. DSFMT_PST_INLINE;
  207. DSFMT_PRE_INLINE void dsfmt_gv_fill_array_close1_open2(double array[], int size)
  208. DSFMT_PST_INLINE;
  209. DSFMT_PRE_INLINE void dsfmt_gv_init_gen_rand(uint32_t seed) DSFMT_PST_INLINE;
  210. DSFMT_PRE_INLINE void dsfmt_gv_init_by_array(uint32_t init_key[],
  211. int key_length) DSFMT_PST_INLINE;
  212. DSFMT_PRE_INLINE void dsfmt_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed)
  213. DSFMT_PST_INLINE;
  214. DSFMT_PRE_INLINE void dsfmt_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[],
  215. int key_length) DSFMT_PST_INLINE;
  216. /**
  217. * This function generates and returns unsigned 32-bit integer.
  218. * This is slower than SFMT, only for convenience usage.
  219. * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called
  220. * before this function.
  221. * @param dsfmt dsfmt internal state date
  222. * @return double precision floating point pseudorandom number
  223. */
  224. inline static uint32_t dsfmt_genrand_uint32(dsfmt_t *dsfmt) {
  225. uint32_t r;
  226. uint64_t *psfmt64 = &dsfmt->status[0].u[0];
  227. if (dsfmt->idx >= DSFMT_N64) {
  228. dsfmt_gen_rand_all(dsfmt);
  229. dsfmt->idx = 0;
  230. }
  231. r = psfmt64[dsfmt->idx++] & 0xffffffffU;
  232. return r;
  233. }
  234. /**
  235. * This function generates and returns double precision pseudorandom
  236. * number which distributes uniformly in the range [1, 2). This is
  237. * the primitive and faster than generating numbers in other ranges.
  238. * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called
  239. * before this function.
  240. * @param dsfmt dsfmt internal state date
  241. * @return double precision floating point pseudorandom number
  242. */
  243. inline static double dsfmt_genrand_close1_open2(dsfmt_t *dsfmt) {
  244. double r;
  245. double *psfmt64 = &dsfmt->status[0].d[0];
  246. if (dsfmt->idx >= DSFMT_N64) {
  247. dsfmt_gen_rand_all(dsfmt);
  248. dsfmt->idx = 0;
  249. }
  250. r = psfmt64[dsfmt->idx++];
  251. return r;
  252. }
  253. /**
  254. * This function generates and returns unsigned 32-bit integer.
  255. * This is slower than SFMT, only for convenience usage.
  256. * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called
  257. * before this function. This function uses \b global variables.
  258. * @return double precision floating point pseudorandom number
  259. */
  260. inline static uint32_t dsfmt_gv_genrand_uint32(void) {
  261. return dsfmt_genrand_uint32(&dsfmt_global_data);
  262. }
  263. /**
  264. * This function generates and returns double precision pseudorandom
  265. * number which distributes uniformly in the range [1, 2).
  266. * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called
  267. * before this function. This function uses \b global variables.
  268. * @return double precision floating point pseudorandom number
  269. */
  270. inline static double dsfmt_gv_genrand_close1_open2(void) {
  271. return dsfmt_genrand_close1_open2(&dsfmt_global_data);
  272. }
  273. /**
  274. * This function generates and returns double precision pseudorandom
  275. * number which distributes uniformly in the range [0, 1).
  276. * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called
  277. * before this function.
  278. * @param dsfmt dsfmt internal state date
  279. * @return double precision floating point pseudorandom number
  280. */
  281. inline static double dsfmt_genrand_close_open(dsfmt_t *dsfmt) {
  282. return dsfmt_genrand_close1_open2(dsfmt) - 1.0;
  283. }
  284. /**
  285. * This function generates and returns double precision pseudorandom
  286. * number which distributes uniformly in the range [0, 1).
  287. * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called
  288. * before this function. This function uses \b global variables.
  289. * @return double precision floating point pseudorandom number
  290. */
  291. inline static double dsfmt_gv_genrand_close_open(void) {
  292. return dsfmt_gv_genrand_close1_open2() - 1.0;
  293. }
  294. /**
  295. * This function generates and returns double precision pseudorandom
  296. * number which distributes uniformly in the range (0, 1].
  297. * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called
  298. * before this function.
  299. * @param dsfmt dsfmt internal state date
  300. * @return double precision floating point pseudorandom number
  301. */
  302. inline static double dsfmt_genrand_open_close(dsfmt_t *dsfmt) {
  303. return 2.0 - dsfmt_genrand_close1_open2(dsfmt);
  304. }
  305. /**
  306. * This function generates and returns double precision pseudorandom
  307. * number which distributes uniformly in the range (0, 1].
  308. * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called
  309. * before this function. This function uses \b global variables.
  310. * @return double precision floating point pseudorandom number
  311. */
  312. inline static double dsfmt_gv_genrand_open_close(void) {
  313. return 2.0 - dsfmt_gv_genrand_close1_open2();
  314. }
  315. /**
  316. * This function generates and returns double precision pseudorandom
  317. * number which distributes uniformly in the range (0, 1).
  318. * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called
  319. * before this function.
  320. * @param dsfmt dsfmt internal state date
  321. * @return double precision floating point pseudorandom number
  322. */
  323. inline static double dsfmt_genrand_open_open(dsfmt_t *dsfmt) {
  324. double *dsfmt64 = &dsfmt->status[0].d[0];
  325. union {
  326. double d;
  327. uint64_t u;
  328. } r;
  329. if (dsfmt->idx >= DSFMT_N64) {
  330. dsfmt_gen_rand_all(dsfmt);
  331. dsfmt->idx = 0;
  332. }
  333. r.d = dsfmt64[dsfmt->idx++];
  334. r.u |= 1;
  335. return r.d - 1.0;
  336. }
  337. /**
  338. * This function generates and returns double precision pseudorandom
  339. * number which distributes uniformly in the range (0, 1).
  340. * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called
  341. * before this function. This function uses \b global variables.
  342. * @return double precision floating point pseudorandom number
  343. */
  344. inline static double dsfmt_gv_genrand_open_open(void) {
  345. return dsfmt_genrand_open_open(&dsfmt_global_data);
  346. }
  347. /**
  348. * This function generates double precision floating point
  349. * pseudorandom numbers which distribute in the range [1, 2) to the
  350. * specified array[] by one call. This function is the same as
  351. * dsfmt_fill_array_close1_open2() except that this function uses
  352. * \b global variables.
  353. * @param array an array where pseudorandom numbers are filled
  354. * by this function.
  355. * @param size the number of pseudorandom numbers to be generated.
  356. * see also \sa dsfmt_fill_array_close1_open2()
  357. */
  358. inline static void dsfmt_gv_fill_array_close1_open2(double array[], int size) {
  359. dsfmt_fill_array_close1_open2(&dsfmt_global_data, array, size);
  360. }
  361. /**
  362. * This function generates double precision floating point
  363. * pseudorandom numbers which distribute in the range (0, 1] to the
  364. * specified array[] by one call. This function is the same as
  365. * dsfmt_gv_fill_array_close1_open2() except the distribution range.
  366. * This function uses \b global variables.
  367. * @param array an array where pseudorandom numbers are filled
  368. * by this function.
  369. * @param size the number of pseudorandom numbers to be generated.
  370. * see also \sa dsfmt_fill_array_close1_open2() and \sa
  371. * dsfmt_gv_fill_array_close1_open2()
  372. */
  373. inline static void dsfmt_gv_fill_array_open_close(double array[], int size) {
  374. dsfmt_fill_array_open_close(&dsfmt_global_data, array, size);
  375. }
  376. /**
  377. * This function generates double precision floating point
  378. * pseudorandom numbers which distribute in the range [0, 1) to the
  379. * specified array[] by one call. This function is the same as
  380. * dsfmt_gv_fill_array_close1_open2() except the distribution range.
  381. * This function uses \b global variables.
  382. * @param array an array where pseudorandom numbers are filled
  383. * by this function.
  384. * @param size the number of pseudorandom numbers to be generated.
  385. * see also \sa dsfmt_fill_array_close1_open2() \sa
  386. * dsfmt_gv_fill_array_close1_open2()
  387. */
  388. inline static void dsfmt_gv_fill_array_close_open(double array[], int size) {
  389. dsfmt_fill_array_close_open(&dsfmt_global_data, array, size);
  390. }
  391. /**
  392. * This function generates double precision floating point
  393. * pseudorandom numbers which distribute in the range (0, 1) to the
  394. * specified array[] by one call. This function is the same as
  395. * dsfmt_gv_fill_array_close1_open2() except the distribution range.
  396. * This function uses \b global variables.
  397. * @param array an array where pseudorandom numbers are filled
  398. * by this function.
  399. * @param size the number of pseudorandom numbers to be generated.
  400. * see also \sa dsfmt_fill_array_close1_open2() \sa
  401. * dsfmt_gv_fill_array_close1_open2()
  402. */
  403. inline static void dsfmt_gv_fill_array_open_open(double array[], int size) {
  404. dsfmt_fill_array_open_open(&dsfmt_global_data, array, size);
  405. }
  406. /**
  407. * This function initializes the internal state array with a 32-bit
  408. * integer seed.
  409. * @param dsfmt dsfmt state vector.
  410. * @param seed a 32-bit integer used as the seed.
  411. */
  412. inline static void dsfmt_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed) {
  413. dsfmt_chk_init_gen_rand(dsfmt, seed, DSFMT_MEXP);
  414. }
  415. /**
  416. * This function initializes the internal state array with a 32-bit
  417. * integer seed. This function uses \b global variables.
  418. * @param seed a 32-bit integer used as the seed.
  419. * see also \sa dsfmt_init_gen_rand()
  420. */
  421. inline static void dsfmt_gv_init_gen_rand(uint32_t seed) {
  422. dsfmt_init_gen_rand(&dsfmt_global_data, seed);
  423. }
  424. /**
  425. * This function initializes the internal state array,
  426. * with an array of 32-bit integers used as the seeds.
  427. * @param dsfmt dsfmt state vector
  428. * @param init_key the array of 32-bit integers, used as a seed.
  429. * @param key_length the length of init_key.
  430. */
  431. inline static void dsfmt_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[],
  432. int key_length) {
  433. dsfmt_chk_init_by_array(dsfmt, init_key, key_length, DSFMT_MEXP);
  434. }
  435. /**
  436. * This function initializes the internal state array,
  437. * with an array of 32-bit integers used as the seeds.
  438. * This function uses \b global variables.
  439. * @param init_key the array of 32-bit integers, used as a seed.
  440. * @param key_length the length of init_key.
  441. * see also \sa dsfmt_init_by_array()
  442. */
  443. inline static void dsfmt_gv_init_by_array(uint32_t init_key[], int key_length) {
  444. dsfmt_init_by_array(&dsfmt_global_data, init_key, key_length);
  445. }
  446. #if !defined(DSFMT_DO_NOT_USE_OLD_NAMES)
  447. DSFMT_PRE_INLINE const char *get_idstring(void) DSFMT_PST_INLINE;
  448. DSFMT_PRE_INLINE int get_min_array_size(void) DSFMT_PST_INLINE;
  449. DSFMT_PRE_INLINE void init_gen_rand(uint32_t seed) DSFMT_PST_INLINE;
  450. DSFMT_PRE_INLINE void init_by_array(uint32_t init_key[], int key_length)
  451. DSFMT_PST_INLINE;
  452. DSFMT_PRE_INLINE double genrand_close1_open2(void) DSFMT_PST_INLINE;
  453. DSFMT_PRE_INLINE double genrand_close_open(void) DSFMT_PST_INLINE;
  454. DSFMT_PRE_INLINE double genrand_open_close(void) DSFMT_PST_INLINE;
  455. DSFMT_PRE_INLINE double genrand_open_open(void) DSFMT_PST_INLINE;
  456. DSFMT_PRE_INLINE void fill_array_open_close(double array[], int size)
  457. DSFMT_PST_INLINE;
  458. DSFMT_PRE_INLINE void fill_array_close_open(double array[], int size)
  459. DSFMT_PST_INLINE;
  460. DSFMT_PRE_INLINE void fill_array_open_open(double array[], int size)
  461. DSFMT_PST_INLINE;
  462. DSFMT_PRE_INLINE void fill_array_close1_open2(double array[], int size)
  463. DSFMT_PST_INLINE;
  464. /**
  465. * This function is just the same as dsfmt_get_idstring().
  466. * @return id string.
  467. * see also \sa dsfmt_get_idstring()
  468. */
  469. inline static const char *get_idstring(void) {
  470. return dsfmt_get_idstring();
  471. }
  472. /**
  473. * This function is just the same as dsfmt_get_min_array_size().
  474. * @return minimum size of array used for fill_array functions.
  475. * see also \sa dsfmt_get_min_array_size()
  476. */
  477. inline static int get_min_array_size(void) {
  478. return dsfmt_get_min_array_size();
  479. }
  480. /**
  481. * This function is just the same as dsfmt_gv_init_gen_rand().
  482. * @param seed a 32-bit integer used as the seed.
  483. * see also \sa dsfmt_gv_init_gen_rand(), \sa dsfmt_init_gen_rand().
  484. */
  485. inline static void init_gen_rand(uint32_t seed) {
  486. dsfmt_gv_init_gen_rand(seed);
  487. }
  488. /**
  489. * This function is just the same as dsfmt_gv_init_by_array().
  490. * @param init_key the array of 32-bit integers, used as a seed.
  491. * @param key_length the length of init_key.
  492. * see also \sa dsfmt_gv_init_by_array(), \sa dsfmt_init_by_array().
  493. */
  494. inline static void init_by_array(uint32_t init_key[], int key_length) {
  495. dsfmt_gv_init_by_array(init_key, key_length);
  496. }
  497. /**
  498. * This function is just the same as dsfmt_gv_genrand_close1_open2().
  499. * @return double precision floating point number.
  500. * see also \sa dsfmt_genrand_close1_open2() \sa
  501. * dsfmt_gv_genrand_close1_open2()
  502. */
  503. inline static double genrand_close1_open2(void) {
  504. return dsfmt_gv_genrand_close1_open2();
  505. }
  506. /**
  507. * This function is just the same as dsfmt_gv_genrand_close_open().
  508. * @return double precision floating point number.
  509. * see also \sa dsfmt_genrand_close_open() \sa
  510. * dsfmt_gv_genrand_close_open()
  511. */
  512. inline static double genrand_close_open(void) {
  513. return dsfmt_gv_genrand_close_open();
  514. }
  515. /**
  516. * This function is just the same as dsfmt_gv_genrand_open_close().
  517. * @return double precision floating point number.
  518. * see also \sa dsfmt_genrand_open_close() \sa
  519. * dsfmt_gv_genrand_open_close()
  520. */
  521. inline static double genrand_open_close(void) {
  522. return dsfmt_gv_genrand_open_close();
  523. }
  524. /**
  525. * This function is just the same as dsfmt_gv_genrand_open_open().
  526. * @return double precision floating point number.
  527. * see also \sa dsfmt_genrand_open_open() \sa
  528. * dsfmt_gv_genrand_open_open()
  529. */
  530. inline static double genrand_open_open(void) {
  531. return dsfmt_gv_genrand_open_open();
  532. }
  533. /**
  534. * This function is juset the same as dsfmt_gv_fill_array_open_close().
  535. * @param array an array where pseudorandom numbers are filled
  536. * by this function.
  537. * @param size the number of pseudorandom numbers to be generated.
  538. * see also \sa dsfmt_gv_fill_array_open_close(), \sa
  539. * dsfmt_fill_array_close1_open2(), \sa
  540. * dsfmt_gv_fill_array_close1_open2()
  541. */
  542. inline static void fill_array_open_close(double array[], int size) {
  543. dsfmt_gv_fill_array_open_close(array, size);
  544. }
  545. /**
  546. * This function is juset the same as dsfmt_gv_fill_array_close_open().
  547. * @param array an array where pseudorandom numbers are filled
  548. * by this function.
  549. * @param size the number of pseudorandom numbers to be generated.
  550. * see also \sa dsfmt_gv_fill_array_close_open(), \sa
  551. * dsfmt_fill_array_close1_open2(), \sa
  552. * dsfmt_gv_fill_array_close1_open2()
  553. */
  554. inline static void fill_array_close_open(double array[], int size) {
  555. dsfmt_gv_fill_array_close_open(array, size);
  556. }
  557. /**
  558. * This function is juset the same as dsfmt_gv_fill_array_open_open().
  559. * @param array an array where pseudorandom numbers are filled
  560. * by this function.
  561. * @param size the number of pseudorandom numbers to be generated.
  562. * see also \sa dsfmt_gv_fill_array_open_open(), \sa
  563. * dsfmt_fill_array_close1_open2(), \sa
  564. * dsfmt_gv_fill_array_close1_open2()
  565. */
  566. inline static void fill_array_open_open(double array[], int size) {
  567. dsfmt_gv_fill_array_open_open(array, size);
  568. }
  569. /**
  570. * This function is juset the same as dsfmt_gv_fill_array_close1_open2().
  571. * @param array an array where pseudorandom numbers are filled
  572. * by this function.
  573. * @param size the number of pseudorandom numbers to be generated.
  574. * see also \sa dsfmt_fill_array_close1_open2(), \sa
  575. * dsfmt_gv_fill_array_close1_open2()
  576. */
  577. inline static void fill_array_close1_open2(double array[], int size) {
  578. dsfmt_gv_fill_array_close1_open2(array, size);
  579. }
  580. #endif /* DSFMT_DO_NOT_USE_OLD_NAMES */
  581. #if defined(__cplusplus)
  582. }
  583. #endif
  584. #endif /* DSFMT_H */