Skip to content

Commit d14e00f

Browse files
committed
ENH: Add jumt to MT19937
Add jump function to MT19937 generator using Horner method closes #84
1 parent fd9c111 commit d14e00f

22 files changed

+904
-14
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ matrix:
2121
- env:
2222
- PYTHON=3.4
2323
- NUMPY=1.10
24-
- CYTHON=0.23
24+
- CYTHON=0.24
2525
- env:
2626
- PYTHON=3.5
2727
- env:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Building requires:
144144

145145
* Python (2.7, 3.4, 3.5, 3.6)
146146
* NumPy (1.9, 1.10, 1.11, 1.12)
147-
* Cython (0.22, 0.23, 0.24, 0.25)
147+
* Cython (0.22, **not** 0.23, 0.24, 0.25)
148148
* tempita (0.5+), if not provided by Cython
149149

150150
Testing requires pytest (3.0+).

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Building requires:
160160

161161
- Python (2.7, 3.4, 3.5, 3.6)
162162
- NumPy (1.9, 1.10, 1.11, 1.12)
163-
- Cython (0.22, 0.23, 0.24, 0.25)
163+
- Cython (0.22, **not** 0.23, 0.24, 0.25)
164164
- tempita (0.5+), if not provided by Cython
165165

166166
Testing requires pytest (3.0+).

doc/source/change-log.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Since Version 1.13
3333
* Add SIMD-oriented Fast Mersenne Twister
3434
(`SFMT <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/>`_) generator.
3535
* Add complex normal (:meth:`~randomstate.prng.mt19937.complex_normal`)
36+
* Added support for jumping the MT19937 generator
3637

3738
Version 1.13
3839
------------

doc/source/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ The main innovation is the inclusion of a number of alternative pseudo-random nu
8888
generators, 'in addition' to the standard PRNG in NumPy. The included PRNGs are:
8989

9090
* MT19937 - The standard NumPy generator. Produces identical results to NumPy
91-
using the same seed/state. See `NumPy's documentation`_.
91+
using the same seed/state. Adds a jump function that advances the generator
92+
as-if 2**128 draws have been made (:meth:`randomstate.prng.mt19937.jump`).
93+
See `NumPy's documentation`_.
9294
* dSFMT - A SSE2 enables version of the MT19937 generator. Theoretically the
9395
same, but with a different state and so it is not possible to produce a
9496
sequence identical to MT19937. See the `dSFMT authors' page`_.

doc/source/mt19937.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Random generator
1616
get_state
1717
set_state
1818

19+
Parallel generation
20+
===================
21+
.. autosummary::
22+
:toctree: generated/
23+
24+
jump
1925

2026
Simple random data
2127
==================

doc/source/parallel.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ are listed below.
5454
+-----------------+-------------------------+-------------------------+-------------------------+
5555
| xorshift1024 | :math:`2^{1024}` | :math:`2^{512}` | 64 |
5656
+-----------------+-------------------------+-------------------------+-------------------------+
57+
| mt19937 | :math:`2^{19937}` | :math:`2^{128}` | 32 |
58+
+-----------------+-------------------------+-------------------------+-------------------------+
5759

5860
``jump`` can be used to produce long blocks which should be long enough to not
5961
overlap.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build-system]
2+
requires = ["numpy>=1.09", "cython>=0.24", "setuptools", "wheel"]

randomstate/interface/random-kit/random-kit-poly.h

Lines changed: 207 additions & 0 deletions
Large diffs are not rendered by default.

randomstate/interface/random-kit/random-kit-shim.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "random-kit-shim.h"
2+
#include "random-kit-poly.h"
3+
24

35
extern inline uint32_t random_uint32(aug_state* state);
46

@@ -23,4 +25,9 @@ void entropy_init(aug_state* state)
2325
uint32_t seeds[1];
2426
entropy_fill((void*) seeds, sizeof(seeds));
2527
set_seed(state, seeds[0]);
28+
}
29+
30+
void jump_state(aug_state* state)
31+
{
32+
randomkit_jump(state->rng, poly);
2633
}

0 commit comments

Comments
 (0)