Index

About SFMT jump function

For a given integer N, this jump function executes the N-step jump. Namely, from the given state, obtain the state of SFMT after N steps generation. This is equivalent to call the SFMT 32-bit integer generation 4N times with discarding the outputs. A typical usage of a jump function is to obtain distinct sub streams from a whole period of pseudorandom number sequence generated by one SFMT.

There are two steps for doing jump. Calculations of jump polynomial and changing internal state.

Step 1: Calculations of jump polynomial

From the characteristic polynomial ϕ of a linear random number generator and an integer N, we can get jump polynomial ψ

ψ = XN mod ϕ.
As a result, degree of jump polynomial ψ is less than the characteristic polynomial ϕ, regardless of jump step N.

The characteristic polynomial of SFMT of MEXP is stored in files of 'characteristic.MEXP.txt' included in SFMT-jump archive file.

The executable binary file 'calc-jump' calculates jump polynomial from command line. Here is a usage:

./calc-jump jump-step characteristic-file [no.]
    jump-step: a number between zero and 2^{SFMT_MEXP}-1.
               large decimal number is allowed.
    characteristic-file: one of characteristic.{MEXP}.txt file
    [no.]: shows which characteristic polynomial in
           the file should be used. 0 is used if omitted.
           this is used for files in params directory.

Users can call C++ function 'sfmt::calc_jump' in C++ header file 'SFMT-calc-jump.hpp' to calculate jump polynomials.

NTL: A Library for doing Number Theory by Victor Shoup is used for polynomial calculation and handling large integers.

This step does not use SFMT internal state and independent from MEXPs except file names of characteristic polynomials.

Step 2: Changing internal state of SFMT to jumped state.

This step depends on MEXPs of SFMT, and the characteristic polynomial of SFMT should be the same as one used for the jump polynomial calculation.

The function SFMT_jump written in C language does this step. For our convenience, we used C structure for SFMT internal state, and almost of all functions provided in SFMT ver. 1.3 were re-written to use SFMT structures. No support for ALTIVEC or BIG ENDIAN.

Install, Compile and Test

Test program needs source programs of SFMT ver. 1.4 to be compiled.

  1. Install NTL if not installed.
  2. Expand archive file
  3. Copy jump directory in SFMTJump-src-xxxx to the directory of SFMT.
  4. SFMT-src-1.4
       +---html
       +---params
       +---jump
    
  5. Change directory to copied jump directory
  6. If you specify gmp or gf2x when you installed NTL, you need to uncomment one of below lines in Makefile.
  7. #LIBGF2X = -lgf2x
    #LIBGMP = -lgmp
    
  8. make
  9. make all
    make check
    
  10. Check if OK is showed and no NG

test-jump-MXXX files made by above can invoke with '-s' argument like this:

$ ./test-jump-M19937 -s
mexp 19937 jump 10^04 steps calc_jump: 0.806ms
mexp 19937 jump 10^04 steps SFMT_jump: 0.319ms
mexp 19937 jump 10^06 steps calc_jump: 3.562ms
mexp 19937 jump 10^06 steps SFMT_jump: 3.248ms
mexp 19937 jump 10^08 steps calc_jump: 6.480ms
mexp 19937 jump 10^08 steps SFMT_jump: 3.275ms
mexp 19937 jump 10^10 steps calc_jump: 9.385ms
mexp 19937 jump 10^10 steps SFMT_jump: 3.267ms
mexp 19937 jump 10^12 steps calc_jump:12.720ms
mexp 19937 jump 10^12 steps SFMT_jump: 3.273ms
mexp 19937 jump 10^14 steps calc_jump:15.429ms
mexp 19937 jump 10^14 steps SFMT_jump: 3.280ms
mexp 19937 jump 10^16 steps calc_jump:18.377ms
mexp 19937 jump 10^16 steps SFMT_jump: 3.301ms
mexp 19937 jump 10^18 steps calc_jump:21.416ms
mexp 19937 jump 10^18 steps SFMT_jump: 3.297ms
mexp 19937 jump 10^20 steps calc_jump:24.440ms
mexp 19937 jump 10^20 steps SFMT_jump: 3.233ms
mexp 19937 jump 10^22 steps calc_jump:27.389ms
mexp 19937 jump 10^22 steps SFMT_jump: 3.283ms

Samples of Parallel generation

sample1.c file included in the archive shows generation of 5 distinct sub-sequences using 1020 steps jump. As far as the length of each sub-sequence is smaller than 1020 the sub-sequences are not overlapping.

Getting distinct sub sequences is an important purpose of jump function, however jump function is also available to get a sub-sequence using parallel computing.
Here is a sample of generating a sequence using 6 SFMT instances. This sample is included in the archive. sample2.c

License

SFMT-jump, as well as SFMT, can be used freely for any purpose, including commercial use.
See LICENSE.txt for detail.