cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ] #include <mathcw.h> extern void vurcw1f_r (randcw_state_t state, int n, float u[]); extern void vurcw1_r (randcw_state_t state, int n, double u[]); extern void vurcw1l_r (randcw_state_t state, int n, long double u[]); extern void vurcw1w_r (randcw_state_t state, int n, __float80 u[]); extern void vurcw1q_r (randcw_state_t state, int n, __float128 u[]); extern void vurcw1ll_r (randcw_state_t state, int n, long_long_double u[]); extern void vurcw1df_r (randcw_state_t state, int n, decimal_float u[]); extern void vurcw1d_r (randcw_state_t state, int n, decimal_double u[]); extern void vurcw1dl_r (randcw_state_t state, int n, decimal_long_double u[]); extern void vurcw1dll_r (randcw_state_t state, int n, decimal_long_long_double u[]);
NB: Functions with prototypes containing underscores in type names may be available only with certain extended compilers.
The generator state is keep externally in the state argument, a vector of four UINT_LEAST32_T values, most conveniently initialized with incw_r(). This makes the functions thread safe, and allows creation of a practically-unlimited number of independent families of generators, each with its own state.
The generator is Marsaglia's KISS generator, which has a long period of about 2**123 (approximately 10**37), and has passed several difficult tests of randomness, including Marsaglia's Diehard Battery test suite, and the Marsaglia/Tsang tuftest suite.
The double functions sample the 32-bit integer generator twice, the long double functions sample it four times, and the long long double functions sample it eight times,
When precision permits, the decimal floating-point functions use the corresponding binary generator, and then convert that result to decimal. Otherwise, they convert several samples of the integer generator to decimal floating-point with suitable scaling.