TinyMT Jump Function
READ ME FIRST
The jump function makes the internal state of TinyMT N-th forward
state. When N is large, the jump calculation is much faster than
generating N pseudorandom numbers. Users can get discrete sub
sequences from pseudorandom number sequence.
The jump function is written in standard C language, with
standard library. But the function is written using
stdint.h and inttypes.h, which are parts of C99 standard.
Three Methods of parallel generation of pseudorandom numbers
using TinyMT
-
Getting multiple sequences of pseudorandom numbers by using
one parameter set and changing seed of initialization. The
sequences obtained by this method are sub sequences of one
long sequence, and it is difficult to know how far each sub
sequences are from other ones. In the worst case, there may be
a duplicated sub-sub sequence. Usually the probability of the
worst case is negligible. Merit of this method is saving
memory in shared memory parallel programing models like
multiple threads model, by setting the parameter set in shared
constant memories.
-
Getting multiple sequences of pseudorandom numbers by
jump. The sequences obtained by this method are also sub
sequences of one long sequence, but how far each sub sequences
are from other ones are known, i.e. the number specified for
jump.
This method also has memory saving merit as above.
-
Getting multiple sequences of pseudorandom numbers by
using multiple parameter sets. The sequences obtained this
method are regarded most independent each other.
This method wastes memories than former methods.
The jump function provides the second method. Our program does
not save memories, users need to change the tinymt structure and
to define parameters as constant to save memories.
Usage
Compilation of test programs
Test program needs source programs of TinyMT to be compiled. And
it needs the output parameter set of TinyMTDC for execution.
- Expand archive file
- Copy jump directory in TinyMTJump-src-xxxx to
the directory of TinyMT.
TinyMT-src-xxx
+---dc
+---tinymt
+---jump
- Change directory to copied jump directory
- Type make all to compile test program.
- Type ./jump_test32 d8524022ed8dff4a8dcc50c798faba43 8f7011ee fc78ff1f 3793fdff 1298
- Check if OK is showed and no NG
description of jump function
void tinymt32_jump(tinymt32c_t *tiny,
uint64_t lower_step,
uint64_t upper_step,
const char * poly_str);
-
This function changes the internal state of tinymt32 to
N (specified by lower_step and upper_step) steps forwards.
N is between 0 and 2128-1.
- tiny is a structure of type tinymt32_t.
tiny must be initialized.
tiny is overwritten by new jumped state.
- lower_step and upper_step
specifies how many steps tinymt jumps.
Users can specify from zero to 2128-1 steps,
using two 64-bit arguments.
- poly_str is a string of characteristic polynomial,
which is in the first column of outputs of tinymt32dc.
void calculate_jump_polynomial(f2_polynomial *jump_poly,
uint64_t lower_step,
uint64_t upper_step,
const char * poly_str);
-
This function calculates jump polynomial from
the characteristic polynomial, lower_step and upper_step.
This function is time consuming.
- jump_polynomial will be overwritten by a calculated
jump polynomial.
- lower_step and upper_step
specifies how many steps tinymt jumps.
Users can specify from zero to 2128-1 steps,
using two 64-bit arguments.
- poly_str is a string of characteristic polynomial,
which is in the first column of outputs of tinymt32dc.
void tinymt32_jump_by_polynomial(tinymt32_t *tiny,
f2_polynomial * jump_poly);
-
This function changes the internal state of tinymt32 to
some steps froward using jump_poly.
jump_poly must be calculated
using the characteristic polynomial of tiny
before this function is called.
This function is faster than calculate_jump_polynomial.
- tiny is a structure of type tinymt32_t.
tiny must be initialized.
tiny is overwritten by new jumped state.
Sample program
Here is a sample program sample.c