Retrieves the current table used in the 32-bit Mersenne Twister generator.
void imsls_random_MT32_table_get (unsigned int **table, ..., 0)
unsigned int
**table (Output)
Address of a pointer to an
array of length 625 containing the table used in the 32-bit Mersenne Twister
generator. Typically,
unsigned int *table is declared and &table is used as an argument.
void
imsls_random_MT32_table_get (int **table,
IMSLS_RETURN_USER, int
r[],
0)
IMSLS_RETURN_USER, int
r[]
(Output)
User-supplied array of length 625 containing the table used in the
32-bit Mersenne Twister generator.
The values in table contain the state of the 32-bit Mersenne Twister random number generator. The table can be used by imsls_random_MT32_table_set to set the generator back to this state.
In this example, four simulation streams are generated. The first series is generated with the seed used for initialization. The second series is generated using an array for initialization. The third series is obtained by resetting the generator back to the state it had at the beginning of the second stream. Therefore, the second and third streams are identical. The fourth stream is obtained by resetting the generator back to its original, uninitialized state, and having it reinitialize using the seed. The fourth and first streams are therefore the same.
const unsigned int init[] = {0x123, 0x234, 0x345, 0x456};
/* Initialize Mersenne Twister series with a seed */
imsls_random_seed_set (iseed);
r = imsls_f_random_uniform (nr, 0);
imsls_f_write_matrix ("First stream output", 1, 5, r,
/* Reinitialize Mersenne Twister series with an array */
imsls_random_MT32_init(4, init);
/* Save the state of the series */
imsls_random_MT32_table_get(&itable, 0);
r = imsls_f_random_uniform (nr, 0);
imsls_f_write_matrix ("Second stream output", 1, 5, r,
/* Restore the state of the series */
imsls_random_MT32_table_set(itable);
r = imsls_f_random_uniform (nr, 0);
imsls_f_write_matrix ("Third stream output", 1, 5, r,
/* Reset the series - it will reinitialize from the seed */
imsls_random_MT32_table_set(itable);
r = imsls_f_random_uniform (nr, 0);
imsls_f_write_matrix ("Fourth stream output", 1, 5, r,
0.4347 0.3522 0.0139 0.2091 0.4956
0.2486 0.2226 0.1111 0.9563 0.9846
0.2486 0.2226 0.1111 0.9563 0.9846
0.4347 0.3522 0.0139 0.2091 0.4956
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |