diff options
author | Kevin Sheppard <kevin.k.sheppard@gmail.com> | 2019-05-24 10:41:58 +0100 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2019-05-27 22:58:35 +0300 |
commit | 58c0e72854c3f79d3d165d74f2dc721815a38b57 (patch) | |
tree | 3a8fff1f2c1a073248c81e53ba8d3a0367c00907 /numpy/random | |
parent | 3db5a7736cf26db59817eb8939b042ae18c482fa (diff) | |
download | numpy-58c0e72854c3f79d3d165d74f2dc721815a38b57.tar.gz |
Revert "MAINT: Implement API changes for randomgen-derived code"
This reverts commit 17e0070df93f4262908f884dca4b08cb7d0bba7f.
Diffstat (limited to 'numpy/random')
26 files changed, 10043 insertions, 14 deletions
diff --git a/numpy/random/__init__.py b/numpy/random/__init__.py index 51a2952f1..ade912839 100644 --- a/numpy/random/__init__.py +++ b/numpy/random/__init__.py @@ -99,6 +99,8 @@ BitGenerator Streams that work with Generator --------------------------------------------- --- MT19937 DSFMT +PCG32 +PCG64 Philox ThreeFry Xoshiro256 @@ -163,13 +165,15 @@ from .mtrand import * from .dsfmt import DSFMT from .generator import Generator from .mt19937 import MT19937 +from .pcg32 import PCG32 +from .pcg64 import PCG64 from .philox import Philox from .threefry import ThreeFry from .xoshiro256 import Xoshiro256 from .xoshiro512 import Xoshiro512 from .mtrand import RandomState -__all__ += ['Generator', 'DSFMT', 'MT19937', 'Philox', +__all__ += ['Generator', 'DSFMT', 'MT19937', 'Philox','PCG64', 'PCG32', 'ThreeFry', 'Xoshiro256', 'Xoshiro512', 'RandomState'] # Some aliases: diff --git a/numpy/random/_pickle.py b/numpy/random/_pickle.py index 71a6d8bdd..cc624a1e8 100644 --- a/numpy/random/_pickle.py +++ b/numpy/random/_pickle.py @@ -1,6 +1,8 @@ from .mtrand import RandomState from .philox import Philox from .threefry import ThreeFry +from .pcg32 import PCG32 +from .pcg64 import PCG64 from .xoshiro256 import Xoshiro256 from .xoshiro512 import Xoshiro512 @@ -9,12 +11,14 @@ from .generator import Generator from .mt19937 import MT19937 BitGenerators = {'MT19937': MT19937, - 'DSFMT': DSFMT, - 'Philox': Philox, - 'ThreeFry': ThreeFry, - 'Xoshiro256': Xoshiro256, - 'Xoshiro512': Xoshiro512, - } + 'DSFMT': DSFMT, + 'PCG32': PCG32, + 'PCG64': PCG64, + 'Philox': Philox, + 'ThreeFry': ThreeFry, + 'Xoshiro256': Xoshiro256, + 'Xoshiro512': Xoshiro512 + } def __generator_ctor(bit_generator_name='mt19937'): diff --git a/numpy/random/pcg32.pyx b/numpy/random/pcg32.pyx new file mode 100644 index 000000000..b57f8e04e --- /dev/null +++ b/numpy/random/pcg32.pyx @@ -0,0 +1,392 @@ +try: + from threading import Lock +except ImportError: + from dummy_threading import Lock + +from cpython.pycapsule cimport PyCapsule_New + +import numpy as np +cimport numpy as np + +from .common cimport * +from .distributions cimport bitgen_t +from .entropy import random_entropy + +__all__ = ['PCG32'] + +np.import_array() + +cdef extern from "src/pcg32/pcg32.h": + + cdef struct pcg_state_setseq_64: + uint64_t state + uint64_t inc + + ctypedef pcg_state_setseq_64 pcg32_random_t + + struct s_pcg32_state: + pcg32_random_t *pcg_state + + ctypedef s_pcg32_state pcg32_state + + uint64_t pcg32_next64(pcg32_state *state) nogil + uint32_t pcg32_next32(pcg32_state *state) nogil + double pcg32_next_double(pcg32_state *state) nogil + void pcg32_jump(pcg32_state *state) + void pcg32_advance_state(pcg32_state *state, uint64_t step) + void pcg32_set_seed(pcg32_state *state, uint64_t seed, uint64_t inc) + +cdef uint64_t pcg32_uint64(void* st) nogil: + return pcg32_next64(<pcg32_state *>st) + +cdef uint32_t pcg32_uint32(void *st) nogil: + return pcg32_next32(<pcg32_state *> st) + +cdef double pcg32_double(void* st) nogil: + return pcg32_next_double(<pcg32_state *>st) + +cdef uint64_t pcg32_raw(void* st) nogil: + return <uint64_t>pcg32_next32(<pcg32_state *> st) + + +cdef class PCG32: + u""" + PCG32(seed=None, inc=0) + + Container for the PCG-32 pseudo-random number generator. + + Parameters + ---------- + seed : {None, long}, optional + Random seed initializing the pseudo-random number generator. + Can be an integer in [0, 2**64] or ``None`` (the default). + If `seed` is ``None``, then ``PCG32`` will try to read data + from ``/dev/urandom`` (or the Windows analog) if available. If + unavailable, a 64-bit hash of the time and process ID is used. + inc : {None, int}, optional + Stream to return. + Can be an integer in [0, 2**64] or ``None`` (the default). If `inc` is + ``None``, then 0 is used. Can be used with the same seed to + produce multiple streams using other values of inc. + + Attributes + ---------- + lock: threading.Lock + Lock instance that is shared so that the same bit git generator can + be used in multiple Generators without corrupting the state. Code that + generates values from a bit generator should hold the bit generator's + lock. + + Notes + ----- + PCG-32 is a 64-bit implementation of O'Neill's permutation congruential + generator ([1]_, [2]_). PCG-32 has a period of :math:`2^{64}` and supports + advancing an arbitrary number of steps as well as :math:`2^{63}` streams. + + ``PCG32`` provides a capsule containing function pointers that produce + doubles, and unsigned 32 and 64- bit integers. These are not + directly consumable in Python and must be consumed by a ``Generator`` + or similar object that supports low-level access. + + Supports the method advance to advance the RNG an arbitrary number of + steps. The state of the PCG-32 PRNG is represented by 2 64-bit unsigned + integers. + + See ``PCG64`` for a similar implementation with a smaller period. + + **State and Seeding** + + The ``PCG32`` state vector consists of 2 unsigned 64-bit values. + ``PCG32`` is seeded using a single 64-bit unsigned integer. + In addition, a second 64-bit unsigned integer is used to set the stream. + + **Parallel Features** + + ``PCG32`` can be used in parallel applications in one of two ways. + The preferable method is to use sub-streams, which are generated by using the + same value of ``seed`` and incrementing the second value, ``inc``. + + >>> from numpy.random import Generator, PCG32 + >>> rg = [Generator(PCG32(1234, i + 1)) for i in range(10)] + + The alternative method is to call ``advance`` with a different value on + each instance to produce non-overlapping sequences. + + >>> rg = [Generator(PCG32(1234, i + 1)) for i in range(10)] + >>> for i in range(10): + ... rg[i].bit_generator.advance(i * 2**32) + + **Compatibility Guarantee** + + ``PCG32`` makes a guarantee that a fixed seed and will always produce + the same random integer stream. + + References + ---------- + .. [1] "PCG, A Family of Better Random Number Generators", + http://www.pcg-random.org/ + .. [2] O'Neill, Melissa E. "PCG: A Family of Simple Fast Space-Efficient + Statistically Good Algorithms for Random Number Generation" + """ + cdef pcg32_state rng_state + cdef pcg32_random_t pcg32_random_state + cdef bitgen_t _bitgen + cdef public object capsule + cdef object _ctypes + cdef object _cffi + cdef public object lock + + def __init__(self, seed=None, inc=0): + self.rng_state.pcg_state = &self.pcg32_random_state + self.seed(seed, inc) + self.lock = Lock() + + self._bitgen.state = <void *>&self.rng_state + self._bitgen.next_uint64 = &pcg32_uint64 + self._bitgen.next_uint32 = &pcg32_uint32 + self._bitgen.next_double = &pcg32_double + self._bitgen.next_raw = &pcg32_raw + + self._ctypes = None + self._cffi = None + + cdef const char *name = "BitGenerator" + self.capsule = PyCapsule_New(<void *>&self._bitgen, name, NULL) + + # Pickling support: + def __getstate__(self): + return self.state + + def __setstate__(self, state): + self.state = state + + def __reduce__(self): + from ._pickle import __bit_generator_ctor + return __bit_generator_ctor, (self.state['bit_generator'],), self.state + + def random_raw(self, size=None, output=True): + """ + random_raw(self, size=None) + + Return randoms as generated by the underlying BitGenerator + + Parameters + ---------- + size : int or tuple of ints, optional + Output shape. If the given shape is, e.g., ``(m, n, k)``, then + ``m * n * k`` samples are drawn. Default is None, in which case a + single value is returned. + output : bool, optional + Output values. Used for performance testing since the generated + values are not returned. + + Returns + ------- + out : uint or ndarray + Drawn samples. + + Notes + ----- + This method directly exposes the the raw underlying pseudo-random + number generator. All values are returned as unsigned 64-bit + values irrespective of the number of bits produced by the PRNG. + + See the class docstring for the number of bits returned. + """ + return random_raw(&self._bitgen, self.lock, size, output) + + def _benchmark(self, Py_ssize_t cnt, method=u'uint64'): + return benchmark(&self._bitgen, self.lock, cnt, method) + + def seed(self, seed=None, inc=0): + """ + seed(seed=None, inc=0) + + Seed the generator. + + This method is called at initialization. It can be called again to + re-seed the generator. + + Parameters + ---------- + seed : int, optional + Seed for ``PCG64``. Integer between 0 and 2**64-1. + inc : int, optional + Increment to use for PCG stream. Integer between 0 and 2**64-1. + + Raises + ------ + ValueError + If seed values are out of range for the PRNG. + """ + ub = 2 ** 64 + if seed is None: + try: + seed = <np.ndarray>random_entropy(2) + except RuntimeError: + seed = <np.ndarray>random_entropy(2, 'fallback') + seed = seed.view(np.uint64).squeeze() + else: + err_msg = 'seed must be a scalar integer between 0 and ' \ + '{ub}'.format(ub=ub) + if not np.isscalar(seed): + raise TypeError(err_msg) + if int(seed) != seed: + raise TypeError(err_msg) + if seed < 0 or seed > ub: + raise ValueError(err_msg) + + if not np.isscalar(inc): + raise TypeError('inc must be a scalar integer between 0 ' + 'and {ub}'.format(ub=ub)) + if inc < 0 or inc > ub or int(inc) != inc: + raise ValueError('inc must be a scalar integer between 0 ' + 'and {ub}'.format(ub=ub)) + + pcg32_set_seed(&self.rng_state, <uint64_t>seed, <uint64_t>inc) + + cdef jump_inplace(self, iter): + """ + Jump state in-place + + Not part of public API + + Parameters + ---------- + iter : integer, positive + Number of times to jump the state of the rng. + """ + self.advance(iter * 2**32) + + def jumped(self, iter=1): + """ + jumped(iter=1) + + Returns a new bit generator with the state jumped + + The state of the returned big generator is jumped as-if + 2**(32 * iter) random numbers have been generated. + + Parameters + ---------- + iter : integer, positive + Number of times to jump the state of the bit generator returned + + Returns + ------- + bit_generator : PCG32 + New instance of generator jumped iter times + """ + cdef PCG32 bit_generator + + bit_generator = self.__class__() + bit_generator.state = self.state + bit_generator.jump_inplace(iter) + + return bit_generator + + @property + def state(self): + """ + Get or set the PRNG state + + Returns + ------- + state : dict + Dictionary containing the information required to describe the + state of the PRNG + """ + return {'bit_generator': self.__class__.__name__, + 'state': {'state': self.rng_state.pcg_state.state, + 'inc': self.rng_state.pcg_state.inc}} + + @state.setter + def state(self, value): + if not isinstance(value, dict): + raise TypeError('state must be a dict') + bitgen = value.get('bit_generator', '') + if bitgen != self.__class__.__name__: + raise ValueError('state must be for a {0} ' + 'PRNG'.format(self.__class__.__name__)) + self.rng_state.pcg_state.state = value['state']['state'] + self.rng_state.pcg_state.inc = value['state']['inc'] + + def advance(self, delta): + """ + advance(delta) + + Advance the underlying RNG as-if delta draws have occurred. + + Parameters + ---------- + delta : integer, positive + Number of draws to advance the RNG. Must be less than the + size state variable in the underlying RNG. + + Returns + ------- + self : PCG32 + RNG advanced delta steps + + Notes + ----- + Advancing a RNG updates the underlying RNG state as-if a given + number of calls to the underlying RNG have been made. In general + there is not a one-to-one relationship between the number output + random values from a particular distribution and the number of + draws from the core RNG. This occurs for two reasons: + + * The random values are simulated using a rejection-based method + and so, on average, more than one value from the underlying + RNG is required to generate an single draw. + * The number of bits required to generate a simulated value + differs from the number of bits generated by the underlying + RNG. For example, two 16-bit integer values can be simulated + from a single draw of a 32-bit RNG. + """ + pcg32_advance_state(&self.rng_state, <uint64_t>delta) + return self + + @property + def ctypes(self): + """ + ctypes interface + + Returns + ------- + interface : namedtuple + Named tuple containing ctypes wrapper + + * state_address - Memory address of the state struct + * state - pointer to the state struct + * next_uint64 - function pointer to produce 64 bit integers + * next_uint32 - function pointer to produce 32 bit integers + * next_double - function pointer to produce doubles + * bitgen - pointer to the bit generator struct + """ + if self._ctypes is None: + self._ctypes = prepare_ctypes(&self._bitgen) + + return self._ctypes + + @property + def cffi(self): + """ + CFFI interface + + Returns + ------- + interface : namedtuple + Named tuple containing CFFI wrapper + + * state_address - Memory address of the state struct + * state - pointer to the state struct + * next_uint64 - function pointer to produce 64 bit integers + * next_uint32 - function pointer to produce 32 bit integers + * next_double - function pointer to produce doubles + * bitgen - pointer to the bit generator struct + """ + if self._cffi is not None: + return self._cffi + self._cffi = prepare_cffi(&self._bitgen) + return self._cffi diff --git a/numpy/random/pcg64.pyx b/numpy/random/pcg64.pyx new file mode 100644 index 000000000..7610fb203 --- /dev/null +++ b/numpy/random/pcg64.pyx @@ -0,0 +1,431 @@ +try: + from threading import Lock +except ImportError: + from dummy_threading import Lock + +from cpython.pycapsule cimport PyCapsule_New + +import numpy as np +cimport numpy as np + +from .common cimport * +from .distributions cimport bitgen_t +from .entropy import random_entropy + +__all__ = ['PCG64'] + +np.import_array() + +cdef extern from "src/pcg64/pcg64.h": + # Use int as generic type, actual type read from pcg64.h and is platform dependent + ctypedef int pcg64_random_t + + struct s_pcg64_state: + pcg64_random_t *pcg_state + int has_uint32 + uint32_t uinteger + + ctypedef s_pcg64_state pcg64_state + + uint64_t pcg64_next64(pcg64_state *state) nogil + uint32_t pcg64_next32(pcg64_state *state) nogil + void pcg64_jump(pcg64_state *state) + void pcg64_advance(pcg64_state *state, uint64_t *step) + void pcg64_set_seed(pcg64_state *state, uint64_t *seed, uint64_t *inc) + void pcg64_get_state(pcg64_state *state, uint64_t *state_arr, int *has_uint32, uint32_t *uinteger) + void pcg64_set_state(pcg64_state *state, uint64_t *state_arr, int has_uint32, uint32_t uinteger) + +cdef uint64_t pcg64_uint64(void* st) nogil: + return pcg64_next64(<pcg64_state *>st) + +cdef uint32_t pcg64_uint32(void *st) nogil: + return pcg64_next32(<pcg64_state *> st) + +cdef double pcg64_double(void* st) nogil: + return uint64_to_double(pcg64_next64(<pcg64_state *>st)) + + +cdef class PCG64: + u""" + PCG64(seed=None, inc=0) + + Container for the PCG-64 pseudo-random number generator. + + Parameters + ---------- + seed : {None, long}, optional + Random seed initializing the pseudo-random number generator. + Can be an integer in [0, 2**128] or ``None`` (the default). + If `seed` is ``None``, then ``PCG64`` will try to read data + from ``/dev/urandom`` (or the Windows analog) if available. If + unavailable, a 64-bit hash of the time and process ID is used. + inc : {None, int}, optional + Stream to return. + Can be an integer in [0, 2**128] or ``None`` (the default). If `inc` is + ``None``, then 0 is used. Can be used with the same seed to + produce multiple streams using other values of inc. + + Attributes + ---------- + lock: threading.Lock + Lock instance that is shared so that the same bit git generator can + be used in multiple Generators without corrupting the state. Code that + generates values from a bit generator should hold the bit generator's + lock. + + Notes + ----- + PCG-64 is a 128-bit implementation of O'Neill's permutation congruential + generator ([1]_, [2]_). PCG-64 has a period of :math:`2^{128}` and supports + advancing an arbitrary number of steps as well as :math:`2^{127}` streams. + + ``PCG64`` provides a capsule containing function pointers that produce + doubles, and unsigned 32 and 64- bit integers. These are not + directly consumable in Python and must be consumed by a ``Generator`` + or similar object that supports low-level access. + + Supports the method advance to advance the RNG an arbitrary number of + steps. The state of the PCG-64 RNG is represented by 2 128-bit unsigned + integers. + + See ``PCG32`` for a similar implementation with a smaller period. + + **State and Seeding** + + The ``PCG64`` state vector consists of 2 unsigned 128-bit values, + which are represented externally as Python ints. + ``PCG64`` is seeded using a single 128-bit unsigned integer. + In addition, a second 128-bit unsigned integer is used to set the stream. + + **Parallel Features** + + ``PCG64`` can be used in parallel applications in one of two ways. + The preferable method is to use sub-streams, which are generated by using the + same value of ``seed`` and incrementing the second value, ``inc``. + + >>> from numpy.random import Generator, PCG64 + >>> rg = [Generator(PCG64(1234, i + 1)) for i in range(10)] + + The alternative method is to call ``advance`` with a different value on + each instance to produce non-overlapping sequences. + + >>> rg = [Generator(PCG64(1234, i + 1)) for i in range(10)] + >>> for i in range(10): + ... rg[i].bit_generator.advance(i * 2**64) + + **Compatibility Guarantee** + + ``PCG64`` makes a guarantee that a fixed seed and will always produce + the same random integer stream. + + References + ---------- + .. [1] "PCG, A Family of Better Random Number Generators", + http://www.pcg-random.org/ + .. [2] O'Neill, Melissa E. "PCG: A Family of Simple Fast Space-Efficient + Statistically Good Algorithms for Random Number Generation" + """ + cdef pcg64_state rng_state + cdef pcg64_random_t pcg64_random_state + cdef bitgen_t _bitgen + cdef public object capsule + cdef object _ctypes + cdef object _cffi + cdef public object lock + + def __init__(self, seed=None, inc=0): + self.rng_state.pcg_state = &self.pcg64_random_state + self.seed(seed, inc) + self.lock = Lock() + + self._bitgen.state = <void *>&self.rng_state + self._bitgen.next_uint64 = &pcg64_uint64 + self._bitgen.next_uint32 = &pcg64_uint32 + self._bitgen.next_double = &pcg64_double + self._bitgen.next_raw = &pcg64_uint64 + + self._ctypes = None + self._cffi = None + + cdef const char *name = "BitGenerator" + self.capsule = PyCapsule_New(<void *>&self._bitgen, name, NULL) + + # Pickling support: + def __getstate__(self): + return self.state + + def __setstate__(self, state): + self.state = state + + def __reduce__(self): + from ._pickle import __bit_generator_ctor + return __bit_generator_ctor, (self.state['bit_generator'],), self.state + + cdef _reset_state_variables(self): + self.rng_state.has_uint32 = 0 + self.rng_state.uinteger = 0 + + def random_raw(self, size=None, output=True): + """ + random_raw(self, size=None) + + Return randoms as generated by the underlying BitGenerator + + Parameters + ---------- + size : int or tuple of ints, optional + Output shape. If the given shape is, e.g., ``(m, n, k)``, then + ``m * n * k`` samples are drawn. Default is None, in which case a + single value is returned. + output : bool, optional + Output values. Used for performance testing since the generated + values are not returned. + + Returns + ------- + out : uint or ndarray + Drawn samples. + + Notes + ----- + This method directly exposes the the raw underlying pseudo-random + number generator. All values are returned as unsigned 64-bit + values irrespective of the number of bits produced by the PRNG. + + See the class docstring for the number of bits returned. + """ + return random_raw(&self._bitgen, self.lock, size, output) + + def _benchmark(self, Py_ssize_t cnt, method=u'uint64'): + return benchmark(&self._bitgen, self.lock, cnt, method) + + def seed(self, seed=None, inc=0): + """ + seed(seed=None, inc=0) + + Seed the generator. + + This method is called at initialization. It can be called again to + re-seed the generator. + + Parameters + ---------- + seed : int, optional + Seed for ``PCG64``. Integer between 0 and 2**128-1. + inc : int, optional + Increment to use for PCG stream. Integer between 0 and 2**128-1. + + Raises + ------ + ValueError + If seed values are out of range for the PRNG. + """ + cdef np.ndarray _seed, _inc + ub = 2 ** 128 + if seed is None: + try: + _seed = <np.ndarray>random_entropy(4) + except RuntimeError: + _seed = <np.ndarray>random_entropy(4, 'fallback') + _seed = <np.ndarray>_seed.view(np.uint64) + else: + err_msg = 'seed must be a scalar integer between 0 and ' \ + '{ub}'.format(ub=ub) + if not np.isscalar(seed): + raise TypeError(err_msg) + if int(seed) != seed: + raise TypeError(err_msg) + if seed < 0 or seed > ub: + raise ValueError(err_msg) + _seed = <np.ndarray>np.empty(2, np.uint64) + _seed[0] = int(seed) // 2**64 + _seed[1] = int(seed) % 2**64 + + if not np.isscalar(inc): + raise TypeError('inc must be a scalar integer between 0 and {ub}'.format(ub=ub)) + if inc < 0 or inc > ub or int(inc) != inc: + raise ValueError('inc must be a scalar integer between 0 and {ub}'.format(ub=ub)) + _inc = <np.ndarray>np.empty(2, np.uint64) + _inc[0] = int(inc) // 2**64 + _inc[1] = int(inc) % 2**64 + + pcg64_set_seed(&self.rng_state, + <uint64_t *>np.PyArray_DATA(_seed), + <uint64_t *>np.PyArray_DATA(_inc)) + self._reset_state_variables() + + cdef jump_inplace(self, iter): + """ + Jump state in-place + + Not part of public API + + Parameters + ---------- + iter : integer, positive + Number of times to jump the state of the rng. + """ + self.advance(iter * 2**64) + + def jumped(self, iter=1): + """ + jumped(iter=1) + + Returns a new bit generator with the state jumped + + The state of the returned big generator is jumped as-if + 2**(64 * iter) random numbers have been generated. + + Parameters + ---------- + iter : integer, positive + Number of times to jump the state of the bit generator returned + + Returns + ------- + bit_generator : PCG64 + New instance of generator jumped iter times + """ + cdef PCG64 bit_generator + + bit_generator = self.__class__() + bit_generator.state = self.state + bit_generator.jump_inplace(iter) + + return bit_generator + + @property + def state(self): + """ + Get or set the PRNG state + + Returns + ------- + state : dict + Dictionary containing the information required to describe the + state of the PRNG + """ + cdef np.ndarray state_vec + cdef int has_uint32 + cdef uint32_t uinteger + + # state_vec is state.high, state.low, inc.high, inc.low + state_vec = <np.ndarray>np.empty(4, dtype=np.uint64) + pcg64_get_state(&self.rng_state, + <uint64_t *>np.PyArray_DATA(state_vec), + &has_uint32, &uinteger) + state = int(state_vec[0]) * 2**64 + int(state_vec[1]) + inc = int(state_vec[2]) * 2**64 + int(state_vec[3]) + return {'bit_generator': self.__class__.__name__, + 'state': {'state': state, 'inc': inc}, + 'has_uint32': has_uint32, + 'uinteger': uinteger} + + @state.setter + def state(self, value): + cdef np.ndarray state_vec + cdef int has_uint32 + cdef uint32_t uinteger + if not isinstance(value, dict): + raise TypeError('state must be a dict') + bitgen = value.get('bit_generator', '') + if bitgen != self.__class__.__name__: + raise ValueError('state must be for a {0} ' + 'RNG'.format(self.__class__.__name__)) + state_vec = <np.ndarray>np.empty(4, dtype=np.uint64) + state_vec[0] = value['state']['state'] // 2 ** 64 + state_vec[1] = value['state']['state'] % 2 ** 64 + state_vec[2] = value['state']['inc'] // 2 ** 64 + state_vec[3] = value['state']['inc'] % 2 ** 64 + has_uint32 = value['has_uint32'] + uinteger = value['uinteger'] + pcg64_set_state(&self.rng_state, + <uint64_t *>np.PyArray_DATA(state_vec), + has_uint32, uinteger) + + def advance(self, delta): + """ + advance(delta) + + Advance the underlying RNG as-if delta draws have occurred. + + Parameters + ---------- + delta : integer, positive + Number of draws to advance the RNG. Must be less than the + size state variable in the underlying RNG. + + Returns + ------- + self : PCG64 + RNG advanced delta steps + + Notes + ----- + Advancing a RNG updates the underlying RNG state as-if a given + number of calls to the underlying RNG have been made. In general + there is not a one-to-one relationship between the number output + random values from a particular distribution and the number of + draws from the core RNG. This occurs for two reasons: + + * The random values are simulated using a rejection-based method + and so, on average, more than one value from the underlying + RNG is required to generate an single draw. + * The number of bits required to generate a simulated value + differs from the number of bits generated by the underlying + RNG. For example, two 16-bit integer values can be simulated + from a single draw of a 32-bit RNG. + + Advancing the RNG state resets any pre-computed random numbers. + This is required to ensure exact reproducibility. + """ + cdef np.ndarray d = np.empty(2, dtype=np.uint64) + d[0] = delta // 2**64 + d[1] = delta % 2**64 + pcg64_advance(&self.rng_state, <uint64_t *>np.PyArray_DATA(d)) + self._reset_state_variables() + return self + + @property + def ctypes(self): + """ + ctypes interface + + Returns + ------- + interface : namedtuple + Named tuple containing ctypes wrapper + + * state_address - Memory address of the state struct + * state - pointer to the state struct + * next_uint64 - function pointer to produce 64 bit integers + * next_uint32 - function pointer to produce 32 bit integers + * next_double - function pointer to produce doubles + * bitgen - pointer to the bit generator struct + """ + if self._ctypes is None: + self._ctypes = prepare_ctypes(&self._bitgen) + + return self._ctypes + + @property + def cffi(self): + """ + CFFI interface + + Returns + ------- + interface : namedtuple + Named tuple containing CFFI wrapper + + * state_address - Memory address of the state struct + * state - pointer to the state struct + * next_uint64 - function pointer to produce 64 bit integers + * next_uint32 - function pointer to produce 32 bit integers + * next_double - function pointer to produce doubles + * bitgen - pointer to the bit generator struct + """ + if self._cffi is not None: + return self._cffi + self._cffi = prepare_cffi(&self._bitgen) + return self._cffi diff --git a/numpy/random/setup.py b/numpy/random/setup.py index b8b190b09..b634b5eb0 100644 --- a/numpy/random/setup.py +++ b/numpy/random/setup.py @@ -58,6 +58,10 @@ def configuration(parent_package='', top_path=None): # Required defined for DSFMT size and to allow it to detect SSE2 using # config file information DSFMT_DEFS = [('DSFMT_MEXP', '19937'), ("HAVE_NPY_CONFIG_H", "1")] + PCG64_DEFS = [] + if 1 or sys.maxsize < 2 ** 32 or os.name == 'nt': + # Force emulated mode here + PCG64_DEFS += [('PCG_FORCE_EMULATED_128BIT_MATH', '1')] config.add_extension('entropy', sources=['entropy.c', 'src/entropy/entropy.c'] + @@ -97,8 +101,10 @@ def configuration(parent_package='', top_path=None): depends=['%s.pyx' % gen], define_macros=defs, ) - for gen in ['philox', 'threefry', 'xoshiro256', 'xoshiro512']: + for gen in ['philox', 'threefry', 'xoshiro256', 'xoshiro512', + 'pcg64', 'pcg32']: # gen.pyx, src/gen/gen.c + _defs = defs + PCG64_DEFS if gen == 'pcg64' else defs config.add_extension(gen, sources=['{0}.c'.format(gen), 'src/{0}/{0}.c'.format(gen)], @@ -107,7 +113,7 @@ def configuration(parent_package='', top_path=None): extra_compile_args=EXTRA_COMPILE_ARGS, extra_link_args=EXTRA_LINK_ARGS, depends=['%s.pyx' % gen], - define_macros=defs, + define_macros=_defs, ) for gen in ['common']: # gen.pyx diff --git a/numpy/random/src/pcg32/LICENSE.md b/numpy/random/src/pcg32/LICENSE.md new file mode 100644 index 000000000..e28ef1a8b --- /dev/null +++ b/numpy/random/src/pcg32/LICENSE.md @@ -0,0 +1,22 @@ +# PCG32 + +## The MIT License + +PCG Random Number Generation for C. + +Copyright 2014 Melissa O'Neill <oneill@pcg-random.org> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/numpy/random/src/pcg32/pcg-advance-64.c b/numpy/random/src/pcg32/pcg-advance-64.c new file mode 100644 index 000000000..8210e7565 --- /dev/null +++ b/numpy/random/src/pcg32/pcg-advance-64.c @@ -0,0 +1,62 @@ +/* + * PCG Random Number Generation for C. + * + * Copyright 2014 Melissa O'Neill <oneill@pcg-random.org> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * For additional information about the PCG random number generation scheme, + * including its license and other licensing options, visit + * + * http://www.pcg-random.org + */ + +/* + * This code is derived from the canonical C++ PCG implementation, which + * has many additional features and is preferable if you can use C++ in + * your project. + * + * Repetative C code is derived using C preprocessor metaprogramming + * techniques. + */ + +#include "pcg_variants.h" + +/* Multi-step advance functions (jump-ahead, jump-back) + * + * The method used here is based on Brown, "Random Number Generation + * with Arbitrary Stride,", Transactions of the American Nuclear + * Society (Nov. 1994). The algorithm is very similar to fast + * exponentiation. + * + * Even though delta is an unsigned integer, we can pass a + * signed integer to go backwards, it just goes "the long way round". + */ + +uint64_t pcg_advance_lcg_64(uint64_t state, uint64_t delta, uint64_t cur_mult, + uint64_t cur_plus) +{ + uint64_t acc_mult = 1u; + uint64_t acc_plus = 0u; + while (delta > 0) { + if (delta & 1) { + acc_mult *= cur_mult; + acc_plus = acc_plus * cur_mult + cur_plus; + } + cur_plus = (cur_mult + 1) * cur_plus; + cur_mult *= cur_mult; + delta /= 2; + } + return acc_mult * state + acc_plus; +} + diff --git a/numpy/random/src/pcg32/pcg32-test-data-gen.c b/numpy/random/src/pcg32/pcg32-test-data-gen.c new file mode 100644 index 000000000..cccaf84b9 --- /dev/null +++ b/numpy/random/src/pcg32/pcg32-test-data-gen.c @@ -0,0 +1,59 @@ +/* + * Generate testing csv files + * + * + * gcc pcg32-test-data-gen.c pcg32.orig.c ../splitmix64/splitmix64.c -o + * pgc64-test-data-gen + */ + +#include "pcg_variants.h" +#include <inttypes.h> +#include <stdio.h> + +#define N 1000 + +int main() { + pcg32_random_t rng; + uint64_t inc, seed = 0xDEADBEAF; + inc = 0; + int i; + uint64_t store[N]; + pcg32_srandom_r(&rng, seed, inc); + for (i = 0; i < N; i++) { + store[i] = pcg32_random_r(&rng); + } + + FILE *fp; + fp = fopen("pcg32-testset-1.csv", "w"); + if (fp == NULL) { + printf("Couldn't open file\n"); + return -1; + } + fprintf(fp, "seed, 0x%" PRIx64 "\n", seed); + for (i = 0; i < N; i++) { + fprintf(fp, "%d, 0x%" PRIx64 "\n", i, store[i]); + if (i == 999) { + printf("%d, 0x%" PRIx64 "\n", i, store[i]); + } + } + fclose(fp); + + seed = 0; + pcg32_srandom_r(&rng, seed, inc); + for (i = 0; i < N; i++) { + store[i] = pcg32_random_r(&rng); + } + fp = fopen("pcg32-testset-2.csv", "w"); + if (fp == NULL) { + printf("Couldn't open file\n"); + return -1; + } + fprintf(fp, "seed, 0x%" PRIx64 "\n", seed); + for (i = 0; i < N; i++) { + fprintf(fp, "%d, 0x%" PRIx64 "\n", i, store[i]); + if (i == 999) { + printf("%d, 0x%" PRIx64 "\n", i, store[i]); + } + } + fclose(fp); +} diff --git a/numpy/random/src/pcg32/pcg32.c b/numpy/random/src/pcg32/pcg32.c new file mode 100644 index 000000000..5fbf6759f --- /dev/null +++ b/numpy/random/src/pcg32/pcg32.c @@ -0,0 +1,30 @@ +#include "pcg32.h" + +extern inline uint64_t pcg32_next64(pcg32_state *state); +extern inline uint32_t pcg32_next32(pcg32_state *state); +extern inline double pcg32_next_double(pcg32_state *state); + +uint64_t pcg_advance_lcg_64(uint64_t state, uint64_t delta, uint64_t cur_mult, + uint64_t cur_plus) { + uint64_t acc_mult, acc_plus; + acc_mult = 1u; + acc_plus = 0u; + while (delta > 0) { + if (delta & 1) { + acc_mult *= cur_mult; + acc_plus = acc_plus * cur_mult + cur_plus; + } + cur_plus = (cur_mult + 1) * cur_plus; + cur_mult *= cur_mult; + delta /= 2; + } + return acc_mult * state + acc_plus; +} + +extern void pcg32_advance_state(pcg32_state *state, uint64_t step) { + pcg32_advance_r(state->pcg_state, step); +} + +extern void pcg32_set_seed(pcg32_state *state, uint64_t seed, uint64_t inc) { + pcg32_srandom_r(state->pcg_state, seed, inc); +} diff --git a/numpy/random/src/pcg32/pcg32.h b/numpy/random/src/pcg32/pcg32.h new file mode 100644 index 000000000..32c6b693d --- /dev/null +++ b/numpy/random/src/pcg32/pcg32.h @@ -0,0 +1,86 @@ +#ifndef _RANDOMDGEN__PCG32_H_ +#define _RANDOMDGEN__PCG32_H_ + +#include <inttypes.h> + +#ifdef _WIN32 +#define inline __forceinline +#endif + +#define PCG_DEFAULT_MULTIPLIER_64 6364136223846793005ULL + +struct pcg_state_setseq_64 { + uint64_t state; + uint64_t inc; +}; + +static inline uint32_t pcg_rotr_32(uint32_t value, unsigned int rot) { +#if PCG_USE_INLINE_ASM && __clang__ && (__x86_64__ || __i386__) + asm("rorl %%cl, %0" : "=r"(value) : "0"(value), "c"(rot)); + return value; +#else + return (value >> rot) | (value << ((-rot) & 31)); +#endif +} + +static inline void pcg_setseq_64_step_r(struct pcg_state_setseq_64 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_64 + rng->inc; +} + +static inline uint32_t pcg_output_xsh_rr_64_32(uint64_t state) { + return pcg_rotr_32(((state >> 18u) ^ state) >> 27u, state >> 59u); +} + +static inline uint32_t +pcg_setseq_64_xsh_rr_32_random_r(struct pcg_state_setseq_64 *rng) { + uint64_t oldstate; + oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_xsh_rr_64_32(oldstate); +} + +static inline void pcg_setseq_64_srandom_r(struct pcg_state_setseq_64 *rng, + uint64_t initstate, + uint64_t initseq) { + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_64_step_r(rng); + rng->state += initstate; + pcg_setseq_64_step_r(rng); +} + +extern uint64_t pcg_advance_lcg_64(uint64_t state, uint64_t delta, + uint64_t cur_mult, uint64_t cur_plus); + +static inline void pcg_setseq_64_advance_r(struct pcg_state_setseq_64 *rng, + uint64_t delta) { + rng->state = pcg_advance_lcg_64(rng->state, delta, PCG_DEFAULT_MULTIPLIER_64, + rng->inc); +} + +typedef struct pcg_state_setseq_64 pcg32_random_t; +#define pcg32_random_r pcg_setseq_64_xsh_rr_32_random_r +#define pcg32_srandom_r pcg_setseq_64_srandom_r +#define pcg32_advance_r pcg_setseq_64_advance_r + +typedef struct s_pcg32_state { pcg32_random_t *pcg_state; } pcg32_state; + +static inline uint64_t pcg32_next64(pcg32_state *state) { + return (uint64_t)(pcg32_random_r(state->pcg_state)) << 32 | + pcg32_random_r(state->pcg_state); +} + +static inline uint32_t pcg32_next32(pcg32_state *state) { + return pcg32_random_r(state->pcg_state); +} + +static inline double pcg32_next_double(pcg32_state *state) { + int32_t a = pcg32_random_r(state->pcg_state) >> 5, + b = pcg32_random_r(state->pcg_state) >> 6; + return (a * 67108864.0 + b) / 9007199254740992.0; +} + +void pcg32_advance_state(pcg32_state *state, uint64_t step); +void pcg32_set_seed(pcg32_state *state, uint64_t seed, uint64_t inc); + +#endif diff --git a/numpy/random/src/pcg32/pcg_variants.h b/numpy/random/src/pcg32/pcg_variants.h new file mode 100644 index 000000000..32daac1ce --- /dev/null +++ b/numpy/random/src/pcg32/pcg_variants.h @@ -0,0 +1,2210 @@ +/* + * PCG Random Number Generation for C. + * + * Copyright 2014 Melissa O'Neill <oneill@pcg-random.org> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * For additional information about the PCG random number generation scheme, + * including its license and other licensing options, visit + * + * http://www.pcg-random.org + */ + +/* + * This code is derived from the canonical C++ PCG implementation, which + * has many additional features and is preferable if you can use C++ in + * your project. + * + * Much of the derivation was performed mechanically. In particular, the + * output functions were generated by compiling the C++ output functions + * into LLVM bitcode and then transforming that using the LLVM C backend + * (from https://github.com/draperlaboratory/llvm-cbe), and then + * postprocessing and hand editing the output. + * + * Much of the remaining code was generated by C-preprocessor metaprogramming. + */ + +#ifndef PCG_VARIANTS_H_INCLUDED +#define PCG_VARIANTS_H_INCLUDED 1 + +#include <inttypes.h> + +#if __SIZEOF_INT128__ + typedef __uint128_t pcg128_t; + #define PCG_128BIT_CONSTANT(high,low) \ + ((((pcg128_t)high) << 64) + low) + #define PCG_HAS_128BIT_OPS 1 +#endif + +#if __GNUC_GNU_INLINE__ && !defined(__cplusplus) + #error Nonstandard GNU inlining semantics. Compile with -std=c99 or better. + // We could instead use macros PCG_INLINE and PCG_EXTERN_INLINE + // but better to just reject ancient C code. +#endif + +#if __cplusplus +extern "C" { +#endif + +/* + * Rotate helper functions. + */ + +inline uint8_t pcg_rotr_8(uint8_t value, unsigned int rot) +{ +/* Unfortunately, clang is kinda pathetic when it comes to properly + * recognizing idiomatic rotate code, so for clang we actually provide + * assembler directives (enabled with PCG_USE_INLINE_ASM). Boo, hiss. + */ +#if PCG_USE_INLINE_ASM && __clang__ && (__x86_64__ || __i386__) + asm ("rorb %%cl, %0" : "=r" (value) : "0" (value), "c" (rot)); + return value; +#else + return (value >> rot) | (value << ((- rot) & 7)); +#endif +} + +inline uint16_t pcg_rotr_16(uint16_t value, unsigned int rot) +{ +#if PCG_USE_INLINE_ASM && __clang__ && (__x86_64__ || __i386__) + asm ("rorw %%cl, %0" : "=r" (value) : "0" (value), "c" (rot)); + return value; +#else + return (value >> rot) | (value << ((- rot) & 15)); +#endif +} + +inline uint32_t pcg_rotr_32(uint32_t value, unsigned int rot) +{ +#if PCG_USE_INLINE_ASM && __clang__ && (__x86_64__ || __i386__) + asm ("rorl %%cl, %0" : "=r" (value) : "0" (value), "c" (rot)); + return value; +#else + return (value >> rot) | (value << ((- rot) & 31)); +#endif +} + +inline uint64_t pcg_rotr_64(uint64_t value, unsigned int rot) +{ +#if 0 && PCG_USE_INLINE_ASM && __clang__ && __x86_64__ + // For whatever reason, clang actually *does* generate rotq by + // itself, so we don't need this code. + asm ("rorq %%cl, %0" : "=r" (value) : "0" (value), "c" (rot)); + return value; +#else + return (value >> rot) | (value << ((- rot) & 63)); +#endif +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_rotr_128(pcg128_t value, unsigned int rot) +{ + return (value >> rot) | (value << ((- rot) & 127)); +} +#endif + +/* + * Output functions. These are the core of the PCG generation scheme. + */ + +// XSH RS + +inline uint8_t pcg_output_xsh_rs_16_8(uint16_t state) +{ + return (uint8_t)(((state >> 7u) ^ state) >> ((state >> 14u) + 3u)); +} + +inline uint16_t pcg_output_xsh_rs_32_16(uint32_t state) +{ + return (uint16_t)(((state >> 11u) ^ state) >> ((state >> 30u) + 11u)); +} + +inline uint32_t pcg_output_xsh_rs_64_32(uint64_t state) +{ + + return (uint32_t)(((state >> 22u) ^ state) >> ((state >> 61u) + 22u)); +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_output_xsh_rs_128_64(pcg128_t state) +{ + return (uint64_t)(((state >> 43u) ^ state) >> ((state >> 124u) + 45u)); +} +#endif + +// XSH RR + +inline uint8_t pcg_output_xsh_rr_16_8(uint16_t state) +{ + return pcg_rotr_8(((state >> 5u) ^ state) >> 5u, state >> 13u); +} + +inline uint16_t pcg_output_xsh_rr_32_16(uint32_t state) +{ + return pcg_rotr_16(((state >> 10u) ^ state) >> 12u, state >> 28u); +} + +inline uint32_t pcg_output_xsh_rr_64_32(uint64_t state) +{ + return pcg_rotr_32(((state >> 18u) ^ state) >> 27u, state >> 59u); +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_output_xsh_rr_128_64(pcg128_t state) +{ + return pcg_rotr_64(((state >> 29u) ^ state) >> 58u, state >> 122u); +} +#endif + +// RXS M XS + +inline uint8_t pcg_output_rxs_m_xs_8_8(uint8_t state) +{ + uint8_t word = ((state >> ((state >> 6u) + 2u)) ^ state) * 217u; + return (word >> 6u) ^ word; +} + +inline uint16_t pcg_output_rxs_m_xs_16_16(uint16_t state) +{ + uint16_t word = ((state >> ((state >> 13u) + 3u)) ^ state) * 62169u; + return (word >> 11u) ^ word; +} + +inline uint32_t pcg_output_rxs_m_xs_32_32(uint32_t state) +{ + uint32_t word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u; + return (word >> 22u) ^ word; +} + +inline uint64_t pcg_output_rxs_m_xs_64_64(uint64_t state) +{ + uint64_t word = ((state >> ((state >> 59u) + 5u)) ^ state) + * 12605985483714917081ull; + return (word >> 43u) ^ word; +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_output_rxs_m_xs_128_128(pcg128_t state) +{ + pcg128_t word = ((state >> ((state >> 122u) + 6u)) ^ state) + * (PCG_128BIT_CONSTANT(17766728186571221404ULL, + 12605985483714917081ULL)); + // 327738287884841127335028083622016905945 + return (word >> 86u) ^ word; +} +#endif + +// XSL RR (only defined for >= 64 bits) + +inline uint32_t pcg_output_xsl_rr_64_32(uint64_t state) +{ + return pcg_rotr_32(((uint32_t)(state >> 32u)) ^ (uint32_t)state, + state >> 59u); +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_output_xsl_rr_128_64(pcg128_t state) +{ + return pcg_rotr_64(((uint64_t)(state >> 64u)) ^ (uint64_t)state, + state >> 122u); +} +#endif + +// XSL RR RR (only defined for >= 64 bits) + +inline uint64_t pcg_output_xsl_rr_rr_64_64(uint64_t state) +{ + uint32_t rot1 = (uint32_t)(state >> 59u); + uint32_t high = (uint32_t)(state >> 32u); + uint32_t low = (uint32_t)state; + uint32_t xored = high ^ low; + uint32_t newlow = pcg_rotr_32(xored, rot1); + uint32_t newhigh = pcg_rotr_32(high, newlow & 31u); + return (((uint64_t)newhigh) << 32u) | newlow; +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_output_xsl_rr_rr_128_128(pcg128_t state) +{ + uint32_t rot1 = (uint32_t)(state >> 122u); + uint64_t high = (uint64_t)(state >> 64u); + uint64_t low = (uint64_t)state; + uint64_t xored = high ^ low; + uint64_t newlow = pcg_rotr_64(xored, rot1); + uint64_t newhigh = pcg_rotr_64(high, newlow & 63u); + return (((pcg128_t)newhigh) << 64u) | newlow; +} +#endif + +#define PCG_DEFAULT_MULTIPLIER_8 141U +#define PCG_DEFAULT_MULTIPLIER_16 12829U +#define PCG_DEFAULT_MULTIPLIER_32 747796405U +#define PCG_DEFAULT_MULTIPLIER_64 6364136223846793005ULL + +#define PCG_DEFAULT_INCREMENT_8 77U +#define PCG_DEFAULT_INCREMENT_16 47989U +#define PCG_DEFAULT_INCREMENT_32 2891336453U +#define PCG_DEFAULT_INCREMENT_64 1442695040888963407ULL + +#if PCG_HAS_128BIT_OPS +#define PCG_DEFAULT_MULTIPLIER_128 \ + PCG_128BIT_CONSTANT(2549297995355413924ULL,4865540595714422341ULL) +#define PCG_DEFAULT_INCREMENT_128 \ + PCG_128BIT_CONSTANT(6364136223846793005ULL,1442695040888963407ULL) +#endif + +/* + * Static initialization constants (if you can't call srandom for some + * bizarre reason). + */ + +#define PCG_STATE_ONESEQ_8_INITIALIZER { 0xd7U } +#define PCG_STATE_ONESEQ_16_INITIALIZER { 0x20dfU } +#define PCG_STATE_ONESEQ_32_INITIALIZER { 0x46b56677U } +#define PCG_STATE_ONESEQ_64_INITIALIZER { 0x4d595df4d0f33173ULL } +#if PCG_HAS_128BIT_OPS +#define PCG_STATE_ONESEQ_128_INITIALIZER \ + { PCG_128BIT_CONSTANT(0xb8dc10e158a92392ULL, 0x98046df007ec0a53ULL) } +#endif + +#define PCG_STATE_UNIQUE_8_INITIALIZER PCG_STATE_ONESEQ_8_INITIALIZER +#define PCG_STATE_UNIQUE_16_INITIALIZER PCG_STATE_ONESEQ_16_INITIALIZER +#define PCG_STATE_UNIQUE_32_INITIALIZER PCG_STATE_ONESEQ_32_INITIALIZER +#define PCG_STATE_UNIQUE_64_INITIALIZER PCG_STATE_ONESEQ_64_INITIALIZER +#if PCG_HAS_128BIT_OPS +#define PCG_STATE_UNIQUE_128_INITIALIZER PCG_STATE_ONESEQ_128_INITIALIZER +#endif + +#define PCG_STATE_MCG_8_INITIALIZER { 0xe5U } +#define PCG_STATE_MCG_16_INITIALIZER { 0xa5e5U } +#define PCG_STATE_MCG_32_INITIALIZER { 0xd15ea5e5U } +#define PCG_STATE_MCG_64_INITIALIZER { 0xcafef00dd15ea5e5ULL } +#if PCG_HAS_128BIT_OPS +#define PCG_STATE_MCG_128_INITIALIZER \ + { PCG_128BIT_CONSTANT(0x0000000000000000ULL, 0xcafef00dd15ea5e5ULL) } +#endif + +#define PCG_STATE_SETSEQ_8_INITIALIZER { 0x9bU, 0xdbU } +#define PCG_STATE_SETSEQ_16_INITIALIZER { 0xe39bU, 0x5bdbU } +#define PCG_STATE_SETSEQ_32_INITIALIZER { 0xec02d89bU, 0x94b95bdbU } +#define PCG_STATE_SETSEQ_64_INITIALIZER \ + { 0x853c49e6748fea9bULL, 0xda3e39cb94b95bdbULL } +#if PCG_HAS_128BIT_OPS +#define PCG_STATE_SETSEQ_128_INITIALIZER \ + { PCG_128BIT_CONSTANT(0x979c9a98d8462005ULL, 0x7d3e9cb6cfe0549bULL), \ + PCG_128BIT_CONSTANT(0x0000000000000001ULL, 0xda3e39cb94b95bdbULL) } +#endif + +/* Representations for the oneseq, mcg, and unique variants */ + +struct pcg_state_8 { + uint8_t state; +}; + +struct pcg_state_16 { + uint16_t state; +}; + +struct pcg_state_32 { + uint32_t state; +}; + +struct pcg_state_64 { + uint64_t state; +}; + +#if PCG_HAS_128BIT_OPS +struct pcg_state_128 { + pcg128_t state; +}; +#endif + +/* Representations setseq variants */ + +struct pcg_state_setseq_8 { + uint8_t state; + uint8_t inc; +}; + +struct pcg_state_setseq_16 { + uint16_t state; + uint16_t inc; +}; + +struct pcg_state_setseq_32 { + uint32_t state; + uint32_t inc; +}; + +struct pcg_state_setseq_64 { + uint64_t state; + uint64_t inc; +}; + +#if PCG_HAS_128BIT_OPS +struct pcg_state_setseq_128 { + pcg128_t state; + pcg128_t inc; +}; +#endif + +/* Multi-step advance functions (jump-ahead, jump-back) */ + +extern uint8_t pcg_advance_lcg_8(uint8_t state, uint8_t delta, uint8_t cur_mult, + uint8_t cur_plus); +extern uint16_t pcg_advance_lcg_16(uint16_t state, uint16_t delta, + uint16_t cur_mult, uint16_t cur_plus); +extern uint32_t pcg_advance_lcg_32(uint32_t state, uint32_t delta, + uint32_t cur_mult, uint32_t cur_plus); +extern uint64_t pcg_advance_lcg_64(uint64_t state, uint64_t delta, + uint64_t cur_mult, uint64_t cur_plus); + +#if PCG_HAS_128BIT_OPS +extern pcg128_t pcg_advance_lcg_128(pcg128_t state, pcg128_t delta, + pcg128_t cur_mult, pcg128_t cur_plus); +#endif + +/* Functions to advance the underlying LCG, one version for each size and + * each style. These functions are considered semi-private. There is rarely + * a good reason to call them directly. + */ + +inline void pcg_oneseq_8_step_r(struct pcg_state_8* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_8 + + PCG_DEFAULT_INCREMENT_8; +} + +inline void pcg_oneseq_8_advance_r(struct pcg_state_8* rng, uint8_t delta) +{ + rng->state = pcg_advance_lcg_8(rng->state, delta, PCG_DEFAULT_MULTIPLIER_8, + PCG_DEFAULT_INCREMENT_8); +} + +inline void pcg_mcg_8_step_r(struct pcg_state_8* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_8; +} + +inline void pcg_mcg_8_advance_r(struct pcg_state_8* rng, uint8_t delta) +{ + rng->state + = pcg_advance_lcg_8(rng->state, delta, PCG_DEFAULT_MULTIPLIER_8, 0u); +} + +inline void pcg_unique_8_step_r(struct pcg_state_8* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_8 + + (uint8_t)(((intptr_t)rng) | 1u); +} + +inline void pcg_unique_8_advance_r(struct pcg_state_8* rng, uint8_t delta) +{ + rng->state = pcg_advance_lcg_8(rng->state, delta, PCG_DEFAULT_MULTIPLIER_8, + (uint8_t)(((intptr_t)rng) | 1u)); +} + +inline void pcg_setseq_8_step_r(struct pcg_state_setseq_8* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_8 + rng->inc; +} + +inline void pcg_setseq_8_advance_r(struct pcg_state_setseq_8* rng, + uint8_t delta) +{ + rng->state = pcg_advance_lcg_8(rng->state, delta, PCG_DEFAULT_MULTIPLIER_8, + rng->inc); +} + +inline void pcg_oneseq_16_step_r(struct pcg_state_16* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_16 + + PCG_DEFAULT_INCREMENT_16; +} + +inline void pcg_oneseq_16_advance_r(struct pcg_state_16* rng, uint16_t delta) +{ + rng->state = pcg_advance_lcg_16( + rng->state, delta, PCG_DEFAULT_MULTIPLIER_16, PCG_DEFAULT_INCREMENT_16); +} + +inline void pcg_mcg_16_step_r(struct pcg_state_16* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_16; +} + +inline void pcg_mcg_16_advance_r(struct pcg_state_16* rng, uint16_t delta) +{ + rng->state + = pcg_advance_lcg_16(rng->state, delta, PCG_DEFAULT_MULTIPLIER_16, 0u); +} + +inline void pcg_unique_16_step_r(struct pcg_state_16* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_16 + + (uint16_t)(((intptr_t)rng) | 1u); +} + +inline void pcg_unique_16_advance_r(struct pcg_state_16* rng, uint16_t delta) +{ + rng->state + = pcg_advance_lcg_16(rng->state, delta, PCG_DEFAULT_MULTIPLIER_16, + (uint16_t)(((intptr_t)rng) | 1u)); +} + +inline void pcg_setseq_16_step_r(struct pcg_state_setseq_16* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_16 + rng->inc; +} + +inline void pcg_setseq_16_advance_r(struct pcg_state_setseq_16* rng, + uint16_t delta) +{ + rng->state = pcg_advance_lcg_16(rng->state, delta, + PCG_DEFAULT_MULTIPLIER_16, rng->inc); +} + +inline void pcg_oneseq_32_step_r(struct pcg_state_32* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_32 + + PCG_DEFAULT_INCREMENT_32; +} + +inline void pcg_oneseq_32_advance_r(struct pcg_state_32* rng, uint32_t delta) +{ + rng->state = pcg_advance_lcg_32( + rng->state, delta, PCG_DEFAULT_MULTIPLIER_32, PCG_DEFAULT_INCREMENT_32); +} + +inline void pcg_mcg_32_step_r(struct pcg_state_32* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_32; +} + +inline void pcg_mcg_32_advance_r(struct pcg_state_32* rng, uint32_t delta) +{ + rng->state + = pcg_advance_lcg_32(rng->state, delta, PCG_DEFAULT_MULTIPLIER_32, 0u); +} + +inline void pcg_unique_32_step_r(struct pcg_state_32* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_32 + + (uint32_t)(((intptr_t)rng) | 1u); +} + +inline void pcg_unique_32_advance_r(struct pcg_state_32* rng, uint32_t delta) +{ + rng->state + = pcg_advance_lcg_32(rng->state, delta, PCG_DEFAULT_MULTIPLIER_32, + (uint32_t)(((intptr_t)rng) | 1u)); +} + +inline void pcg_setseq_32_step_r(struct pcg_state_setseq_32* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_32 + rng->inc; +} + +inline void pcg_setseq_32_advance_r(struct pcg_state_setseq_32* rng, + uint32_t delta) +{ + rng->state = pcg_advance_lcg_32(rng->state, delta, + PCG_DEFAULT_MULTIPLIER_32, rng->inc); +} + +inline void pcg_oneseq_64_step_r(struct pcg_state_64* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_64 + + PCG_DEFAULT_INCREMENT_64; +} + +inline void pcg_oneseq_64_advance_r(struct pcg_state_64* rng, uint64_t delta) +{ + rng->state = pcg_advance_lcg_64( + rng->state, delta, PCG_DEFAULT_MULTIPLIER_64, PCG_DEFAULT_INCREMENT_64); +} + +inline void pcg_mcg_64_step_r(struct pcg_state_64* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_64; +} + +inline void pcg_mcg_64_advance_r(struct pcg_state_64* rng, uint64_t delta) +{ + rng->state + = pcg_advance_lcg_64(rng->state, delta, PCG_DEFAULT_MULTIPLIER_64, 0u); +} + +inline void pcg_unique_64_step_r(struct pcg_state_64* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_64 + + (uint64_t)(((intptr_t)rng) | 1u); +} + +inline void pcg_unique_64_advance_r(struct pcg_state_64* rng, uint64_t delta) +{ + rng->state + = pcg_advance_lcg_64(rng->state, delta, PCG_DEFAULT_MULTIPLIER_64, + (uint64_t)(((intptr_t)rng) | 1u)); +} + +inline void pcg_setseq_64_step_r(struct pcg_state_setseq_64* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_64 + rng->inc; +} + +inline void pcg_setseq_64_advance_r(struct pcg_state_setseq_64* rng, + uint64_t delta) +{ + rng->state = pcg_advance_lcg_64(rng->state, delta, + PCG_DEFAULT_MULTIPLIER_64, rng->inc); +} + +#if PCG_HAS_128BIT_OPS +inline void pcg_oneseq_128_step_r(struct pcg_state_128* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_128 + + PCG_DEFAULT_INCREMENT_128; +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_oneseq_128_advance_r(struct pcg_state_128* rng, pcg128_t delta) +{ + rng->state + = pcg_advance_lcg_128(rng->state, delta, PCG_DEFAULT_MULTIPLIER_128, + PCG_DEFAULT_INCREMENT_128); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_mcg_128_step_r(struct pcg_state_128* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_128; +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_mcg_128_advance_r(struct pcg_state_128* rng, pcg128_t delta) +{ + rng->state = pcg_advance_lcg_128(rng->state, delta, + PCG_DEFAULT_MULTIPLIER_128, 0u); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_unique_128_step_r(struct pcg_state_128* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_128 + + (pcg128_t)(((intptr_t)rng) | 1u); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_unique_128_advance_r(struct pcg_state_128* rng, pcg128_t delta) +{ + rng->state + = pcg_advance_lcg_128(rng->state, delta, PCG_DEFAULT_MULTIPLIER_128, + (pcg128_t)(((intptr_t)rng) | 1u)); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_setseq_128_step_r(struct pcg_state_setseq_128* rng) +{ + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_128 + rng->inc; +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_setseq_128_advance_r(struct pcg_state_setseq_128* rng, + pcg128_t delta) +{ + rng->state = pcg_advance_lcg_128(rng->state, delta, + PCG_DEFAULT_MULTIPLIER_128, rng->inc); +} +#endif + +/* Functions to seed the RNG state, one version for each size and each + * style. Unlike the step functions, regular users can and should call + * these functions. + */ + +inline void pcg_oneseq_8_srandom_r(struct pcg_state_8* rng, uint8_t initstate) +{ + rng->state = 0U; + pcg_oneseq_8_step_r(rng); + rng->state += initstate; + pcg_oneseq_8_step_r(rng); +} + +inline void pcg_mcg_8_srandom_r(struct pcg_state_8* rng, uint8_t initstate) +{ + rng->state = initstate | 1u; +} + +inline void pcg_unique_8_srandom_r(struct pcg_state_8* rng, uint8_t initstate) +{ + rng->state = 0U; + pcg_unique_8_step_r(rng); + rng->state += initstate; + pcg_unique_8_step_r(rng); +} + +inline void pcg_setseq_8_srandom_r(struct pcg_state_setseq_8* rng, + uint8_t initstate, uint8_t initseq) +{ + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_8_step_r(rng); + rng->state += initstate; + pcg_setseq_8_step_r(rng); +} + +inline void pcg_oneseq_16_srandom_r(struct pcg_state_16* rng, + uint16_t initstate) +{ + rng->state = 0U; + pcg_oneseq_16_step_r(rng); + rng->state += initstate; + pcg_oneseq_16_step_r(rng); +} + +inline void pcg_mcg_16_srandom_r(struct pcg_state_16* rng, uint16_t initstate) +{ + rng->state = initstate | 1u; +} + +inline void pcg_unique_16_srandom_r(struct pcg_state_16* rng, + uint16_t initstate) +{ + rng->state = 0U; + pcg_unique_16_step_r(rng); + rng->state += initstate; + pcg_unique_16_step_r(rng); +} + +inline void pcg_setseq_16_srandom_r(struct pcg_state_setseq_16* rng, + uint16_t initstate, uint16_t initseq) +{ + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_16_step_r(rng); + rng->state += initstate; + pcg_setseq_16_step_r(rng); +} + +inline void pcg_oneseq_32_srandom_r(struct pcg_state_32* rng, + uint32_t initstate) +{ + rng->state = 0U; + pcg_oneseq_32_step_r(rng); + rng->state += initstate; + pcg_oneseq_32_step_r(rng); +} + +inline void pcg_mcg_32_srandom_r(struct pcg_state_32* rng, uint32_t initstate) +{ + rng->state = initstate | 1u; +} + +inline void pcg_unique_32_srandom_r(struct pcg_state_32* rng, + uint32_t initstate) +{ + rng->state = 0U; + pcg_unique_32_step_r(rng); + rng->state += initstate; + pcg_unique_32_step_r(rng); +} + +inline void pcg_setseq_32_srandom_r(struct pcg_state_setseq_32* rng, + uint32_t initstate, uint32_t initseq) +{ + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_32_step_r(rng); + rng->state += initstate; + pcg_setseq_32_step_r(rng); +} + +inline void pcg_oneseq_64_srandom_r(struct pcg_state_64* rng, + uint64_t initstate) +{ + rng->state = 0U; + pcg_oneseq_64_step_r(rng); + rng->state += initstate; + pcg_oneseq_64_step_r(rng); +} + +inline void pcg_mcg_64_srandom_r(struct pcg_state_64* rng, uint64_t initstate) +{ + rng->state = initstate | 1u; +} + +inline void pcg_unique_64_srandom_r(struct pcg_state_64* rng, + uint64_t initstate) +{ + rng->state = 0U; + pcg_unique_64_step_r(rng); + rng->state += initstate; + pcg_unique_64_step_r(rng); +} + +inline void pcg_setseq_64_srandom_r(struct pcg_state_setseq_64* rng, + uint64_t initstate, uint64_t initseq) +{ + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_64_step_r(rng); + rng->state += initstate; + pcg_setseq_64_step_r(rng); +} + +#if PCG_HAS_128BIT_OPS +inline void pcg_oneseq_128_srandom_r(struct pcg_state_128* rng, + pcg128_t initstate) +{ + rng->state = 0U; + pcg_oneseq_128_step_r(rng); + rng->state += initstate; + pcg_oneseq_128_step_r(rng); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_mcg_128_srandom_r(struct pcg_state_128* rng, pcg128_t initstate) +{ + rng->state = initstate | 1u; +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_unique_128_srandom_r(struct pcg_state_128* rng, + pcg128_t initstate) +{ + rng->state = 0U; + pcg_unique_128_step_r(rng); + rng->state += initstate; + pcg_unique_128_step_r(rng); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_setseq_128_srandom_r(struct pcg_state_setseq_128* rng, + pcg128_t initstate, pcg128_t initseq) +{ + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_128_step_r(rng); + rng->state += initstate; + pcg_setseq_128_step_r(rng); +} +#endif + +/* Now, finally we create each of the individual generators. We provide + * a random_r function that provides a random number of the appropriate + * type (using the full range of the type) and a boundedrand_r version + * that provides + * + * Implementation notes for boundedrand_r: + * + * To avoid bias, we need to make the range of the RNG a multiple of + * bound, which we do by dropping output less than a threshold. + * Let's consider a 32-bit case... A naive scheme to calculate the + * threshold would be to do + * + * uint32_t threshold = 0x100000000ull % bound; + * + * but 64-bit div/mod is slower than 32-bit div/mod (especially on + * 32-bit platforms). In essence, we do + * + * uint32_t threshold = (0x100000000ull-bound) % bound; + * + * because this version will calculate the same modulus, but the LHS + * value is less than 2^32. + * + * (Note that using modulo is only wise for good RNGs, poorer RNGs + * such as raw LCGs do better using a technique based on division.) + * Empricical tests show that division is preferable to modulus for + * reducting the range of an RNG. It's faster, and sometimes it can + * even be statistically prefereable. + */ + +/* Generation functions for XSH RS */ + +inline uint8_t pcg_oneseq_16_xsh_rs_8_random_r(struct pcg_state_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_oneseq_16_step_r(rng); + return pcg_output_xsh_rs_16_8(oldstate); +} + +inline uint8_t pcg_oneseq_16_xsh_rs_8_boundedrand_r(struct pcg_state_16* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_oneseq_16_xsh_rs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_oneseq_32_xsh_rs_16_random_r(struct pcg_state_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_oneseq_32_step_r(rng); + return pcg_output_xsh_rs_32_16(oldstate); +} + +inline uint16_t pcg_oneseq_32_xsh_rs_16_boundedrand_r(struct pcg_state_32* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_oneseq_32_xsh_rs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_oneseq_64_xsh_rs_32_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_xsh_rs_64_32(oldstate); +} + +inline uint32_t pcg_oneseq_64_xsh_rs_32_boundedrand_r(struct pcg_state_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_oneseq_64_xsh_rs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_oneseq_128_xsh_rs_64_random_r(struct pcg_state_128* rng) +{ + pcg_oneseq_128_step_r(rng); + return pcg_output_xsh_rs_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_oneseq_128_xsh_rs_64_boundedrand_r(struct pcg_state_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_128_xsh_rs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_unique_16_xsh_rs_8_random_r(struct pcg_state_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_unique_16_step_r(rng); + return pcg_output_xsh_rs_16_8(oldstate); +} + +inline uint8_t pcg_unique_16_xsh_rs_8_boundedrand_r(struct pcg_state_16* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_unique_16_xsh_rs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_unique_32_xsh_rs_16_random_r(struct pcg_state_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_unique_32_step_r(rng); + return pcg_output_xsh_rs_32_16(oldstate); +} + +inline uint16_t pcg_unique_32_xsh_rs_16_boundedrand_r(struct pcg_state_32* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_unique_32_xsh_rs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_unique_64_xsh_rs_32_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_xsh_rs_64_32(oldstate); +} + +inline uint32_t pcg_unique_64_xsh_rs_32_boundedrand_r(struct pcg_state_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_unique_64_xsh_rs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_unique_128_xsh_rs_64_random_r(struct pcg_state_128* rng) +{ + pcg_unique_128_step_r(rng); + return pcg_output_xsh_rs_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_unique_128_xsh_rs_64_boundedrand_r(struct pcg_state_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_128_xsh_rs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_setseq_16_xsh_rs_8_random_r(struct pcg_state_setseq_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_setseq_16_step_r(rng); + return pcg_output_xsh_rs_16_8(oldstate); +} + +inline uint8_t +pcg_setseq_16_xsh_rs_8_boundedrand_r(struct pcg_state_setseq_16* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_setseq_16_xsh_rs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t +pcg_setseq_32_xsh_rs_16_random_r(struct pcg_state_setseq_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_setseq_32_step_r(rng); + return pcg_output_xsh_rs_32_16(oldstate); +} + +inline uint16_t +pcg_setseq_32_xsh_rs_16_boundedrand_r(struct pcg_state_setseq_32* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_setseq_32_xsh_rs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t +pcg_setseq_64_xsh_rs_32_random_r(struct pcg_state_setseq_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_xsh_rs_64_32(oldstate); +} + +inline uint32_t +pcg_setseq_64_xsh_rs_32_boundedrand_r(struct pcg_state_setseq_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_setseq_64_xsh_rs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsh_rs_64_random_r(struct pcg_state_setseq_128* rng) +{ + pcg_setseq_128_step_r(rng); + return pcg_output_xsh_rs_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsh_rs_64_boundedrand_r(struct pcg_state_setseq_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_128_xsh_rs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_mcg_16_xsh_rs_8_random_r(struct pcg_state_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_mcg_16_step_r(rng); + return pcg_output_xsh_rs_16_8(oldstate); +} + +inline uint8_t pcg_mcg_16_xsh_rs_8_boundedrand_r(struct pcg_state_16* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_mcg_16_xsh_rs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_mcg_32_xsh_rs_16_random_r(struct pcg_state_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_mcg_32_step_r(rng); + return pcg_output_xsh_rs_32_16(oldstate); +} + +inline uint16_t pcg_mcg_32_xsh_rs_16_boundedrand_r(struct pcg_state_32* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_mcg_32_xsh_rs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_mcg_64_xsh_rs_32_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_mcg_64_step_r(rng); + return pcg_output_xsh_rs_64_32(oldstate); +} + +inline uint32_t pcg_mcg_64_xsh_rs_32_boundedrand_r(struct pcg_state_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_mcg_64_xsh_rs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsh_rs_64_random_r(struct pcg_state_128* rng) +{ + pcg_mcg_128_step_r(rng); + return pcg_output_xsh_rs_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsh_rs_64_boundedrand_r(struct pcg_state_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_mcg_128_xsh_rs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +/* Generation functions for XSH RR */ + +inline uint8_t pcg_oneseq_16_xsh_rr_8_random_r(struct pcg_state_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_oneseq_16_step_r(rng); + return pcg_output_xsh_rr_16_8(oldstate); +} + +inline uint8_t pcg_oneseq_16_xsh_rr_8_boundedrand_r(struct pcg_state_16* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_oneseq_16_xsh_rr_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_oneseq_32_xsh_rr_16_random_r(struct pcg_state_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_oneseq_32_step_r(rng); + return pcg_output_xsh_rr_32_16(oldstate); +} + +inline uint16_t pcg_oneseq_32_xsh_rr_16_boundedrand_r(struct pcg_state_32* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_oneseq_32_xsh_rr_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_oneseq_64_xsh_rr_32_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_xsh_rr_64_32(oldstate); +} + +inline uint32_t pcg_oneseq_64_xsh_rr_32_boundedrand_r(struct pcg_state_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_oneseq_64_xsh_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_oneseq_128_xsh_rr_64_random_r(struct pcg_state_128* rng) +{ + pcg_oneseq_128_step_r(rng); + return pcg_output_xsh_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_oneseq_128_xsh_rr_64_boundedrand_r(struct pcg_state_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_128_xsh_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_unique_16_xsh_rr_8_random_r(struct pcg_state_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_unique_16_step_r(rng); + return pcg_output_xsh_rr_16_8(oldstate); +} + +inline uint8_t pcg_unique_16_xsh_rr_8_boundedrand_r(struct pcg_state_16* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_unique_16_xsh_rr_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_unique_32_xsh_rr_16_random_r(struct pcg_state_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_unique_32_step_r(rng); + return pcg_output_xsh_rr_32_16(oldstate); +} + +inline uint16_t pcg_unique_32_xsh_rr_16_boundedrand_r(struct pcg_state_32* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_unique_32_xsh_rr_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_unique_64_xsh_rr_32_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_xsh_rr_64_32(oldstate); +} + +inline uint32_t pcg_unique_64_xsh_rr_32_boundedrand_r(struct pcg_state_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_unique_64_xsh_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_unique_128_xsh_rr_64_random_r(struct pcg_state_128* rng) +{ + pcg_unique_128_step_r(rng); + return pcg_output_xsh_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_unique_128_xsh_rr_64_boundedrand_r(struct pcg_state_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_128_xsh_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_setseq_16_xsh_rr_8_random_r(struct pcg_state_setseq_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_setseq_16_step_r(rng); + return pcg_output_xsh_rr_16_8(oldstate); +} + +inline uint8_t +pcg_setseq_16_xsh_rr_8_boundedrand_r(struct pcg_state_setseq_16* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_setseq_16_xsh_rr_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t +pcg_setseq_32_xsh_rr_16_random_r(struct pcg_state_setseq_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_setseq_32_step_r(rng); + return pcg_output_xsh_rr_32_16(oldstate); +} + +inline uint16_t +pcg_setseq_32_xsh_rr_16_boundedrand_r(struct pcg_state_setseq_32* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_setseq_32_xsh_rr_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t +pcg_setseq_64_xsh_rr_32_random_r(struct pcg_state_setseq_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_xsh_rr_64_32(oldstate); +} + +inline uint32_t +pcg_setseq_64_xsh_rr_32_boundedrand_r(struct pcg_state_setseq_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_setseq_64_xsh_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsh_rr_64_random_r(struct pcg_state_setseq_128* rng) +{ + pcg_setseq_128_step_r(rng); + return pcg_output_xsh_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsh_rr_64_boundedrand_r(struct pcg_state_setseq_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_128_xsh_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_mcg_16_xsh_rr_8_random_r(struct pcg_state_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_mcg_16_step_r(rng); + return pcg_output_xsh_rr_16_8(oldstate); +} + +inline uint8_t pcg_mcg_16_xsh_rr_8_boundedrand_r(struct pcg_state_16* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_mcg_16_xsh_rr_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_mcg_32_xsh_rr_16_random_r(struct pcg_state_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_mcg_32_step_r(rng); + return pcg_output_xsh_rr_32_16(oldstate); +} + +inline uint16_t pcg_mcg_32_xsh_rr_16_boundedrand_r(struct pcg_state_32* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_mcg_32_xsh_rr_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_mcg_64_xsh_rr_32_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_mcg_64_step_r(rng); + return pcg_output_xsh_rr_64_32(oldstate); +} + +inline uint32_t pcg_mcg_64_xsh_rr_32_boundedrand_r(struct pcg_state_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_mcg_64_xsh_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsh_rr_64_random_r(struct pcg_state_128* rng) +{ + pcg_mcg_128_step_r(rng); + return pcg_output_xsh_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsh_rr_64_boundedrand_r(struct pcg_state_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_mcg_128_xsh_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +/* Generation functions for RXS M XS (no MCG versions because they + * don't make sense when you want to use the entire state) + */ + +inline uint8_t pcg_oneseq_8_rxs_m_xs_8_random_r(struct pcg_state_8* rng) +{ + uint8_t oldstate = rng->state; + pcg_oneseq_8_step_r(rng); + return pcg_output_rxs_m_xs_8_8(oldstate); +} + +inline uint8_t pcg_oneseq_8_rxs_m_xs_8_boundedrand_r(struct pcg_state_8* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_oneseq_8_rxs_m_xs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_oneseq_16_rxs_m_xs_16_random_r(struct pcg_state_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_oneseq_16_step_r(rng); + return pcg_output_rxs_m_xs_16_16(oldstate); +} + +inline uint16_t +pcg_oneseq_16_rxs_m_xs_16_boundedrand_r(struct pcg_state_16* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_oneseq_16_rxs_m_xs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_oneseq_32_rxs_m_xs_32_random_r(struct pcg_state_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_oneseq_32_step_r(rng); + return pcg_output_rxs_m_xs_32_32(oldstate); +} + +inline uint32_t +pcg_oneseq_32_rxs_m_xs_32_boundedrand_r(struct pcg_state_32* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_oneseq_32_rxs_m_xs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint64_t pcg_oneseq_64_rxs_m_xs_64_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_rxs_m_xs_64_64(oldstate); +} + +inline uint64_t +pcg_oneseq_64_rxs_m_xs_64_boundedrand_r(struct pcg_state_64* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_64_rxs_m_xs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_oneseq_128_rxs_m_xs_128_random_r(struct pcg_state_128* rng) +{ + pcg_oneseq_128_step_r(rng); + return pcg_output_rxs_m_xs_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_oneseq_128_rxs_m_xs_128_boundedrand_r(struct pcg_state_128* rng, + pcg128_t bound) +{ + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_oneseq_128_rxs_m_xs_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint16_t pcg_unique_16_rxs_m_xs_16_random_r(struct pcg_state_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_unique_16_step_r(rng); + return pcg_output_rxs_m_xs_16_16(oldstate); +} + +inline uint16_t +pcg_unique_16_rxs_m_xs_16_boundedrand_r(struct pcg_state_16* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_unique_16_rxs_m_xs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_unique_32_rxs_m_xs_32_random_r(struct pcg_state_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_unique_32_step_r(rng); + return pcg_output_rxs_m_xs_32_32(oldstate); +} + +inline uint32_t +pcg_unique_32_rxs_m_xs_32_boundedrand_r(struct pcg_state_32* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_unique_32_rxs_m_xs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint64_t pcg_unique_64_rxs_m_xs_64_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_rxs_m_xs_64_64(oldstate); +} + +inline uint64_t +pcg_unique_64_rxs_m_xs_64_boundedrand_r(struct pcg_state_64* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_64_rxs_m_xs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_unique_128_rxs_m_xs_128_random_r(struct pcg_state_128* rng) +{ + pcg_unique_128_step_r(rng); + return pcg_output_rxs_m_xs_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_unique_128_rxs_m_xs_128_boundedrand_r(struct pcg_state_128* rng, + pcg128_t bound) +{ + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_unique_128_rxs_m_xs_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_setseq_8_rxs_m_xs_8_random_r(struct pcg_state_setseq_8* rng) +{ + uint8_t oldstate = rng->state; + pcg_setseq_8_step_r(rng); + return pcg_output_rxs_m_xs_8_8(oldstate); +} + +inline uint8_t +pcg_setseq_8_rxs_m_xs_8_boundedrand_r(struct pcg_state_setseq_8* rng, + uint8_t bound) +{ + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_setseq_8_rxs_m_xs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t +pcg_setseq_16_rxs_m_xs_16_random_r(struct pcg_state_setseq_16* rng) +{ + uint16_t oldstate = rng->state; + pcg_setseq_16_step_r(rng); + return pcg_output_rxs_m_xs_16_16(oldstate); +} + +inline uint16_t +pcg_setseq_16_rxs_m_xs_16_boundedrand_r(struct pcg_state_setseq_16* rng, + uint16_t bound) +{ + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_setseq_16_rxs_m_xs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t +pcg_setseq_32_rxs_m_xs_32_random_r(struct pcg_state_setseq_32* rng) +{ + uint32_t oldstate = rng->state; + pcg_setseq_32_step_r(rng); + return pcg_output_rxs_m_xs_32_32(oldstate); +} + +inline uint32_t +pcg_setseq_32_rxs_m_xs_32_boundedrand_r(struct pcg_state_setseq_32* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_setseq_32_rxs_m_xs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint64_t +pcg_setseq_64_rxs_m_xs_64_random_r(struct pcg_state_setseq_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_rxs_m_xs_64_64(oldstate); +} + +inline uint64_t +pcg_setseq_64_rxs_m_xs_64_boundedrand_r(struct pcg_state_setseq_64* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_64_rxs_m_xs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_setseq_128_rxs_m_xs_128_random_r(struct pcg_state_setseq_128* rng) +{ + pcg_setseq_128_step_r(rng); + return pcg_output_rxs_m_xs_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_setseq_128_rxs_m_xs_128_boundedrand_r(struct pcg_state_setseq_128* rng, + pcg128_t bound) +{ + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_setseq_128_rxs_m_xs_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +/* Generation functions for XSL RR (only defined for "large" types) */ + +inline uint32_t pcg_oneseq_64_xsl_rr_32_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_xsl_rr_64_32(oldstate); +} + +inline uint32_t pcg_oneseq_64_xsl_rr_32_boundedrand_r(struct pcg_state_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_oneseq_64_xsl_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_oneseq_128_xsl_rr_64_random_r(struct pcg_state_128* rng) +{ + pcg_oneseq_128_step_r(rng); + return pcg_output_xsl_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_oneseq_128_xsl_rr_64_boundedrand_r(struct pcg_state_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_128_xsl_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint32_t pcg_unique_64_xsl_rr_32_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_xsl_rr_64_32(oldstate); +} + +inline uint32_t pcg_unique_64_xsl_rr_32_boundedrand_r(struct pcg_state_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_unique_64_xsl_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_unique_128_xsl_rr_64_random_r(struct pcg_state_128* rng) +{ + pcg_unique_128_step_r(rng); + return pcg_output_xsl_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_unique_128_xsl_rr_64_boundedrand_r(struct pcg_state_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_128_xsl_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint32_t +pcg_setseq_64_xsl_rr_32_random_r(struct pcg_state_setseq_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_xsl_rr_64_32(oldstate); +} + +inline uint32_t +pcg_setseq_64_xsl_rr_32_boundedrand_r(struct pcg_state_setseq_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_setseq_64_xsl_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsl_rr_64_random_r(struct pcg_state_setseq_128* rng) +{ + pcg_setseq_128_step_r(rng); + return pcg_output_xsl_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsl_rr_64_boundedrand_r(struct pcg_state_setseq_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_128_xsl_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint32_t pcg_mcg_64_xsl_rr_32_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_mcg_64_step_r(rng); + return pcg_output_xsl_rr_64_32(oldstate); +} + +inline uint32_t pcg_mcg_64_xsl_rr_32_boundedrand_r(struct pcg_state_64* rng, + uint32_t bound) +{ + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_mcg_64_xsl_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsl_rr_64_random_r(struct pcg_state_128* rng) +{ + pcg_mcg_128_step_r(rng); + return pcg_output_xsl_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsl_rr_64_boundedrand_r(struct pcg_state_128* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_mcg_128_xsl_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +/* Generation functions for XSL RR RR (only defined for "large" types) */ + +inline uint64_t pcg_oneseq_64_xsl_rr_rr_64_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_xsl_rr_rr_64_64(oldstate); +} + +inline uint64_t +pcg_oneseq_64_xsl_rr_rr_64_boundedrand_r(struct pcg_state_64* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_64_xsl_rr_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_oneseq_128_xsl_rr_rr_128_random_r(struct pcg_state_128* rng) +{ + pcg_oneseq_128_step_r(rng); + return pcg_output_xsl_rr_rr_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_oneseq_128_xsl_rr_rr_128_boundedrand_r(struct pcg_state_128* rng, + pcg128_t bound) +{ + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_oneseq_128_xsl_rr_rr_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint64_t pcg_unique_64_xsl_rr_rr_64_random_r(struct pcg_state_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_xsl_rr_rr_64_64(oldstate); +} + +inline uint64_t +pcg_unique_64_xsl_rr_rr_64_boundedrand_r(struct pcg_state_64* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_64_xsl_rr_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_unique_128_xsl_rr_rr_128_random_r(struct pcg_state_128* rng) +{ + pcg_unique_128_step_r(rng); + return pcg_output_xsl_rr_rr_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_unique_128_xsl_rr_rr_128_boundedrand_r(struct pcg_state_128* rng, + pcg128_t bound) +{ + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_unique_128_xsl_rr_rr_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint64_t +pcg_setseq_64_xsl_rr_rr_64_random_r(struct pcg_state_setseq_64* rng) +{ + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_xsl_rr_rr_64_64(oldstate); +} + +inline uint64_t +pcg_setseq_64_xsl_rr_rr_64_boundedrand_r(struct pcg_state_setseq_64* rng, + uint64_t bound) +{ + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_64_xsl_rr_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_setseq_128_xsl_rr_rr_128_random_r(struct pcg_state_setseq_128* rng) +{ + pcg_setseq_128_step_r(rng); + return pcg_output_xsl_rr_rr_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_setseq_128_xsl_rr_rr_128_boundedrand_r(struct pcg_state_setseq_128* rng, + pcg128_t bound) +{ + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_setseq_128_xsl_rr_rr_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +//// Typedefs +typedef struct pcg_state_setseq_64 pcg32_random_t; +typedef struct pcg_state_64 pcg32s_random_t; +typedef struct pcg_state_64 pcg32u_random_t; +typedef struct pcg_state_64 pcg32f_random_t; +//// random_r +#define pcg32_random_r pcg_setseq_64_xsh_rr_32_random_r +#define pcg32s_random_r pcg_oneseq_64_xsh_rr_32_random_r +#define pcg32u_random_r pcg_unique_64_xsh_rr_32_random_r +#define pcg32f_random_r pcg_mcg_64_xsh_rs_32_random_r +//// boundedrand_r +#define pcg32_boundedrand_r pcg_setseq_64_xsh_rr_32_boundedrand_r +#define pcg32s_boundedrand_r pcg_oneseq_64_xsh_rr_32_boundedrand_r +#define pcg32u_boundedrand_r pcg_unique_64_xsh_rr_32_boundedrand_r +#define pcg32f_boundedrand_r pcg_mcg_64_xsh_rs_32_boundedrand_r +//// srandom_r +#define pcg32_srandom_r pcg_setseq_64_srandom_r +#define pcg32s_srandom_r pcg_oneseq_64_srandom_r +#define pcg32u_srandom_r pcg_unique_64_srandom_r +#define pcg32f_srandom_r pcg_mcg_64_srandom_r +//// advance_r +#define pcg32_advance_r pcg_setseq_64_advance_r +#define pcg32s_advance_r pcg_oneseq_64_advance_r +#define pcg32u_advance_r pcg_unique_64_advance_r +#define pcg32f_advance_r pcg_mcg_64_advance_r + +#if PCG_HAS_128BIT_OPS +//// Typedefs +typedef struct pcg_state_setseq_128 pcg64_random_t; +typedef struct pcg_state_128 pcg64s_random_t; +typedef struct pcg_state_128 pcg64u_random_t; +typedef struct pcg_state_128 pcg64f_random_t; +//// random_r +#define pcg64_random_r pcg_setseq_128_xsl_rr_64_random_r +#define pcg64s_random_r pcg_oneseq_128_xsl_rr_64_random_r +#define pcg64u_random_r pcg_unique_128_xsl_rr_64_random_r +#define pcg64f_random_r pcg_mcg_128_xsl_rr_64_random_r +//// boundedrand_r +#define pcg64_boundedrand_r pcg_setseq_128_xsl_rr_64_boundedrand_r +#define pcg64s_boundedrand_r pcg_oneseq_128_xsl_rr_64_boundedrand_r +#define pcg64u_boundedrand_r pcg_unique_128_xsl_rr_64_boundedrand_r +#define pcg64f_boundedrand_r pcg_mcg_128_xsl_rr_64_boundedrand_r +//// srandom_r +#define pcg64_srandom_r pcg_setseq_128_srandom_r +#define pcg64s_srandom_r pcg_oneseq_128_srandom_r +#define pcg64u_srandom_r pcg_unique_128_srandom_r +#define pcg64f_srandom_r pcg_mcg_128_srandom_r +//// advance_r +#define pcg64_advance_r pcg_setseq_128_advance_r +#define pcg64s_advance_r pcg_oneseq_128_advance_r +#define pcg64u_advance_r pcg_unique_128_advance_r +#define pcg64f_advance_r pcg_mcg_128_advance_r +#endif + +//// Typedefs +typedef struct pcg_state_8 pcg8si_random_t; +typedef struct pcg_state_16 pcg16si_random_t; +typedef struct pcg_state_32 pcg32si_random_t; +typedef struct pcg_state_64 pcg64si_random_t; +//// random_r +#define pcg8si_random_r pcg_oneseq_8_rxs_m_xs_8_random_r +#define pcg16si_random_r pcg_oneseq_16_rxs_m_xs_16_random_r +#define pcg32si_random_r pcg_oneseq_32_rxs_m_xs_32_random_r +#define pcg64si_random_r pcg_oneseq_64_rxs_m_xs_64_random_r +//// boundedrand_r +#define pcg8si_boundedrand_r pcg_oneseq_8_rxs_m_xs_8_boundedrand_r +#define pcg16si_boundedrand_r pcg_oneseq_16_rxs_m_xs_16_boundedrand_r +#define pcg32si_boundedrand_r pcg_oneseq_32_rxs_m_xs_32_boundedrand_r +#define pcg64si_boundedrand_r pcg_oneseq_64_rxs_m_xs_64_boundedrand_r +//// srandom_r +#define pcg8si_srandom_r pcg_oneseq_8_srandom_r +#define pcg16si_srandom_r pcg_oneseq_16_srandom_r +#define pcg32si_srandom_r pcg_oneseq_32_srandom_r +#define pcg64si_srandom_r pcg_oneseq_64_srandom_r +//// advance_r +#define pcg8si_advance_r pcg_oneseq_8_advance_r +#define pcg16si_advance_r pcg_oneseq_16_advance_r +#define pcg32si_advance_r pcg_oneseq_32_advance_r +#define pcg64si_advance_r pcg_oneseq_64_advance_r + +#if PCG_HAS_128BIT_OPS +typedef struct pcg_state_128 pcg128si_random_t; +#define pcg128si_random_r pcg_oneseq_128_rxs_m_xs_128_random_r +#define pcg128si_boundedrand_r pcg_oneseq_128_rxs_m_xs_128_boundedrand_r +#define pcg128si_srandom_r pcg_oneseq_128_srandom_r +#define pcg128si_advance_r pcg_oneseq_128_advance_r +#endif + +//// Typedefs +typedef struct pcg_state_setseq_8 pcg8i_random_t; +typedef struct pcg_state_setseq_16 pcg16i_random_t; +typedef struct pcg_state_setseq_32 pcg32i_random_t; +typedef struct pcg_state_setseq_64 pcg64i_random_t; +//// random_r +#define pcg8i_random_r pcg_setseq_8_rxs_m_xs_8_random_r +#define pcg16i_random_r pcg_setseq_16_rxs_m_xs_16_random_r +#define pcg32i_random_r pcg_setseq_32_rxs_m_xs_32_random_r +#define pcg64i_random_r pcg_setseq_64_rxs_m_xs_64_random_r +//// boundedrand_r +#define pcg8i_boundedrand_r pcg_setseq_8_rxs_m_xs_8_boundedrand_r +#define pcg16i_boundedrand_r pcg_setseq_16_rxs_m_xs_16_boundedrand_r +#define pcg32i_boundedrand_r pcg_setseq_32_rxs_m_xs_32_boundedrand_r +#define pcg64i_boundedrand_r pcg_setseq_64_rxs_m_xs_64_boundedrand_r +//// srandom_r +#define pcg8i_srandom_r pcg_setseq_8_srandom_r +#define pcg16i_srandom_r pcg_setseq_16_srandom_r +#define pcg32i_srandom_r pcg_setseq_32_srandom_r +#define pcg64i_srandom_r pcg_setseq_64_srandom_r +//// advance_r +#define pcg8i_advance_r pcg_setseq_8_advance_r +#define pcg16i_advance_r pcg_setseq_16_advance_r +#define pcg32i_advance_r pcg_setseq_32_advance_r +#define pcg64i_advance_r pcg_setseq_64_advance_r + +#if PCG_HAS_128BIT_OPS +typedef struct pcg_state_setseq_128 pcg128i_random_t; +#define pcg128i_random_r pcg_setseq_128_rxs_m_xs_128_random_r +#define pcg128i_boundedrand_r pcg_setseq_128_rxs_m_xs_128_boundedrand_r +#define pcg128i_srandom_r pcg_setseq_128_srandom_r +#define pcg128i_advance_r pcg_setseq_128_advance_r +#endif + +extern uint32_t pcg32_random(); +extern uint32_t pcg32_boundedrand(uint32_t bound); +extern void pcg32_srandom(uint64_t seed, uint64_t seq); +extern void pcg32_advance(uint64_t delta); + +#if PCG_HAS_128BIT_OPS +extern uint64_t pcg64_random(); +extern uint64_t pcg64_boundedrand(uint64_t bound); +extern void pcg64_srandom(pcg128_t seed, pcg128_t seq); +extern void pcg64_advance(pcg128_t delta); +#endif + +/* + * Static initialization constants (if you can't call srandom for some + * bizarre reason). + */ + +#define PCG32_INITIALIZER PCG_STATE_SETSEQ_64_INITIALIZER +#define PCG32U_INITIALIZER PCG_STATE_UNIQUE_64_INITIALIZER +#define PCG32S_INITIALIZER PCG_STATE_ONESEQ_64_INITIALIZER +#define PCG32F_INITIALIZER PCG_STATE_MCG_64_INITIALIZER + +#if PCG_HAS_128BIT_OPS +#define PCG64_INITIALIZER PCG_STATE_SETSEQ_128_INITIALIZER +#define PCG64U_INITIALIZER PCG_STATE_UNIQUE_128_INITIALIZER +#define PCG64S_INITIALIZER PCG_STATE_ONESEQ_128_INITIALIZER +#define PCG64F_INITIALIZER PCG_STATE_MCG_128_INITIALIZER +#endif + +#define PCG8SI_INITIALIZER PCG_STATE_ONESEQ_8_INITIALIZER +#define PCG16SI_INITIALIZER PCG_STATE_ONESEQ_16_INITIALIZER +#define PCG32SI_INITIALIZER PCG_STATE_ONESEQ_32_INITIALIZER +#define PCG64SI_INITIALIZER PCG_STATE_ONESEQ_64_INITIALIZER +#if PCG_HAS_128BIT_OPS +#define PCG128SI_INITIALIZER PCG_STATE_ONESEQ_128_INITIALIZER +#endif + +#define PCG8I_INITIALIZER PCG_STATE_SETSEQ_8_INITIALIZER +#define PCG16I_INITIALIZER PCG_STATE_SETSEQ_16_INITIALIZER +#define PCG32I_INITIALIZER PCG_STATE_SETSEQ_32_INITIALIZER +#define PCG64I_INITIALIZER PCG_STATE_SETSEQ_64_INITIALIZER +#if PCG_HAS_128BIT_OPS +#define PCG128I_INITIALIZER PCG_STATE_SETSEQ_128_INITIALIZER +#endif + +#if __cplusplus +} +#endif + +#endif // PCG_VARIANTS_H_INCLUDED diff --git a/numpy/random/src/pcg64/LICENSE.md b/numpy/random/src/pcg64/LICENSE.md new file mode 100644 index 000000000..7aac7a51c --- /dev/null +++ b/numpy/random/src/pcg64/LICENSE.md @@ -0,0 +1,22 @@ +# PCG64 + +## The MIT License + +PCG Random Number Generation for C. + +Copyright 2014 Melissa O'Neill <oneill@pcg-random.org> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/numpy/random/src/pcg64/pcg64-benchmark.c b/numpy/random/src/pcg64/pcg64-benchmark.c new file mode 100644 index 000000000..76f3ec78c --- /dev/null +++ b/numpy/random/src/pcg64/pcg64-benchmark.c @@ -0,0 +1,42 @@ +/* + * cl pcg64-benchmark.c pcg64.c ../splitmix64/splitmix64.c /Ox + * Measure-Command { .\xoroshiro128-benchmark.exe } + * + * gcc pcg64-benchmark.c pcg64.c ../splitmix64/splitmix64.c -O3 -o + * pcg64-benchmark + * time ./pcg64-benchmark + */ +#include "../splitmix64/splitmix64.h" +#include "pcg64.h" +#include <inttypes.h> +#include <stdio.h> +#include <time.h> + +#define N 1000000000 + +int main() { + pcg64_random_t rng; + uint64_t sum = 0, count = 0; + uint64_t seed = 0xDEADBEAF; + int i; +#if __SIZEOF_INT128__ && !defined(PCG_FORCE_EMULATED_128BIT_MATH) + rng.state = (__uint128_t)splitmix64_next(&seed) << 64; + rng.state |= splitmix64_next(&seed); + rng.inc = (__uint128_t)1; +#else + rng.state.high = splitmix64_next(&seed); + rng.state.low = splitmix64_next(&seed); + rng.inc.high = 0; + rng.inc.low = 1; +#endif + clock_t begin = clock(); + for (i = 0; i < N; i++) { + sum += pcg64_random_r(&rng); + count++; + } + clock_t end = clock(); + double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; + printf("0x%" PRIx64 "\ncount: %" PRIu64 "\n", sum, count); + printf("%" PRIu64 " randoms per second\n", + (uint64_t)(N / time_spent) / 1000000 * 1000000); +} diff --git a/numpy/random/src/pcg64/pcg64-test-data-gen.c b/numpy/random/src/pcg64/pcg64-test-data-gen.c new file mode 100644 index 000000000..0c2b079a3 --- /dev/null +++ b/numpy/random/src/pcg64/pcg64-test-data-gen.c @@ -0,0 +1,73 @@ +/* + * Generate testing csv files + * + * GCC only + * + * gcc pcg64-test-data-gen.c pcg64.orig.c ../splitmix64/splitmix64.c -o + * pgc64-test-data-gen + */ + +#include "pcg64.orig.h" +#include <inttypes.h> +#include <stdio.h> + +#define N 1000 + +int main() { + pcg64_random_t rng; + uint64_t state, seed = 0xDEADBEAF; + state = seed; + __uint128_t temp, s, inc; + int i; + uint64_t store[N]; + s = (__uint128_t)seed; + inc = (__uint128_t)0; + pcg64_srandom_r(&rng, s, inc); + printf("0x%" PRIx64, (uint64_t)(rng.state >> 64)); + printf("%" PRIx64 "\n", (uint64_t)rng.state); + printf("0x%" PRIx64, (uint64_t)(rng.inc >> 64)); + printf("%" PRIx64 "\n", (uint64_t)rng.inc); + for (i = 0; i < N; i++) { + store[i] = pcg64_random_r(&rng); + } + + FILE *fp; + fp = fopen("pcg64-testset-1.csv", "w"); + if (fp == NULL) { + printf("Couldn't open file\n"); + return -1; + } + fprintf(fp, "seed, 0x%" PRIx64 "\n", seed); + for (i = 0; i < N; i++) { + fprintf(fp, "%d, 0x%" PRIx64 "\n", i, store[i]); + if (i == 999) { + printf("%d, 0x%" PRIx64 "\n", i, store[i]); + } + } + fclose(fp); + + state = seed = 0; + s = (__uint128_t)seed; + i = (__uint128_t)0; + pcg64_srandom_r(&rng, s, i); + printf("0x%" PRIx64, (uint64_t)(rng.state >> 64)); + printf("%" PRIx64 "\n", (uint64_t)rng.state); + printf("0x%" PRIx64, (uint64_t)(rng.inc >> 64)); + printf("%" PRIx64 "\n", (uint64_t)rng.inc); + for (i = 0; i < N; i++) { + store[i] = pcg64_random_r(&rng); + } + fp = fopen("pcg64-testset-2.csv", "w"); + if (fp == NULL) { + printf("Couldn't open file\n"); + return -1; + } + fprintf(fp, "seed, 0x%" PRIx64 "\n", seed); + for (i = 0; i < N; i++) { + fprintf(fp, "%d, 0x%" PRIx64 "\n", i, store[i]); + if (i == 999) { + printf("%d, 0x%" PRIx64 "\n", i, store[i]); + } + } + fclose(fp); +} diff --git a/numpy/random/src/pcg64/pcg64.c b/numpy/random/src/pcg64/pcg64.c new file mode 100644 index 000000000..c89454029 --- /dev/null +++ b/numpy/random/src/pcg64/pcg64.c @@ -0,0 +1,185 @@ +/* + * PCG64 Random Number Generation for C. + * + * Copyright 2014 Melissa O'Neill <oneill@pcg-random.org> + * Copyright 2015 Robert Kern <robert.kern@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * For additional information about the PCG random number generation scheme, + * including its license and other licensing options, visit + * + * http://www.pcg-random.org + * + * Relicensed MIT in May 2019 + * + * The MIT License + * + * PCG Random Number Generation for C. + * + * Copyright 2014 Melissa O'Neill <oneill@pcg-random.org> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pcg64.h" + +extern inline void pcg_setseq_128_step_r(pcg_state_setseq_128 *rng); +extern inline uint64_t pcg_output_xsl_rr_128_64(pcg128_t state); +extern inline void pcg_setseq_128_srandom_r(pcg_state_setseq_128 *rng, + pcg128_t initstate, + pcg128_t initseq); +extern inline uint64_t +pcg_setseq_128_xsl_rr_64_random_r(pcg_state_setseq_128 *rng); +extern inline uint64_t +pcg_setseq_128_xsl_rr_64_boundedrand_r(pcg_state_setseq_128 *rng, + uint64_t bound); +extern inline void pcg_setseq_128_advance_r(pcg_state_setseq_128 *rng, + pcg128_t delta); + +/* Multi-step advance functions (jump-ahead, jump-back) + * + * The method used here is based on Brown, "Random Number Generation + * with Arbitrary Stride,", Transactions of the American Nuclear + * Society (Nov. 1994). The algorithm is very similar to fast + * exponentiation. + * + * Even though delta is an unsigned integer, we can pass a + * signed integer to go backwards, it just goes "the long way round". + */ + +#ifndef PCG_EMULATED_128BIT_MATH + +pcg128_t pcg_advance_lcg_128(pcg128_t state, pcg128_t delta, pcg128_t cur_mult, + pcg128_t cur_plus) { + pcg128_t acc_mult = 1u; + pcg128_t acc_plus = 0u; + while (delta > 0) { + if (delta & 1) { + acc_mult *= cur_mult; + acc_plus = acc_plus * cur_mult + cur_plus; + } + cur_plus = (cur_mult + 1) * cur_plus; + cur_mult *= cur_mult; + delta /= 2; + } + return acc_mult * state + acc_plus; +} + +#else + +pcg128_t pcg_advance_lcg_128(pcg128_t state, pcg128_t delta, pcg128_t cur_mult, + pcg128_t cur_plus) { + pcg128_t acc_mult = PCG_128BIT_CONSTANT(0u, 1u); + pcg128_t acc_plus = PCG_128BIT_CONSTANT(0u, 0u); + while ((delta.high > 0) || (delta.low > 0)) { + if (delta.low & 1) { + acc_mult = _pcg128_mult(acc_mult, cur_mult); + acc_plus = _pcg128_add(_pcg128_mult(acc_plus, cur_mult), cur_plus); + } + cur_plus = _pcg128_mult(_pcg128_add(cur_mult, PCG_128BIT_CONSTANT(0u, 1u)), + cur_plus); + cur_mult = _pcg128_mult(cur_mult, cur_mult); + delta.low >>= 1; + delta.low += delta.high & 1; + delta.high >>= 1; + } + return _pcg128_add(_pcg128_mult(acc_mult, state), acc_plus); +} + +#endif + +extern inline uint64_t pcg64_next64(pcg64_state *state); +extern inline uint32_t pcg64_next32(pcg64_state *state); + +extern void pcg64_advance(pcg64_state *state, uint64_t *step) { + pcg128_t delta; +#if __SIZEOF_INT128__ && !defined(PCG_FORCE_EMULATED_128BIT_MATH) + delta = (((pcg128_t)step[0]) << 64) | step[1]; +#else + delta.high = step[0]; + delta.low = step[1]; +#endif + pcg64_advance_r(state->pcg_state, delta); +} + +extern void pcg64_set_seed(pcg64_state *state, uint64_t *seed, uint64_t *inc) { + pcg128_t s, i; +#if __SIZEOF_INT128__ && !defined(PCG_FORCE_EMULATED_128BIT_MATH) + s = (((pcg128_t)seed[0]) << 64) | seed[1]; + i = (((pcg128_t)inc[0]) << 64) | inc[1]; +#else + s.high = seed[0]; + s.low = seed[1]; + i.high = inc[0]; + i.low = inc[1]; +#endif + pcg64_srandom_r(state->pcg_state, s, i); +} + +extern void pcg64_get_state(pcg64_state *state, uint64_t *state_arr, + int *has_uint32, uint32_t *uinteger) { + /* + * state_arr contains state.high, state.low, inc.high, inc.low + * which are interpreted as the upper 64 bits (high) or lower + * 64 bits of a uint128_t variable + * + */ +#if __SIZEOF_INT128__ && !defined(PCG_FORCE_EMULATED_128BIT_MATH) + state_arr[0] = (uint64_t)(state->pcg_state->state >> 64); + state_arr[1] = (uint64_t)(state->pcg_state->state & 0xFFFFFFFFFFFFFFFFULL); + state_arr[2] = (uint64_t)(state->pcg_state->inc >> 64); + state_arr[3] = (uint64_t)(state->pcg_state->inc & 0xFFFFFFFFFFFFFFFFULL); +#else + state_arr[0] = (uint64_t)state->pcg_state->state.high; + state_arr[1] = (uint64_t)state->pcg_state->state.low; + state_arr[2] = (uint64_t)state->pcg_state->inc.high; + state_arr[3] = (uint64_t)state->pcg_state->inc.low; +#endif + has_uint32[0] = state->has_uint32; + uinteger[0] = state->uinteger; +} + +extern void pcg64_set_state(pcg64_state *state, uint64_t *state_arr, + int has_uint32, uint32_t uinteger) { + /* + * state_arr contains state.high, state.low, inc.high, inc.low + * which are interpreted as the upper 64 bits (high) or lower + * 64 bits of a uint128_t variable + * + */ +#if __SIZEOF_INT128__ && !defined(PCG_FORCE_EMULATED_128BIT_MATH) + state->pcg_state->state = (((pcg128_t)state_arr[0]) << 64) | state_arr[1]; + state->pcg_state->inc = (((pcg128_t)state_arr[2]) << 64) | state_arr[3]; +#else + state->pcg_state->state.high = state_arr[0]; + state->pcg_state->state.low = state_arr[1]; + state->pcg_state->inc.high = state_arr[2]; + state->pcg_state->inc.low = state_arr[3]; +#endif + state->has_uint32 = has_uint32; + state->uinteger = uinteger; +} diff --git a/numpy/random/src/pcg64/pcg64.h b/numpy/random/src/pcg64/pcg64.h new file mode 100644 index 000000000..d4c96ff5f --- /dev/null +++ b/numpy/random/src/pcg64/pcg64.h @@ -0,0 +1,262 @@ +/* + * PCG64 Random Number Generation for C. + * + * Copyright 2014 Melissa O'Neill <oneill@pcg-random.org> + * Copyright 2015 Robert Kern <robert.kern@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * For additional information about the PCG random number generation scheme, + * including its license and other licensing options, visit + * + * http://www.pcg-random.org + * + * Relicensed MIT in May 2019 + * + * The MIT License + * + * PCG Random Number Generation for C. + * + * Copyright 2014 Melissa O'Neill <oneill@pcg-random.org> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef PCG64_H_INCLUDED +#define PCG64_H_INCLUDED 1 + +#include <inttypes.h> + +#ifdef _WIN32 +#define inline __forceinline +#endif + +#if __GNUC_GNU_INLINE__ && !defined(__cplusplus) +#error Nonstandard GNU inlining semantics. Compile with -std=c99 or better. +#endif + +#if __cplusplus +extern "C" { +#endif + +#if __SIZEOF_INT128__ && !defined(PCG_FORCE_EMULATED_128BIT_MATH) +typedef __uint128_t pcg128_t; +#define PCG_128BIT_CONSTANT(high, low) (((pcg128_t)(high) << 64) + low) +#else +typedef struct { + uint64_t high; + uint64_t low; +} pcg128_t; + +static inline pcg128_t PCG_128BIT_CONSTANT(uint64_t high, uint64_t low) { + pcg128_t result; + result.high = high; + result.low = low; + return result; +} + +#define PCG_EMULATED_128BIT_MATH 1 +#endif + +typedef struct { pcg128_t state; } pcg_state_128; + +typedef struct { + pcg128_t state; + pcg128_t inc; +} pcg_state_setseq_128; + +#define PCG_DEFAULT_MULTIPLIER_128 \ + PCG_128BIT_CONSTANT(2549297995355413924ULL, 4865540595714422341ULL) +#define PCG_DEFAULT_INCREMENT_128 \ + PCG_128BIT_CONSTANT(6364136223846793005ULL, 1442695040888963407ULL) +#define PCG_STATE_SETSEQ_128_INITIALIZER \ + { \ + PCG_128BIT_CONSTANT(0x979c9a98d8462005ULL, 0x7d3e9cb6cfe0549bULL) \ + , PCG_128BIT_CONSTANT(0x0000000000000001ULL, 0xda3e39cb94b95bdbULL) \ + } + +static inline uint64_t pcg_rotr_64(uint64_t value, unsigned int rot) { + return (value >> rot) | (value << ((-rot) & 63)); +} + +#ifdef PCG_EMULATED_128BIT_MATH + +static inline pcg128_t _pcg128_add(pcg128_t a, pcg128_t b) { + pcg128_t result; + + result.low = a.low + b.low; + result.high = a.high + b.high + (result.low < b.low); + return result; +} + +static inline void _pcg_mult64(uint64_t x, uint64_t y, uint64_t *z1, + uint64_t *z0) { + +#if defined _WIN32 && _MSC_VER >= 1900 && _M_AMD64 + z0[0] = _umul128(x, y, z1); +#else + uint64_t x0, x1, y0, y1; + uint64_t w0, w1, w2, t; + /* Lower 64 bits are straightforward clock-arithmetic. */ + *z0 = x * y; + + x0 = x & 0xFFFFFFFFULL; + x1 = x >> 32; + y0 = y & 0xFFFFFFFFULL; + y1 = y >> 32; + w0 = x0 * y0; + t = x1 * y0 + (w0 >> 32); + w1 = t & 0xFFFFFFFFULL; + w2 = t >> 32; + w1 += x0 * y1; + *z1 = x1 * y1 + w2 + (w1 >> 32); +#endif +} + +static inline pcg128_t _pcg128_mult(pcg128_t a, pcg128_t b) { + uint64_t h1; + pcg128_t result; + + h1 = a.high * b.low + a.low * b.high; + _pcg_mult64(a.low, b.low, &(result.high), &(result.low)); + result.high += h1; + return result; +} + +static inline void pcg_setseq_128_step_r(pcg_state_setseq_128 *rng) { + rng->state = _pcg128_add(_pcg128_mult(rng->state, PCG_DEFAULT_MULTIPLIER_128), + rng->inc); +} + +static inline uint64_t pcg_output_xsl_rr_128_64(pcg128_t state) { + return pcg_rotr_64(state.high ^ state.low, state.high >> 58u); +} + +static inline void pcg_setseq_128_srandom_r(pcg_state_setseq_128 *rng, + pcg128_t initstate, + pcg128_t initseq) { + rng->state = PCG_128BIT_CONSTANT(0ULL, 0ULL); + rng->inc.high = initseq.high << 1u; + rng->inc.high |= initseq.low & 0x800000000000ULL; + rng->inc.low = (initseq.low << 1u) | 1u; + pcg_setseq_128_step_r(rng); + rng->state = _pcg128_add(rng->state, initstate); + pcg_setseq_128_step_r(rng); +} + +#else /* PCG_EMULATED_128BIT_MATH */ + +static inline void pcg_setseq_128_step_r(pcg_state_setseq_128 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_128 + rng->inc; +} + +static inline uint64_t pcg_output_xsl_rr_128_64(pcg128_t state) { + return pcg_rotr_64(((uint64_t)(state >> 64u)) ^ (uint64_t)state, + state >> 122u); +} + +static inline void pcg_setseq_128_srandom_r(pcg_state_setseq_128 *rng, + pcg128_t initstate, + pcg128_t initseq) { + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_128_step_r(rng); + rng->state += initstate; + pcg_setseq_128_step_r(rng); +} + +#endif /* PCG_EMULATED_128BIT_MATH */ + +static inline uint64_t +pcg_setseq_128_xsl_rr_64_random_r(pcg_state_setseq_128 *rng) { + pcg_setseq_128_step_r(rng); + return pcg_output_xsl_rr_128_64(rng->state); +} + +static inline uint64_t +pcg_setseq_128_xsl_rr_64_boundedrand_r(pcg_state_setseq_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_128_xsl_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +extern pcg128_t pcg_advance_lcg_128(pcg128_t state, pcg128_t delta, + pcg128_t cur_mult, pcg128_t cur_plus); + +static inline void pcg_setseq_128_advance_r(pcg_state_setseq_128 *rng, + pcg128_t delta) { + rng->state = pcg_advance_lcg_128(rng->state, delta, + PCG_DEFAULT_MULTIPLIER_128, rng->inc); +} + +typedef pcg_state_setseq_128 pcg64_random_t; +#define pcg64_random_r pcg_setseq_128_xsl_rr_64_random_r +#define pcg64_boundedrand_r pcg_setseq_128_xsl_rr_64_boundedrand_r +#define pcg64_srandom_r pcg_setseq_128_srandom_r +#define pcg64_advance_r pcg_setseq_128_advance_r +#define PCG64_INITIALIZER PCG_STATE_SETSEQ_128_INITIALIZER + +#if __cplusplus +} +#endif + +typedef struct s_pcg64_state { + pcg64_random_t *pcg_state; + int has_uint32; + uint32_t uinteger; +} pcg64_state; + +static inline uint64_t pcg64_next64(pcg64_state *state) { + return pcg64_random_r(state->pcg_state); +} + +static inline uint32_t pcg64_next32(pcg64_state *state) { + uint64_t next; + if (state->has_uint32) { + state->has_uint32 = 0; + return state->uinteger; + } + next = pcg64_random_r(state->pcg_state); + state->has_uint32 = 1; + state->uinteger = (uint32_t)(next >> 32); + return (uint32_t)(next & 0xffffffff); +} + +void pcg64_advance(pcg64_state *state, uint64_t *step); + +void pcg64_set_seed(pcg64_state *state, uint64_t *seed, uint64_t *inc); + +void pcg64_get_state(pcg64_state *state, uint64_t *state_arr, int *has_uint32, + uint32_t *uinteger); + +void pcg64_set_state(pcg64_state *state, uint64_t *state_arr, int has_uint32, + uint32_t uinteger); + +#endif /* PCG64_H_INCLUDED */ diff --git a/numpy/random/src/pcg64/pcg64.orig.c b/numpy/random/src/pcg64/pcg64.orig.c new file mode 100644 index 000000000..07e97e4b6 --- /dev/null +++ b/numpy/random/src/pcg64/pcg64.orig.c @@ -0,0 +1,11 @@ +#include "pcg64.orig.h" + +extern inline void pcg_setseq_128_srandom_r(pcg64_random_t *rng, + pcg128_t initstate, + pcg128_t initseq); + +extern uint64_t pcg_rotr_64(uint64_t value, unsigned int rot); +extern inline uint64_t pcg_output_xsl_rr_128_64(pcg128_t state); +extern void pcg_setseq_128_step_r(struct pcg_state_setseq_128 *rng); +extern uint64_t +pcg_setseq_128_xsl_rr_64_random_r(struct pcg_state_setseq_128 *rng); diff --git a/numpy/random/src/pcg64/pcg64.orig.h b/numpy/random/src/pcg64/pcg64.orig.h new file mode 100644 index 000000000..74be91f31 --- /dev/null +++ b/numpy/random/src/pcg64/pcg64.orig.h @@ -0,0 +1,2025 @@ +/* + * PCG Random Number Generation for C. + * + * Copyright 2014 Melissa O'Neill <oneill@pcg-random.org> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * For additional information about the PCG random number generation scheme, + * including its license and other licensing options, visit + * + * http://www.pcg-random.org + */ + +/* + * This code is derived from the canonical C++ PCG implementation, which + * has many additional features and is preferable if you can use C++ in + * your project. + * + * Much of the derivation was performed mechanically. In particular, the + * output functions were generated by compiling the C++ output functions + * into LLVM bitcode and then transforming that using the LLVM C backend + * (from https://github.com/draperlaboratory/llvm-cbe), and then + * postprocessing and hand editing the output. + * + * Much of the remaining code was generated by C-preprocessor metaprogramming. + */ + +#ifndef PCG_VARIANTS_H_INCLUDED +#define PCG_VARIANTS_H_INCLUDED 1 + +#include <inttypes.h> + +#if __SIZEOF_INT128__ +typedef __uint128_t pcg128_t; +#define PCG_128BIT_CONSTANT(high, low) ((((pcg128_t)high) << 64) + low) +#define PCG_HAS_128BIT_OPS 1 +#endif + +#if __GNUC_GNU_INLINE__ && !defined(__cplusplus) +#error Nonstandard GNU inlining semantics. Compile with -std=c99 or better. +// We could instead use macros PCG_INLINE and PCG_EXTERN_INLINE +// but better to just reject ancient C code. +#endif + +#if __cplusplus +extern "C" { +#endif + +/* + * Rotate helper functions. + */ + +inline uint8_t pcg_rotr_8(uint8_t value, unsigned int rot) { +/* Unfortunately, clang is kinda pathetic when it comes to properly + * recognizing idiomatic rotate code, so for clang we actually provide + * assembler directives (enabled with PCG_USE_INLINE_ASM). Boo, hiss. + */ +#if PCG_USE_INLINE_ASM && __clang__ && (__x86_64__ || __i386__) + asm("rorb %%cl, %0" : "=r"(value) : "0"(value), "c"(rot)); + return value; +#else + return (value >> rot) | (value << ((-rot) & 7)); +#endif +} + +inline uint16_t pcg_rotr_16(uint16_t value, unsigned int rot) { +#if PCG_USE_INLINE_ASM && __clang__ && (__x86_64__ || __i386__) + asm("rorw %%cl, %0" : "=r"(value) : "0"(value), "c"(rot)); + return value; +#else + return (value >> rot) | (value << ((-rot) & 15)); +#endif +} + +inline uint32_t pcg_rotr_32(uint32_t value, unsigned int rot) { +#if PCG_USE_INLINE_ASM && __clang__ && (__x86_64__ || __i386__) + asm("rorl %%cl, %0" : "=r"(value) : "0"(value), "c"(rot)); + return value; +#else + return (value >> rot) | (value << ((-rot) & 31)); +#endif +} + +inline uint64_t pcg_rotr_64(uint64_t value, unsigned int rot) { +#if 0 && PCG_USE_INLINE_ASM && __clang__ && __x86_64__ + // For whatever reason, clang actually *does* generate rotq by + // itself, so we don't need this code. + asm ("rorq %%cl, %0" : "=r" (value) : "0" (value), "c" (rot)); + return value; +#else + return (value >> rot) | (value << ((-rot) & 63)); +#endif +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_rotr_128(pcg128_t value, unsigned int rot) { + return (value >> rot) | (value << ((-rot) & 127)); +} +#endif + +/* + * Output functions. These are the core of the PCG generation scheme. + */ + +// XSH RS + +inline uint8_t pcg_output_xsh_rs_16_8(uint16_t state) { + return (uint8_t)(((state >> 7u) ^ state) >> ((state >> 14u) + 3u)); +} + +inline uint16_t pcg_output_xsh_rs_32_16(uint32_t state) { + return (uint16_t)(((state >> 11u) ^ state) >> ((state >> 30u) + 11u)); +} + +inline uint32_t pcg_output_xsh_rs_64_32(uint64_t state) { + + return (uint32_t)(((state >> 22u) ^ state) >> ((state >> 61u) + 22u)); +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_output_xsh_rs_128_64(pcg128_t state) { + return (uint64_t)(((state >> 43u) ^ state) >> ((state >> 124u) + 45u)); +} +#endif + +// XSH RR + +inline uint8_t pcg_output_xsh_rr_16_8(uint16_t state) { + return pcg_rotr_8(((state >> 5u) ^ state) >> 5u, state >> 13u); +} + +inline uint16_t pcg_output_xsh_rr_32_16(uint32_t state) { + return pcg_rotr_16(((state >> 10u) ^ state) >> 12u, state >> 28u); +} + +inline uint32_t pcg_output_xsh_rr_64_32(uint64_t state) { + return pcg_rotr_32(((state >> 18u) ^ state) >> 27u, state >> 59u); +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_output_xsh_rr_128_64(pcg128_t state) { + return pcg_rotr_64(((state >> 29u) ^ state) >> 58u, state >> 122u); +} +#endif + +// RXS M XS + +inline uint8_t pcg_output_rxs_m_xs_8_8(uint8_t state) { + uint8_t word = ((state >> ((state >> 6u) + 2u)) ^ state) * 217u; + return (word >> 6u) ^ word; +} + +inline uint16_t pcg_output_rxs_m_xs_16_16(uint16_t state) { + uint16_t word = ((state >> ((state >> 13u) + 3u)) ^ state) * 62169u; + return (word >> 11u) ^ word; +} + +inline uint32_t pcg_output_rxs_m_xs_32_32(uint32_t state) { + uint32_t word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u; + return (word >> 22u) ^ word; +} + +inline uint64_t pcg_output_rxs_m_xs_64_64(uint64_t state) { + uint64_t word = + ((state >> ((state >> 59u) + 5u)) ^ state) * 12605985483714917081ull; + return (word >> 43u) ^ word; +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_output_rxs_m_xs_128_128(pcg128_t state) { + pcg128_t word = + ((state >> ((state >> 122u) + 6u)) ^ state) * + (PCG_128BIT_CONSTANT(17766728186571221404ULL, 12605985483714917081ULL)); + // 327738287884841127335028083622016905945 + return (word >> 86u) ^ word; +} +#endif + +// XSL RR (only defined for >= 64 bits) + +inline uint32_t pcg_output_xsl_rr_64_32(uint64_t state) { + return pcg_rotr_32(((uint32_t)(state >> 32u)) ^ (uint32_t)state, + state >> 59u); +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_output_xsl_rr_128_64(pcg128_t state) { + return pcg_rotr_64(((uint64_t)(state >> 64u)) ^ (uint64_t)state, + state >> 122u); +} +#endif + +// XSL RR RR (only defined for >= 64 bits) + +inline uint64_t pcg_output_xsl_rr_rr_64_64(uint64_t state) { + uint32_t rot1 = (uint32_t)(state >> 59u); + uint32_t high = (uint32_t)(state >> 32u); + uint32_t low = (uint32_t)state; + uint32_t xored = high ^ low; + uint32_t newlow = pcg_rotr_32(xored, rot1); + uint32_t newhigh = pcg_rotr_32(high, newlow & 31u); + return (((uint64_t)newhigh) << 32u) | newlow; +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t pcg_output_xsl_rr_rr_128_128(pcg128_t state) { + uint32_t rot1 = (uint32_t)(state >> 122u); + uint64_t high = (uint64_t)(state >> 64u); + uint64_t low = (uint64_t)state; + uint64_t xored = high ^ low; + uint64_t newlow = pcg_rotr_64(xored, rot1); + uint64_t newhigh = pcg_rotr_64(high, newlow & 63u); + return (((pcg128_t)newhigh) << 64u) | newlow; +} +#endif + +#define PCG_DEFAULT_MULTIPLIER_8 141U +#define PCG_DEFAULT_MULTIPLIER_16 12829U +#define PCG_DEFAULT_MULTIPLIER_32 747796405U +#define PCG_DEFAULT_MULTIPLIER_64 6364136223846793005ULL + +#define PCG_DEFAULT_INCREMENT_8 77U +#define PCG_DEFAULT_INCREMENT_16 47989U +#define PCG_DEFAULT_INCREMENT_32 2891336453U +#define PCG_DEFAULT_INCREMENT_64 1442695040888963407ULL + +#if PCG_HAS_128BIT_OPS +#define PCG_DEFAULT_MULTIPLIER_128 \ + PCG_128BIT_CONSTANT(2549297995355413924ULL, 4865540595714422341ULL) +#define PCG_DEFAULT_INCREMENT_128 \ + PCG_128BIT_CONSTANT(6364136223846793005ULL, 1442695040888963407ULL) +#endif + + /* + * Static initialization constants (if you can't call srandom for some + * bizarre reason). + */ + +#define PCG_STATE_ONESEQ_8_INITIALIZER \ + { 0xd7U } +#define PCG_STATE_ONESEQ_16_INITIALIZER \ + { 0x20dfU } +#define PCG_STATE_ONESEQ_32_INITIALIZER \ + { 0x46b56677U } +#define PCG_STATE_ONESEQ_64_INITIALIZER \ + { 0x4d595df4d0f33173ULL } +#if PCG_HAS_128BIT_OPS +#define PCG_STATE_ONESEQ_128_INITIALIZER \ + { PCG_128BIT_CONSTANT(0xb8dc10e158a92392ULL, 0x98046df007ec0a53ULL) } +#endif + +#define PCG_STATE_UNIQUE_8_INITIALIZER PCG_STATE_ONESEQ_8_INITIALIZER +#define PCG_STATE_UNIQUE_16_INITIALIZER PCG_STATE_ONESEQ_16_INITIALIZER +#define PCG_STATE_UNIQUE_32_INITIALIZER PCG_STATE_ONESEQ_32_INITIALIZER +#define PCG_STATE_UNIQUE_64_INITIALIZER PCG_STATE_ONESEQ_64_INITIALIZER +#if PCG_HAS_128BIT_OPS +#define PCG_STATE_UNIQUE_128_INITIALIZER PCG_STATE_ONESEQ_128_INITIALIZER +#endif + +#define PCG_STATE_MCG_8_INITIALIZER \ + { 0xe5U } +#define PCG_STATE_MCG_16_INITIALIZER \ + { 0xa5e5U } +#define PCG_STATE_MCG_32_INITIALIZER \ + { 0xd15ea5e5U } +#define PCG_STATE_MCG_64_INITIALIZER \ + { 0xcafef00dd15ea5e5ULL } +#if PCG_HAS_128BIT_OPS +#define PCG_STATE_MCG_128_INITIALIZER \ + { PCG_128BIT_CONSTANT(0x0000000000000000ULL, 0xcafef00dd15ea5e5ULL) } +#endif + +#define PCG_STATE_SETSEQ_8_INITIALIZER \ + { 0x9bU, 0xdbU } +#define PCG_STATE_SETSEQ_16_INITIALIZER \ + { 0xe39bU, 0x5bdbU } +#define PCG_STATE_SETSEQ_32_INITIALIZER \ + { 0xec02d89bU, 0x94b95bdbU } +#define PCG_STATE_SETSEQ_64_INITIALIZER \ + { 0x853c49e6748fea9bULL, 0xda3e39cb94b95bdbULL } +#if PCG_HAS_128BIT_OPS +#define PCG_STATE_SETSEQ_128_INITIALIZER \ + { \ + PCG_128BIT_CONSTANT(0x979c9a98d8462005ULL, 0x7d3e9cb6cfe0549bULL) \ + , PCG_128BIT_CONSTANT(0x0000000000000001ULL, 0xda3e39cb94b95bdbULL) \ + } +#endif + +/* Representations for the oneseq, mcg, and unique variants */ + +struct pcg_state_8 { + uint8_t state; +}; + +struct pcg_state_16 { + uint16_t state; +}; + +struct pcg_state_32 { + uint32_t state; +}; + +struct pcg_state_64 { + uint64_t state; +}; + +#if PCG_HAS_128BIT_OPS +struct pcg_state_128 { + pcg128_t state; +}; +#endif + +/* Representations setseq variants */ + +struct pcg_state_setseq_8 { + uint8_t state; + uint8_t inc; +}; + +struct pcg_state_setseq_16 { + uint16_t state; + uint16_t inc; +}; + +struct pcg_state_setseq_32 { + uint32_t state; + uint32_t inc; +}; + +struct pcg_state_setseq_64 { + uint64_t state; + uint64_t inc; +}; + +#if PCG_HAS_128BIT_OPS +struct pcg_state_setseq_128 { + pcg128_t state; + pcg128_t inc; +}; +#endif + +/* Multi-step advance functions (jump-ahead, jump-back) */ + +extern uint8_t pcg_advance_lcg_8(uint8_t state, uint8_t delta, uint8_t cur_mult, + uint8_t cur_plus); +extern uint16_t pcg_advance_lcg_16(uint16_t state, uint16_t delta, + uint16_t cur_mult, uint16_t cur_plus); +extern uint32_t pcg_advance_lcg_32(uint32_t state, uint32_t delta, + uint32_t cur_mult, uint32_t cur_plus); +extern uint64_t pcg_advance_lcg_64(uint64_t state, uint64_t delta, + uint64_t cur_mult, uint64_t cur_plus); + +#if PCG_HAS_128BIT_OPS +extern pcg128_t pcg_advance_lcg_128(pcg128_t state, pcg128_t delta, + pcg128_t cur_mult, pcg128_t cur_plus); +#endif + +/* Functions to advance the underlying LCG, one version for each size and + * each style. These functions are considered semi-private. There is rarely + * a good reason to call them directly. + */ + +inline void pcg_oneseq_8_step_r(struct pcg_state_8 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_8 + PCG_DEFAULT_INCREMENT_8; +} + +inline void pcg_oneseq_8_advance_r(struct pcg_state_8 *rng, uint8_t delta) { + rng->state = pcg_advance_lcg_8(rng->state, delta, PCG_DEFAULT_MULTIPLIER_8, + PCG_DEFAULT_INCREMENT_8); +} + +inline void pcg_mcg_8_step_r(struct pcg_state_8 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_8; +} + +inline void pcg_mcg_8_advance_r(struct pcg_state_8 *rng, uint8_t delta) { + rng->state = + pcg_advance_lcg_8(rng->state, delta, PCG_DEFAULT_MULTIPLIER_8, 0u); +} + +inline void pcg_unique_8_step_r(struct pcg_state_8 *rng) { + rng->state = + rng->state * PCG_DEFAULT_MULTIPLIER_8 + (uint8_t)(((intptr_t)rng) | 1u); +} + +inline void pcg_unique_8_advance_r(struct pcg_state_8 *rng, uint8_t delta) { + rng->state = pcg_advance_lcg_8(rng->state, delta, PCG_DEFAULT_MULTIPLIER_8, + (uint8_t)(((intptr_t)rng) | 1u)); +} + +inline void pcg_setseq_8_step_r(struct pcg_state_setseq_8 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_8 + rng->inc; +} + +inline void pcg_setseq_8_advance_r(struct pcg_state_setseq_8 *rng, + uint8_t delta) { + rng->state = + pcg_advance_lcg_8(rng->state, delta, PCG_DEFAULT_MULTIPLIER_8, rng->inc); +} + +inline void pcg_oneseq_16_step_r(struct pcg_state_16 *rng) { + rng->state = + rng->state * PCG_DEFAULT_MULTIPLIER_16 + PCG_DEFAULT_INCREMENT_16; +} + +inline void pcg_oneseq_16_advance_r(struct pcg_state_16 *rng, uint16_t delta) { + rng->state = pcg_advance_lcg_16(rng->state, delta, PCG_DEFAULT_MULTIPLIER_16, + PCG_DEFAULT_INCREMENT_16); +} + +inline void pcg_mcg_16_step_r(struct pcg_state_16 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_16; +} + +inline void pcg_mcg_16_advance_r(struct pcg_state_16 *rng, uint16_t delta) { + rng->state = + pcg_advance_lcg_16(rng->state, delta, PCG_DEFAULT_MULTIPLIER_16, 0u); +} + +inline void pcg_unique_16_step_r(struct pcg_state_16 *rng) { + rng->state = + rng->state * PCG_DEFAULT_MULTIPLIER_16 + (uint16_t)(((intptr_t)rng) | 1u); +} + +inline void pcg_unique_16_advance_r(struct pcg_state_16 *rng, uint16_t delta) { + rng->state = pcg_advance_lcg_16(rng->state, delta, PCG_DEFAULT_MULTIPLIER_16, + (uint16_t)(((intptr_t)rng) | 1u)); +} + +inline void pcg_setseq_16_step_r(struct pcg_state_setseq_16 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_16 + rng->inc; +} + +inline void pcg_setseq_16_advance_r(struct pcg_state_setseq_16 *rng, + uint16_t delta) { + rng->state = pcg_advance_lcg_16(rng->state, delta, PCG_DEFAULT_MULTIPLIER_16, + rng->inc); +} + +inline void pcg_oneseq_32_step_r(struct pcg_state_32 *rng) { + rng->state = + rng->state * PCG_DEFAULT_MULTIPLIER_32 + PCG_DEFAULT_INCREMENT_32; +} + +inline void pcg_oneseq_32_advance_r(struct pcg_state_32 *rng, uint32_t delta) { + rng->state = pcg_advance_lcg_32(rng->state, delta, PCG_DEFAULT_MULTIPLIER_32, + PCG_DEFAULT_INCREMENT_32); +} + +inline void pcg_mcg_32_step_r(struct pcg_state_32 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_32; +} + +inline void pcg_mcg_32_advance_r(struct pcg_state_32 *rng, uint32_t delta) { + rng->state = + pcg_advance_lcg_32(rng->state, delta, PCG_DEFAULT_MULTIPLIER_32, 0u); +} + +inline void pcg_unique_32_step_r(struct pcg_state_32 *rng) { + rng->state = + rng->state * PCG_DEFAULT_MULTIPLIER_32 + (uint32_t)(((intptr_t)rng) | 1u); +} + +inline void pcg_unique_32_advance_r(struct pcg_state_32 *rng, uint32_t delta) { + rng->state = pcg_advance_lcg_32(rng->state, delta, PCG_DEFAULT_MULTIPLIER_32, + (uint32_t)(((intptr_t)rng) | 1u)); +} + +inline void pcg_setseq_32_step_r(struct pcg_state_setseq_32 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_32 + rng->inc; +} + +inline void pcg_setseq_32_advance_r(struct pcg_state_setseq_32 *rng, + uint32_t delta) { + rng->state = pcg_advance_lcg_32(rng->state, delta, PCG_DEFAULT_MULTIPLIER_32, + rng->inc); +} + +inline void pcg_oneseq_64_step_r(struct pcg_state_64 *rng) { + rng->state = + rng->state * PCG_DEFAULT_MULTIPLIER_64 + PCG_DEFAULT_INCREMENT_64; +} + +inline void pcg_oneseq_64_advance_r(struct pcg_state_64 *rng, uint64_t delta) { + rng->state = pcg_advance_lcg_64(rng->state, delta, PCG_DEFAULT_MULTIPLIER_64, + PCG_DEFAULT_INCREMENT_64); +} + +inline void pcg_mcg_64_step_r(struct pcg_state_64 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_64; +} + +inline void pcg_mcg_64_advance_r(struct pcg_state_64 *rng, uint64_t delta) { + rng->state = + pcg_advance_lcg_64(rng->state, delta, PCG_DEFAULT_MULTIPLIER_64, 0u); +} + +inline void pcg_unique_64_step_r(struct pcg_state_64 *rng) { + rng->state = + rng->state * PCG_DEFAULT_MULTIPLIER_64 + (uint64_t)(((intptr_t)rng) | 1u); +} + +inline void pcg_unique_64_advance_r(struct pcg_state_64 *rng, uint64_t delta) { + rng->state = pcg_advance_lcg_64(rng->state, delta, PCG_DEFAULT_MULTIPLIER_64, + (uint64_t)(((intptr_t)rng) | 1u)); +} + +inline void pcg_setseq_64_step_r(struct pcg_state_setseq_64 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_64 + rng->inc; +} + +inline void pcg_setseq_64_advance_r(struct pcg_state_setseq_64 *rng, + uint64_t delta) { + rng->state = pcg_advance_lcg_64(rng->state, delta, PCG_DEFAULT_MULTIPLIER_64, + rng->inc); +} + +#if PCG_HAS_128BIT_OPS +inline void pcg_oneseq_128_step_r(struct pcg_state_128 *rng) { + rng->state = + rng->state * PCG_DEFAULT_MULTIPLIER_128 + PCG_DEFAULT_INCREMENT_128; +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_oneseq_128_advance_r(struct pcg_state_128 *rng, + pcg128_t delta) { + rng->state = pcg_advance_lcg_128( + rng->state, delta, PCG_DEFAULT_MULTIPLIER_128, PCG_DEFAULT_INCREMENT_128); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_mcg_128_step_r(struct pcg_state_128 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_128; +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_mcg_128_advance_r(struct pcg_state_128 *rng, pcg128_t delta) { + rng->state = + pcg_advance_lcg_128(rng->state, delta, PCG_DEFAULT_MULTIPLIER_128, 0u); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_unique_128_step_r(struct pcg_state_128 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_128 + + (pcg128_t)(((intptr_t)rng) | 1u); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_unique_128_advance_r(struct pcg_state_128 *rng, + pcg128_t delta) { + rng->state = + pcg_advance_lcg_128(rng->state, delta, PCG_DEFAULT_MULTIPLIER_128, + (pcg128_t)(((intptr_t)rng) | 1u)); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_setseq_128_step_r(struct pcg_state_setseq_128 *rng) { + rng->state = rng->state * PCG_DEFAULT_MULTIPLIER_128 + rng->inc; +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_setseq_128_advance_r(struct pcg_state_setseq_128 *rng, + pcg128_t delta) { + rng->state = pcg_advance_lcg_128(rng->state, delta, + PCG_DEFAULT_MULTIPLIER_128, rng->inc); +} +#endif + +/* Functions to seed the RNG state, one version for each size and each + * style. Unlike the step functions, regular users can and should call + * these functions. + */ + +inline void pcg_oneseq_8_srandom_r(struct pcg_state_8 *rng, uint8_t initstate) { + rng->state = 0U; + pcg_oneseq_8_step_r(rng); + rng->state += initstate; + pcg_oneseq_8_step_r(rng); +} + +inline void pcg_mcg_8_srandom_r(struct pcg_state_8 *rng, uint8_t initstate) { + rng->state = initstate | 1u; +} + +inline void pcg_unique_8_srandom_r(struct pcg_state_8 *rng, uint8_t initstate) { + rng->state = 0U; + pcg_unique_8_step_r(rng); + rng->state += initstate; + pcg_unique_8_step_r(rng); +} + +inline void pcg_setseq_8_srandom_r(struct pcg_state_setseq_8 *rng, + uint8_t initstate, uint8_t initseq) { + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_8_step_r(rng); + rng->state += initstate; + pcg_setseq_8_step_r(rng); +} + +inline void pcg_oneseq_16_srandom_r(struct pcg_state_16 *rng, + uint16_t initstate) { + rng->state = 0U; + pcg_oneseq_16_step_r(rng); + rng->state += initstate; + pcg_oneseq_16_step_r(rng); +} + +inline void pcg_mcg_16_srandom_r(struct pcg_state_16 *rng, uint16_t initstate) { + rng->state = initstate | 1u; +} + +inline void pcg_unique_16_srandom_r(struct pcg_state_16 *rng, + uint16_t initstate) { + rng->state = 0U; + pcg_unique_16_step_r(rng); + rng->state += initstate; + pcg_unique_16_step_r(rng); +} + +inline void pcg_setseq_16_srandom_r(struct pcg_state_setseq_16 *rng, + uint16_t initstate, uint16_t initseq) { + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_16_step_r(rng); + rng->state += initstate; + pcg_setseq_16_step_r(rng); +} + +inline void pcg_oneseq_32_srandom_r(struct pcg_state_32 *rng, + uint32_t initstate) { + rng->state = 0U; + pcg_oneseq_32_step_r(rng); + rng->state += initstate; + pcg_oneseq_32_step_r(rng); +} + +inline void pcg_mcg_32_srandom_r(struct pcg_state_32 *rng, uint32_t initstate) { + rng->state = initstate | 1u; +} + +inline void pcg_unique_32_srandom_r(struct pcg_state_32 *rng, + uint32_t initstate) { + rng->state = 0U; + pcg_unique_32_step_r(rng); + rng->state += initstate; + pcg_unique_32_step_r(rng); +} + +inline void pcg_setseq_32_srandom_r(struct pcg_state_setseq_32 *rng, + uint32_t initstate, uint32_t initseq) { + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_32_step_r(rng); + rng->state += initstate; + pcg_setseq_32_step_r(rng); +} + +inline void pcg_oneseq_64_srandom_r(struct pcg_state_64 *rng, + uint64_t initstate) { + rng->state = 0U; + pcg_oneseq_64_step_r(rng); + rng->state += initstate; + pcg_oneseq_64_step_r(rng); +} + +inline void pcg_mcg_64_srandom_r(struct pcg_state_64 *rng, uint64_t initstate) { + rng->state = initstate | 1u; +} + +inline void pcg_unique_64_srandom_r(struct pcg_state_64 *rng, + uint64_t initstate) { + rng->state = 0U; + pcg_unique_64_step_r(rng); + rng->state += initstate; + pcg_unique_64_step_r(rng); +} + +inline void pcg_setseq_64_srandom_r(struct pcg_state_setseq_64 *rng, + uint64_t initstate, uint64_t initseq) { + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_64_step_r(rng); + rng->state += initstate; + pcg_setseq_64_step_r(rng); +} + +#if PCG_HAS_128BIT_OPS +inline void pcg_oneseq_128_srandom_r(struct pcg_state_128 *rng, + pcg128_t initstate) { + rng->state = 0U; + pcg_oneseq_128_step_r(rng); + rng->state += initstate; + pcg_oneseq_128_step_r(rng); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_mcg_128_srandom_r(struct pcg_state_128 *rng, + pcg128_t initstate) { + rng->state = initstate | 1u; +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_unique_128_srandom_r(struct pcg_state_128 *rng, + pcg128_t initstate) { + rng->state = 0U; + pcg_unique_128_step_r(rng); + rng->state += initstate; + pcg_unique_128_step_r(rng); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline void pcg_setseq_128_srandom_r(struct pcg_state_setseq_128 *rng, + pcg128_t initstate, pcg128_t initseq) { + rng->state = 0U; + rng->inc = (initseq << 1u) | 1u; + pcg_setseq_128_step_r(rng); + rng->state += initstate; + pcg_setseq_128_step_r(rng); +} +#endif + +/* Now, finally we create each of the individual generators. We provide + * a random_r function that provides a random number of the appropriate + * type (using the full range of the type) and a boundedrand_r version + * that provides + * + * Implementation notes for boundedrand_r: + * + * To avoid bias, we need to make the range of the RNG a multiple of + * bound, which we do by dropping output less than a threshold. + * Let's consider a 32-bit case... A naive scheme to calculate the + * threshold would be to do + * + * uint32_t threshold = 0x100000000ull % bound; + * + * but 64-bit div/mod is slower than 32-bit div/mod (especially on + * 32-bit platforms). In essence, we do + * + * uint32_t threshold = (0x100000000ull-bound) % bound; + * + * because this version will calculate the same modulus, but the LHS + * value is less than 2^32. + * + * (Note that using modulo is only wise for good RNGs, poorer RNGs + * such as raw LCGs do better using a technique based on division.) + * Empricical tests show that division is preferable to modulus for + * reducting the range of an RNG. It's faster, and sometimes it can + * even be statistically prefereable. + */ + +/* Generation functions for XSH RS */ + +inline uint8_t pcg_oneseq_16_xsh_rs_8_random_r(struct pcg_state_16 *rng) { + uint16_t oldstate = rng->state; + pcg_oneseq_16_step_r(rng); + return pcg_output_xsh_rs_16_8(oldstate); +} + +inline uint8_t pcg_oneseq_16_xsh_rs_8_boundedrand_r(struct pcg_state_16 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_oneseq_16_xsh_rs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_oneseq_32_xsh_rs_16_random_r(struct pcg_state_32 *rng) { + uint32_t oldstate = rng->state; + pcg_oneseq_32_step_r(rng); + return pcg_output_xsh_rs_32_16(oldstate); +} + +inline uint16_t pcg_oneseq_32_xsh_rs_16_boundedrand_r(struct pcg_state_32 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_oneseq_32_xsh_rs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_oneseq_64_xsh_rs_32_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_xsh_rs_64_32(oldstate); +} + +inline uint32_t pcg_oneseq_64_xsh_rs_32_boundedrand_r(struct pcg_state_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_oneseq_64_xsh_rs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_oneseq_128_xsh_rs_64_random_r(struct pcg_state_128 *rng) { + pcg_oneseq_128_step_r(rng); + return pcg_output_xsh_rs_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_oneseq_128_xsh_rs_64_boundedrand_r(struct pcg_state_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_128_xsh_rs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_unique_16_xsh_rs_8_random_r(struct pcg_state_16 *rng) { + uint16_t oldstate = rng->state; + pcg_unique_16_step_r(rng); + return pcg_output_xsh_rs_16_8(oldstate); +} + +inline uint8_t pcg_unique_16_xsh_rs_8_boundedrand_r(struct pcg_state_16 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_unique_16_xsh_rs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_unique_32_xsh_rs_16_random_r(struct pcg_state_32 *rng) { + uint32_t oldstate = rng->state; + pcg_unique_32_step_r(rng); + return pcg_output_xsh_rs_32_16(oldstate); +} + +inline uint16_t pcg_unique_32_xsh_rs_16_boundedrand_r(struct pcg_state_32 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_unique_32_xsh_rs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_unique_64_xsh_rs_32_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_xsh_rs_64_32(oldstate); +} + +inline uint32_t pcg_unique_64_xsh_rs_32_boundedrand_r(struct pcg_state_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_unique_64_xsh_rs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_unique_128_xsh_rs_64_random_r(struct pcg_state_128 *rng) { + pcg_unique_128_step_r(rng); + return pcg_output_xsh_rs_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_unique_128_xsh_rs_64_boundedrand_r(struct pcg_state_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_128_xsh_rs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t +pcg_setseq_16_xsh_rs_8_random_r(struct pcg_state_setseq_16 *rng) { + uint16_t oldstate = rng->state; + pcg_setseq_16_step_r(rng); + return pcg_output_xsh_rs_16_8(oldstate); +} + +inline uint8_t +pcg_setseq_16_xsh_rs_8_boundedrand_r(struct pcg_state_setseq_16 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_setseq_16_xsh_rs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t +pcg_setseq_32_xsh_rs_16_random_r(struct pcg_state_setseq_32 *rng) { + uint32_t oldstate = rng->state; + pcg_setseq_32_step_r(rng); + return pcg_output_xsh_rs_32_16(oldstate); +} + +inline uint16_t +pcg_setseq_32_xsh_rs_16_boundedrand_r(struct pcg_state_setseq_32 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_setseq_32_xsh_rs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t +pcg_setseq_64_xsh_rs_32_random_r(struct pcg_state_setseq_64 *rng) { + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_xsh_rs_64_32(oldstate); +} + +inline uint32_t +pcg_setseq_64_xsh_rs_32_boundedrand_r(struct pcg_state_setseq_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_setseq_64_xsh_rs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsh_rs_64_random_r(struct pcg_state_setseq_128 *rng) { + pcg_setseq_128_step_r(rng); + return pcg_output_xsh_rs_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsh_rs_64_boundedrand_r(struct pcg_state_setseq_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_128_xsh_rs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_mcg_16_xsh_rs_8_random_r(struct pcg_state_16 *rng) { + uint16_t oldstate = rng->state; + pcg_mcg_16_step_r(rng); + return pcg_output_xsh_rs_16_8(oldstate); +} + +inline uint8_t pcg_mcg_16_xsh_rs_8_boundedrand_r(struct pcg_state_16 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_mcg_16_xsh_rs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_mcg_32_xsh_rs_16_random_r(struct pcg_state_32 *rng) { + uint32_t oldstate = rng->state; + pcg_mcg_32_step_r(rng); + return pcg_output_xsh_rs_32_16(oldstate); +} + +inline uint16_t pcg_mcg_32_xsh_rs_16_boundedrand_r(struct pcg_state_32 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_mcg_32_xsh_rs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_mcg_64_xsh_rs_32_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_mcg_64_step_r(rng); + return pcg_output_xsh_rs_64_32(oldstate); +} + +inline uint32_t pcg_mcg_64_xsh_rs_32_boundedrand_r(struct pcg_state_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_mcg_64_xsh_rs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsh_rs_64_random_r(struct pcg_state_128 *rng) { + pcg_mcg_128_step_r(rng); + return pcg_output_xsh_rs_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsh_rs_64_boundedrand_r(struct pcg_state_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_mcg_128_xsh_rs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +/* Generation functions for XSH RR */ + +inline uint8_t pcg_oneseq_16_xsh_rr_8_random_r(struct pcg_state_16 *rng) { + uint16_t oldstate = rng->state; + pcg_oneseq_16_step_r(rng); + return pcg_output_xsh_rr_16_8(oldstate); +} + +inline uint8_t pcg_oneseq_16_xsh_rr_8_boundedrand_r(struct pcg_state_16 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_oneseq_16_xsh_rr_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_oneseq_32_xsh_rr_16_random_r(struct pcg_state_32 *rng) { + uint32_t oldstate = rng->state; + pcg_oneseq_32_step_r(rng); + return pcg_output_xsh_rr_32_16(oldstate); +} + +inline uint16_t pcg_oneseq_32_xsh_rr_16_boundedrand_r(struct pcg_state_32 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_oneseq_32_xsh_rr_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_oneseq_64_xsh_rr_32_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_xsh_rr_64_32(oldstate); +} + +inline uint32_t pcg_oneseq_64_xsh_rr_32_boundedrand_r(struct pcg_state_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_oneseq_64_xsh_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_oneseq_128_xsh_rr_64_random_r(struct pcg_state_128 *rng) { + pcg_oneseq_128_step_r(rng); + return pcg_output_xsh_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_oneseq_128_xsh_rr_64_boundedrand_r(struct pcg_state_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_128_xsh_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_unique_16_xsh_rr_8_random_r(struct pcg_state_16 *rng) { + uint16_t oldstate = rng->state; + pcg_unique_16_step_r(rng); + return pcg_output_xsh_rr_16_8(oldstate); +} + +inline uint8_t pcg_unique_16_xsh_rr_8_boundedrand_r(struct pcg_state_16 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_unique_16_xsh_rr_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_unique_32_xsh_rr_16_random_r(struct pcg_state_32 *rng) { + uint32_t oldstate = rng->state; + pcg_unique_32_step_r(rng); + return pcg_output_xsh_rr_32_16(oldstate); +} + +inline uint16_t pcg_unique_32_xsh_rr_16_boundedrand_r(struct pcg_state_32 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_unique_32_xsh_rr_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_unique_64_xsh_rr_32_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_xsh_rr_64_32(oldstate); +} + +inline uint32_t pcg_unique_64_xsh_rr_32_boundedrand_r(struct pcg_state_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_unique_64_xsh_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_unique_128_xsh_rr_64_random_r(struct pcg_state_128 *rng) { + pcg_unique_128_step_r(rng); + return pcg_output_xsh_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_unique_128_xsh_rr_64_boundedrand_r(struct pcg_state_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_128_xsh_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t +pcg_setseq_16_xsh_rr_8_random_r(struct pcg_state_setseq_16 *rng) { + uint16_t oldstate = rng->state; + pcg_setseq_16_step_r(rng); + return pcg_output_xsh_rr_16_8(oldstate); +} + +inline uint8_t +pcg_setseq_16_xsh_rr_8_boundedrand_r(struct pcg_state_setseq_16 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_setseq_16_xsh_rr_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t +pcg_setseq_32_xsh_rr_16_random_r(struct pcg_state_setseq_32 *rng) { + uint32_t oldstate = rng->state; + pcg_setseq_32_step_r(rng); + return pcg_output_xsh_rr_32_16(oldstate); +} + +inline uint16_t +pcg_setseq_32_xsh_rr_16_boundedrand_r(struct pcg_state_setseq_32 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_setseq_32_xsh_rr_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t +pcg_setseq_64_xsh_rr_32_random_r(struct pcg_state_setseq_64 *rng) { + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_xsh_rr_64_32(oldstate); +} + +inline uint32_t +pcg_setseq_64_xsh_rr_32_boundedrand_r(struct pcg_state_setseq_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_setseq_64_xsh_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsh_rr_64_random_r(struct pcg_state_setseq_128 *rng) { + pcg_setseq_128_step_r(rng); + return pcg_output_xsh_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsh_rr_64_boundedrand_r(struct pcg_state_setseq_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_128_xsh_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t pcg_mcg_16_xsh_rr_8_random_r(struct pcg_state_16 *rng) { + uint16_t oldstate = rng->state; + pcg_mcg_16_step_r(rng); + return pcg_output_xsh_rr_16_8(oldstate); +} + +inline uint8_t pcg_mcg_16_xsh_rr_8_boundedrand_r(struct pcg_state_16 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_mcg_16_xsh_rr_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_mcg_32_xsh_rr_16_random_r(struct pcg_state_32 *rng) { + uint32_t oldstate = rng->state; + pcg_mcg_32_step_r(rng); + return pcg_output_xsh_rr_32_16(oldstate); +} + +inline uint16_t pcg_mcg_32_xsh_rr_16_boundedrand_r(struct pcg_state_32 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_mcg_32_xsh_rr_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_mcg_64_xsh_rr_32_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_mcg_64_step_r(rng); + return pcg_output_xsh_rr_64_32(oldstate); +} + +inline uint32_t pcg_mcg_64_xsh_rr_32_boundedrand_r(struct pcg_state_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_mcg_64_xsh_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsh_rr_64_random_r(struct pcg_state_128 *rng) { + pcg_mcg_128_step_r(rng); + return pcg_output_xsh_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsh_rr_64_boundedrand_r(struct pcg_state_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_mcg_128_xsh_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +/* Generation functions for RXS M XS (no MCG versions because they + * don't make sense when you want to use the entire state) + */ + +inline uint8_t pcg_oneseq_8_rxs_m_xs_8_random_r(struct pcg_state_8 *rng) { + uint8_t oldstate = rng->state; + pcg_oneseq_8_step_r(rng); + return pcg_output_rxs_m_xs_8_8(oldstate); +} + +inline uint8_t pcg_oneseq_8_rxs_m_xs_8_boundedrand_r(struct pcg_state_8 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_oneseq_8_rxs_m_xs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t pcg_oneseq_16_rxs_m_xs_16_random_r(struct pcg_state_16 *rng) { + uint16_t oldstate = rng->state; + pcg_oneseq_16_step_r(rng); + return pcg_output_rxs_m_xs_16_16(oldstate); +} + +inline uint16_t +pcg_oneseq_16_rxs_m_xs_16_boundedrand_r(struct pcg_state_16 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_oneseq_16_rxs_m_xs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_oneseq_32_rxs_m_xs_32_random_r(struct pcg_state_32 *rng) { + uint32_t oldstate = rng->state; + pcg_oneseq_32_step_r(rng); + return pcg_output_rxs_m_xs_32_32(oldstate); +} + +inline uint32_t +pcg_oneseq_32_rxs_m_xs_32_boundedrand_r(struct pcg_state_32 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_oneseq_32_rxs_m_xs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint64_t pcg_oneseq_64_rxs_m_xs_64_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_rxs_m_xs_64_64(oldstate); +} + +inline uint64_t +pcg_oneseq_64_rxs_m_xs_64_boundedrand_r(struct pcg_state_64 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_64_rxs_m_xs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_oneseq_128_rxs_m_xs_128_random_r(struct pcg_state_128 *rng) { + pcg_oneseq_128_step_r(rng); + return pcg_output_rxs_m_xs_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_oneseq_128_rxs_m_xs_128_boundedrand_r(struct pcg_state_128 *rng, + pcg128_t bound) { + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_oneseq_128_rxs_m_xs_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint16_t pcg_unique_16_rxs_m_xs_16_random_r(struct pcg_state_16 *rng) { + uint16_t oldstate = rng->state; + pcg_unique_16_step_r(rng); + return pcg_output_rxs_m_xs_16_16(oldstate); +} + +inline uint16_t +pcg_unique_16_rxs_m_xs_16_boundedrand_r(struct pcg_state_16 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_unique_16_rxs_m_xs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t pcg_unique_32_rxs_m_xs_32_random_r(struct pcg_state_32 *rng) { + uint32_t oldstate = rng->state; + pcg_unique_32_step_r(rng); + return pcg_output_rxs_m_xs_32_32(oldstate); +} + +inline uint32_t +pcg_unique_32_rxs_m_xs_32_boundedrand_r(struct pcg_state_32 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_unique_32_rxs_m_xs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint64_t pcg_unique_64_rxs_m_xs_64_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_rxs_m_xs_64_64(oldstate); +} + +inline uint64_t +pcg_unique_64_rxs_m_xs_64_boundedrand_r(struct pcg_state_64 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_64_rxs_m_xs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_unique_128_rxs_m_xs_128_random_r(struct pcg_state_128 *rng) { + pcg_unique_128_step_r(rng); + return pcg_output_rxs_m_xs_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_unique_128_rxs_m_xs_128_boundedrand_r(struct pcg_state_128 *rng, + pcg128_t bound) { + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_unique_128_rxs_m_xs_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint8_t +pcg_setseq_8_rxs_m_xs_8_random_r(struct pcg_state_setseq_8 *rng) { + uint8_t oldstate = rng->state; + pcg_setseq_8_step_r(rng); + return pcg_output_rxs_m_xs_8_8(oldstate); +} + +inline uint8_t +pcg_setseq_8_rxs_m_xs_8_boundedrand_r(struct pcg_state_setseq_8 *rng, + uint8_t bound) { + uint8_t threshold = ((uint8_t)(-bound)) % bound; + for (;;) { + uint8_t r = pcg_setseq_8_rxs_m_xs_8_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint16_t +pcg_setseq_16_rxs_m_xs_16_random_r(struct pcg_state_setseq_16 *rng) { + uint16_t oldstate = rng->state; + pcg_setseq_16_step_r(rng); + return pcg_output_rxs_m_xs_16_16(oldstate); +} + +inline uint16_t +pcg_setseq_16_rxs_m_xs_16_boundedrand_r(struct pcg_state_setseq_16 *rng, + uint16_t bound) { + uint16_t threshold = ((uint16_t)(-bound)) % bound; + for (;;) { + uint16_t r = pcg_setseq_16_rxs_m_xs_16_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint32_t +pcg_setseq_32_rxs_m_xs_32_random_r(struct pcg_state_setseq_32 *rng) { + uint32_t oldstate = rng->state; + pcg_setseq_32_step_r(rng); + return pcg_output_rxs_m_xs_32_32(oldstate); +} + +inline uint32_t +pcg_setseq_32_rxs_m_xs_32_boundedrand_r(struct pcg_state_setseq_32 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_setseq_32_rxs_m_xs_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +inline uint64_t +pcg_setseq_64_rxs_m_xs_64_random_r(struct pcg_state_setseq_64 *rng) { + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_rxs_m_xs_64_64(oldstate); +} + +inline uint64_t +pcg_setseq_64_rxs_m_xs_64_boundedrand_r(struct pcg_state_setseq_64 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_64_rxs_m_xs_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_setseq_128_rxs_m_xs_128_random_r(struct pcg_state_setseq_128 *rng) { + pcg_setseq_128_step_r(rng); + return pcg_output_rxs_m_xs_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_setseq_128_rxs_m_xs_128_boundedrand_r(struct pcg_state_setseq_128 *rng, + pcg128_t bound) { + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_setseq_128_rxs_m_xs_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +/* Generation functions for XSL RR (only defined for "large" types) */ + +inline uint32_t pcg_oneseq_64_xsl_rr_32_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_xsl_rr_64_32(oldstate); +} + +inline uint32_t pcg_oneseq_64_xsl_rr_32_boundedrand_r(struct pcg_state_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_oneseq_64_xsl_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_oneseq_128_xsl_rr_64_random_r(struct pcg_state_128 *rng) { + pcg_oneseq_128_step_r(rng); + return pcg_output_xsl_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_oneseq_128_xsl_rr_64_boundedrand_r(struct pcg_state_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_128_xsl_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint32_t pcg_unique_64_xsl_rr_32_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_xsl_rr_64_32(oldstate); +} + +inline uint32_t pcg_unique_64_xsl_rr_32_boundedrand_r(struct pcg_state_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_unique_64_xsl_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_unique_128_xsl_rr_64_random_r(struct pcg_state_128 *rng) { + pcg_unique_128_step_r(rng); + return pcg_output_xsl_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_unique_128_xsl_rr_64_boundedrand_r(struct pcg_state_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_128_xsl_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint32_t +pcg_setseq_64_xsl_rr_32_random_r(struct pcg_state_setseq_64 *rng) { + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_xsl_rr_64_32(oldstate); +} + +inline uint32_t +pcg_setseq_64_xsl_rr_32_boundedrand_r(struct pcg_state_setseq_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_setseq_64_xsl_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsl_rr_64_random_r(struct pcg_state_setseq_128 *rng) { + pcg_setseq_128_step_r(rng); + return pcg_output_xsl_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t +pcg_setseq_128_xsl_rr_64_boundedrand_r(struct pcg_state_setseq_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_128_xsl_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint32_t pcg_mcg_64_xsl_rr_32_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_mcg_64_step_r(rng); + return pcg_output_xsl_rr_64_32(oldstate); +} + +inline uint32_t pcg_mcg_64_xsl_rr_32_boundedrand_r(struct pcg_state_64 *rng, + uint32_t bound) { + uint32_t threshold = -bound % bound; + for (;;) { + uint32_t r = pcg_mcg_64_xsl_rr_32_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsl_rr_64_random_r(struct pcg_state_128 *rng) { + pcg_mcg_128_step_r(rng); + return pcg_output_xsl_rr_128_64(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline uint64_t pcg_mcg_128_xsl_rr_64_boundedrand_r(struct pcg_state_128 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_mcg_128_xsl_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +/* Generation functions for XSL RR RR (only defined for "large" types) */ + +inline uint64_t pcg_oneseq_64_xsl_rr_rr_64_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_oneseq_64_step_r(rng); + return pcg_output_xsl_rr_rr_64_64(oldstate); +} + +inline uint64_t +pcg_oneseq_64_xsl_rr_rr_64_boundedrand_r(struct pcg_state_64 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_oneseq_64_xsl_rr_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_oneseq_128_xsl_rr_rr_128_random_r(struct pcg_state_128 *rng) { + pcg_oneseq_128_step_r(rng); + return pcg_output_xsl_rr_rr_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_oneseq_128_xsl_rr_rr_128_boundedrand_r(struct pcg_state_128 *rng, + pcg128_t bound) { + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_oneseq_128_xsl_rr_rr_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint64_t pcg_unique_64_xsl_rr_rr_64_random_r(struct pcg_state_64 *rng) { + uint64_t oldstate = rng->state; + pcg_unique_64_step_r(rng); + return pcg_output_xsl_rr_rr_64_64(oldstate); +} + +inline uint64_t +pcg_unique_64_xsl_rr_rr_64_boundedrand_r(struct pcg_state_64 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_unique_64_xsl_rr_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_unique_128_xsl_rr_rr_128_random_r(struct pcg_state_128 *rng) { + pcg_unique_128_step_r(rng); + return pcg_output_xsl_rr_rr_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_unique_128_xsl_rr_rr_128_boundedrand_r(struct pcg_state_128 *rng, + pcg128_t bound) { + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_unique_128_xsl_rr_rr_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +inline uint64_t +pcg_setseq_64_xsl_rr_rr_64_random_r(struct pcg_state_setseq_64 *rng) { + uint64_t oldstate = rng->state; + pcg_setseq_64_step_r(rng); + return pcg_output_xsl_rr_rr_64_64(oldstate); +} + +inline uint64_t +pcg_setseq_64_xsl_rr_rr_64_boundedrand_r(struct pcg_state_setseq_64 *rng, + uint64_t bound) { + uint64_t threshold = -bound % bound; + for (;;) { + uint64_t r = pcg_setseq_64_xsl_rr_rr_64_random_r(rng); + if (r >= threshold) + return r % bound; + } +} + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_setseq_128_xsl_rr_rr_128_random_r(struct pcg_state_setseq_128 *rng) { + pcg_setseq_128_step_r(rng); + return pcg_output_xsl_rr_rr_128_128(rng->state); +} +#endif + +#if PCG_HAS_128BIT_OPS +inline pcg128_t +pcg_setseq_128_xsl_rr_rr_128_boundedrand_r(struct pcg_state_setseq_128 *rng, + pcg128_t bound) { + pcg128_t threshold = -bound % bound; + for (;;) { + pcg128_t r = pcg_setseq_128_xsl_rr_rr_128_random_r(rng); + if (r >= threshold) + return r % bound; + } +} +#endif + +//// Typedefs +typedef struct pcg_state_setseq_64 pcg32_random_t; +typedef struct pcg_state_64 pcg32s_random_t; +typedef struct pcg_state_64 pcg32u_random_t; +typedef struct pcg_state_64 pcg32f_random_t; +//// random_r +#define pcg32_random_r pcg_setseq_64_xsh_rr_32_random_r +#define pcg32s_random_r pcg_oneseq_64_xsh_rr_32_random_r +#define pcg32u_random_r pcg_unique_64_xsh_rr_32_random_r +#define pcg32f_random_r pcg_mcg_64_xsh_rs_32_random_r +//// boundedrand_r +#define pcg32_boundedrand_r pcg_setseq_64_xsh_rr_32_boundedrand_r +#define pcg32s_boundedrand_r pcg_oneseq_64_xsh_rr_32_boundedrand_r +#define pcg32u_boundedrand_r pcg_unique_64_xsh_rr_32_boundedrand_r +#define pcg32f_boundedrand_r pcg_mcg_64_xsh_rs_32_boundedrand_r +//// srandom_r +#define pcg32_srandom_r pcg_setseq_64_srandom_r +#define pcg32s_srandom_r pcg_oneseq_64_srandom_r +#define pcg32u_srandom_r pcg_unique_64_srandom_r +#define pcg32f_srandom_r pcg_mcg_64_srandom_r +//// advance_r +#define pcg32_advance_r pcg_setseq_64_advance_r +#define pcg32s_advance_r pcg_oneseq_64_advance_r +#define pcg32u_advance_r pcg_unique_64_advance_r +#define pcg32f_advance_r pcg_mcg_64_advance_r + +#if PCG_HAS_128BIT_OPS +//// Typedefs +typedef struct pcg_state_setseq_128 pcg64_random_t; +typedef struct pcg_state_128 pcg64s_random_t; +typedef struct pcg_state_128 pcg64u_random_t; +typedef struct pcg_state_128 pcg64f_random_t; +//// random_r +#define pcg64_random_r pcg_setseq_128_xsl_rr_64_random_r +#define pcg64s_random_r pcg_oneseq_128_xsl_rr_64_random_r +#define pcg64u_random_r pcg_unique_128_xsl_rr_64_random_r +#define pcg64f_random_r pcg_mcg_128_xsl_rr_64_random_r +//// boundedrand_r +#define pcg64_boundedrand_r pcg_setseq_128_xsl_rr_64_boundedrand_r +#define pcg64s_boundedrand_r pcg_oneseq_128_xsl_rr_64_boundedrand_r +#define pcg64u_boundedrand_r pcg_unique_128_xsl_rr_64_boundedrand_r +#define pcg64f_boundedrand_r pcg_mcg_128_xsl_rr_64_boundedrand_r +//// srandom_r +#define pcg64_srandom_r pcg_setseq_128_srandom_r +#define pcg64s_srandom_r pcg_oneseq_128_srandom_r +#define pcg64u_srandom_r pcg_unique_128_srandom_r +#define pcg64f_srandom_r pcg_mcg_128_srandom_r +//// advance_r +#define pcg64_advance_r pcg_setseq_128_advance_r +#define pcg64s_advance_r pcg_oneseq_128_advance_r +#define pcg64u_advance_r pcg_unique_128_advance_r +#define pcg64f_advance_r pcg_mcg_128_advance_r +#endif + +//// Typedefs +typedef struct pcg_state_8 pcg8si_random_t; +typedef struct pcg_state_16 pcg16si_random_t; +typedef struct pcg_state_32 pcg32si_random_t; +typedef struct pcg_state_64 pcg64si_random_t; +//// random_r +#define pcg8si_random_r pcg_oneseq_8_rxs_m_xs_8_random_r +#define pcg16si_random_r pcg_oneseq_16_rxs_m_xs_16_random_r +#define pcg32si_random_r pcg_oneseq_32_rxs_m_xs_32_random_r +#define pcg64si_random_r pcg_oneseq_64_rxs_m_xs_64_random_r +//// boundedrand_r +#define pcg8si_boundedrand_r pcg_oneseq_8_rxs_m_xs_8_boundedrand_r +#define pcg16si_boundedrand_r pcg_oneseq_16_rxs_m_xs_16_boundedrand_r +#define pcg32si_boundedrand_r pcg_oneseq_32_rxs_m_xs_32_boundedrand_r +#define pcg64si_boundedrand_r pcg_oneseq_64_rxs_m_xs_64_boundedrand_r +//// srandom_r +#define pcg8si_srandom_r pcg_oneseq_8_srandom_r +#define pcg16si_srandom_r pcg_oneseq_16_srandom_r +#define pcg32si_srandom_r pcg_oneseq_32_srandom_r +#define pcg64si_srandom_r pcg_oneseq_64_srandom_r +//// advance_r +#define pcg8si_advance_r pcg_oneseq_8_advance_r +#define pcg16si_advance_r pcg_oneseq_16_advance_r +#define pcg32si_advance_r pcg_oneseq_32_advance_r +#define pcg64si_advance_r pcg_oneseq_64_advance_r + +#if PCG_HAS_128BIT_OPS +typedef struct pcg_state_128 pcg128si_random_t; +#define pcg128si_random_r pcg_oneseq_128_rxs_m_xs_128_random_r +#define pcg128si_boundedrand_r pcg_oneseq_128_rxs_m_xs_128_boundedrand_r +#define pcg128si_srandom_r pcg_oneseq_128_srandom_r +#define pcg128si_advance_r pcg_oneseq_128_advance_r +#endif + +//// Typedefs +typedef struct pcg_state_setseq_8 pcg8i_random_t; +typedef struct pcg_state_setseq_16 pcg16i_random_t; +typedef struct pcg_state_setseq_32 pcg32i_random_t; +typedef struct pcg_state_setseq_64 pcg64i_random_t; +//// random_r +#define pcg8i_random_r pcg_setseq_8_rxs_m_xs_8_random_r +#define pcg16i_random_r pcg_setseq_16_rxs_m_xs_16_random_r +#define pcg32i_random_r pcg_setseq_32_rxs_m_xs_32_random_r +#define pcg64i_random_r pcg_setseq_64_rxs_m_xs_64_random_r +//// boundedrand_r +#define pcg8i_boundedrand_r pcg_setseq_8_rxs_m_xs_8_boundedrand_r +#define pcg16i_boundedrand_r pcg_setseq_16_rxs_m_xs_16_boundedrand_r +#define pcg32i_boundedrand_r pcg_setseq_32_rxs_m_xs_32_boundedrand_r +#define pcg64i_boundedrand_r pcg_setseq_64_rxs_m_xs_64_boundedrand_r +//// srandom_r +#define pcg8i_srandom_r pcg_setseq_8_srandom_r +#define pcg16i_srandom_r pcg_setseq_16_srandom_r +#define pcg32i_srandom_r pcg_setseq_32_srandom_r +#define pcg64i_srandom_r pcg_setseq_64_srandom_r +//// advance_r +#define pcg8i_advance_r pcg_setseq_8_advance_r +#define pcg16i_advance_r pcg_setseq_16_advance_r +#define pcg32i_advance_r pcg_setseq_32_advance_r +#define pcg64i_advance_r pcg_setseq_64_advance_r + +#if PCG_HAS_128BIT_OPS +typedef struct pcg_state_setseq_128 pcg128i_random_t; +#define pcg128i_random_r pcg_setseq_128_rxs_m_xs_128_random_r +#define pcg128i_boundedrand_r pcg_setseq_128_rxs_m_xs_128_boundedrand_r +#define pcg128i_srandom_r pcg_setseq_128_srandom_r +#define pcg128i_advance_r pcg_setseq_128_advance_r +#endif + +extern uint32_t pcg32_random(); +extern uint32_t pcg32_boundedrand(uint32_t bound); +extern void pcg32_srandom(uint64_t seed, uint64_t seq); +extern void pcg32_advance(uint64_t delta); + +#if PCG_HAS_128BIT_OPS +extern uint64_t pcg64_random(); +extern uint64_t pcg64_boundedrand(uint64_t bound); +extern void pcg64_srandom(pcg128_t seed, pcg128_t seq); +extern void pcg64_advance(pcg128_t delta); +#endif + +/* + * Static initialization constants (if you can't call srandom for some + * bizarre reason). + */ + +#define PCG32_INITIALIZER PCG_STATE_SETSEQ_64_INITIALIZER +#define PCG32U_INITIALIZER PCG_STATE_UNIQUE_64_INITIALIZER +#define PCG32S_INITIALIZER PCG_STATE_ONESEQ_64_INITIALIZER +#define PCG32F_INITIALIZER PCG_STATE_MCG_64_INITIALIZER + +#if PCG_HAS_128BIT_OPS +#define PCG64_INITIALIZER PCG_STATE_SETSEQ_128_INITIALIZER +#define PCG64U_INITIALIZER PCG_STATE_UNIQUE_128_INITIALIZER +#define PCG64S_INITIALIZER PCG_STATE_ONESEQ_128_INITIALIZER +#define PCG64F_INITIALIZER PCG_STATE_MCG_128_INITIALIZER +#endif + +#define PCG8SI_INITIALIZER PCG_STATE_ONESEQ_8_INITIALIZER +#define PCG16SI_INITIALIZER PCG_STATE_ONESEQ_16_INITIALIZER +#define PCG32SI_INITIALIZER PCG_STATE_ONESEQ_32_INITIALIZER +#define PCG64SI_INITIALIZER PCG_STATE_ONESEQ_64_INITIALIZER +#if PCG_HAS_128BIT_OPS +#define PCG128SI_INITIALIZER PCG_STATE_ONESEQ_128_INITIALIZER +#endif + +#define PCG8I_INITIALIZER PCG_STATE_SETSEQ_8_INITIALIZER +#define PCG16I_INITIALIZER PCG_STATE_SETSEQ_16_INITIALIZER +#define PCG32I_INITIALIZER PCG_STATE_SETSEQ_32_INITIALIZER +#define PCG64I_INITIALIZER PCG_STATE_SETSEQ_64_INITIALIZER +#if PCG_HAS_128BIT_OPS +#define PCG128I_INITIALIZER PCG_STATE_SETSEQ_128_INITIALIZER +#endif + +#if __cplusplus +} +#endif + +#endif // PCG_VARIANTS_H_INCLUDED diff --git a/numpy/random/tests/data/pcg32-testset-1.csv b/numpy/random/tests/data/pcg32-testset-1.csv new file mode 100644 index 000000000..6bddc8d5c --- /dev/null +++ b/numpy/random/tests/data/pcg32-testset-1.csv @@ -0,0 +1,1001 @@ +seed, 0xdeadbeaf +0, 0xbeb77374 +1, 0x75cad014 +2, 0xabc6773e +3, 0xe99a034e +4, 0x1e3f5c6d +5, 0x513d3c5b +6, 0x4a378bad +7, 0xba5b3488 +8, 0x21e96448 +9, 0x5197a3d3 +10, 0x84bbcc90 +11, 0x674fce76 +12, 0xd1dd9879 +13, 0x1625afd4 +14, 0x4bb5e330 +15, 0x3f4b8f74 +16, 0xf0a7c00b +17, 0xecdb92d0 +18, 0xf069232c +19, 0x56dbeaa2 +20, 0x70c62231 +21, 0x6c68e57e +22, 0x3829213c +23, 0x9b8bc5e6 +24, 0x45abd553 +25, 0xf5991ce7 +26, 0xb4aff20a +27, 0x677a5785 +28, 0x108f180d +29, 0x2b3f1001 +30, 0x838fdfcb +31, 0x8ad3c2a0 +32, 0x596268fa +33, 0xee6bcc56 +34, 0x46810af0 +35, 0x1648a587 +36, 0x7265a926 +37, 0xed0f3acc +38, 0x72a1ac0 +39, 0xb3f7109f +40, 0x6ddd75f2 +41, 0xa968127f +42, 0x40df20fd +43, 0xde835b80 +44, 0xe453cd68 +45, 0x26ad68eb +46, 0x23a052d2 +47, 0x17881c5c +48, 0x785d41b9 +49, 0x61b4530a +50, 0x5ee92c84 +51, 0x4cad7358 +52, 0x843db584 +53, 0x3576368b +54, 0x14db6b2b +55, 0xb6e8b042 +56, 0x6323e866 +57, 0x9a709e25 +58, 0xae594bdc +59, 0x4be9ec1b +60, 0x77b4fd05 +61, 0x4421667 +62, 0x24bf98f7 +63, 0xfb202aed +64, 0x2f01b05f +65, 0xac766e69 +66, 0xc1572ce2 +67, 0xb26354d6 +68, 0x4db5f193 +69, 0x41a4609b +70, 0x26bbb4cc +71, 0x676b7438 +72, 0x13b2be7d +73, 0x7df521c4 +74, 0x57f770f3 +75, 0x78a8a8 +76, 0x164d46c6 +77, 0xbb29da20 +78, 0x5c262bf9 +79, 0xfd305d0 +80, 0xb500d90b +81, 0xbb7b4e37 +82, 0x5ba2bbfd +83, 0xa9561043 +84, 0xe175c662 +85, 0x3a5c8eec +86, 0xac5e2184 +87, 0x1e1c7de7 +88, 0x46be092a +89, 0x8b82f5be +90, 0xb1c1b591 +91, 0x6f06d957 +92, 0x1d26dc5c +93, 0x158c57e3 +94, 0x6da1ebf8 +95, 0x74501e60 +96, 0x70587043 +97, 0xa19b90fe +98, 0x7d327dff +99, 0x22dc6b90 +100, 0xf48a9ae6 +101, 0x75eeb769 +102, 0x9cdc12cb +103, 0x7fe2cdc6 +104, 0x4fba8066 +105, 0x1a7a0667 +106, 0xd9289d22 +107, 0x3a045bce +108, 0x60e5f71f +109, 0xd81b35dc +110, 0xceae6194 +111, 0xa032a688 +112, 0x7157b327 +113, 0x61c74c80 +114, 0x2d519c39 +115, 0x5b1a352e +116, 0x5ad266da +117, 0x9118352b +118, 0xdd20b6e1 +119, 0xc0d154fa +120, 0x93bbb9c9 +121, 0x91170de2 +122, 0xa3af5e05 +123, 0x1b19ff2f +124, 0xf814c3bf +125, 0x8914a953 +126, 0x5278efb7 +127, 0x3c96d7bd +128, 0xb5422a7 +129, 0x2aee2619 +130, 0x60c6a90c +131, 0xfbec0e9c +132, 0xef794075 +133, 0xda93d22e +134, 0xb956d02a +135, 0xd97cc49b +136, 0x80737244 +137, 0x7c56a95 +138, 0xa5311355 +139, 0x7dcdd592 +140, 0x92add23e +141, 0xb1ba1317 +142, 0x507e5330 +143, 0x2644b95a +144, 0xa1afa519 +145, 0x596c65c0 +146, 0x6f47dd11 +147, 0xfd2fbada +148, 0x98675d7c +149, 0xb9e21413 +150, 0x8bae5eca +151, 0xe1f50018 +152, 0x7dd08715 +153, 0x36a888e1 +154, 0x7fcd6364 +155, 0xb84c093 +156, 0x18e2d58f +157, 0x19fd21ed +158, 0x3c25e3a3 +159, 0x7a0d833b +160, 0x47525b28 +161, 0xba88474 +162, 0xd108e7da +163, 0x32b06660 +164, 0xbce027b3 +165, 0x96b31787 +166, 0x916ab263 +167, 0xa5fa088 +168, 0x3cb9cd59 +169, 0x7a97051f +170, 0x104b6883 +171, 0x6e08c314 +172, 0x33a4c62c +173, 0x14eb854 +174, 0x873f730a +175, 0x8c3f7224 +176, 0x9a41beeb +177, 0xe4e2ab0a +178, 0xfa89ad0e +179, 0x4aa62ac3 +180, 0xb75dc1bf +181, 0x3f4c5131 +182, 0x3fef0f91 +183, 0xffa06655 +184, 0x417d7d38 +185, 0x1e7734df +186, 0x25685235 +187, 0x33fe5b68 +188, 0x68923f72 +189, 0x5da45ff +190, 0xb871df26 +191, 0xd3ffd8c6 +192, 0x1718d862 +193, 0xe127d844 +194, 0xadcdc48a +195, 0x79ee30cb +196, 0x931a6cba +197, 0x9463c42d +198, 0x9f8d2806 +199, 0xa3695a97 +200, 0xfc9587bc +201, 0xb3943573 +202, 0x50ed8901 +203, 0x6891f33 +204, 0xb7a12dfb +205, 0x1245cf5d +206, 0xbc0f73a7 +207, 0x26cbfeb2 +208, 0x774d8e83 +209, 0xa19e9c1 +210, 0xc147a437 +211, 0xe034f2a3 +212, 0xd288b664 +213, 0xdcd0356d +214, 0x2b695901 +215, 0x3bc31736 +216, 0x4a5b1998 +217, 0x18537410 +218, 0x11b40f35 +219, 0xf16f6f89 +220, 0xe844cffe +221, 0xce026166 +222, 0x3770aaba +223, 0xc62566ee +224, 0x6db2d1f8 +225, 0xe4720b6d +226, 0x68321a69 +227, 0x488539ac +228, 0x5e18ab61 +229, 0xb58e598e +230, 0x6f501a91 +231, 0xc4fd3e8d +232, 0x9faa3631 +233, 0x184366b0 +234, 0xecf74d6a +235, 0x3773d622 +236, 0x382ca536 +237, 0x93451381 +238, 0x9f148ed5 +239, 0x2b66f241 +240, 0xa6807c39 +241, 0xbb087446 +242, 0xa18ba432 +243, 0x8e7a6013 +244, 0xab30278e +245, 0xbf457c78 +246, 0xb24814b1 +247, 0x710f99d5 +248, 0xbcb84762 +249, 0x4913a7e7 +250, 0x90a31a0c +251, 0x6d4b1673 +252, 0x18873994 +253, 0x1efd517a +254, 0x99b499d1 +255, 0x2d488776 +256, 0x1cded201 +257, 0xa53b02e4 +258, 0xcb20d0fd +259, 0x72bfaae3 +260, 0x858c865b +261, 0x2e2d3e96 +262, 0x8bc5b0b9 +263, 0x8980346a +264, 0xa8e47fba +265, 0x2a39fe16 +266, 0x9f34eeeb +267, 0x7baebcc9 +268, 0xbc0b8d74 +269, 0x37373c8 +270, 0xe128cfc4 +271, 0x49cdb150 +272, 0x5965c726 +273, 0xfc326226 +274, 0x53a3e8e +275, 0xa99d89f7 +276, 0x33ac111c +277, 0x143fe678 +278, 0x96212281 +279, 0x6a83bffd +280, 0x529852f7 +281, 0x97fef4 +282, 0x303ce151 +283, 0x4f8c7b83 +284, 0xd5ef9c82 +285, 0xede9d572 +286, 0xc03e2c38 +287, 0x89d7f886 +288, 0x21e998b0 +289, 0x58d505cf +290, 0x5c42089 +291, 0x9a01dcab +292, 0x83d8cc17 +293, 0x7d6aacf +294, 0xa1cbdced +295, 0x47365e25 +296, 0xbb61e976 +297, 0xfeafd0a6 +298, 0x760d82b4 +299, 0x9ffb351d +300, 0x28e19ac0 +301, 0x891131c6 +302, 0xc1656522 +303, 0x4536d90 +304, 0x956b1b84 +305, 0xf9ff54f6 +306, 0xb0050d88 +307, 0x7d7fafa2 +308, 0x430e670b +309, 0x18ad450d +310, 0xd5a1d6b6 +311, 0x390a6da4 +312, 0xc70d557d +313, 0xd8fadb5e +314, 0xfb4b4cb6 +315, 0xce707f8b +316, 0x4c18d350 +317, 0x8dc0d200 +318, 0x228d9e85 +319, 0xd6485ba3 +320, 0x37c4a70a +321, 0x9d7cc5f5 +322, 0x889a9b9 +323, 0x41d2f942 +324, 0x4c13b3bd +325, 0x70e58147 +326, 0x4a0e1270 +327, 0x3cdc1b73 +328, 0x7a4e56f3 +329, 0xd8350406 +330, 0x46068108 +331, 0xfc4da48 +332, 0xf6111245 +333, 0x40a15167 +334, 0x38a591ac +335, 0x3e97e682 +336, 0x5c515d2d +337, 0x45023a37 +338, 0xacb0ed6a +339, 0x899f0ebb +340, 0x2054df01 +341, 0x6d629607 +342, 0x79ced597 +343, 0xba0a3a12 +344, 0xde63b611 +345, 0x228cb776 +346, 0x61f10dba +347, 0x9a1095d3 +348, 0xf08dcb3 +349, 0x88e58009 +350, 0x131880aa +351, 0xc55002ee +352, 0xcf556f47 +353, 0x17b6dd76 +354, 0x6110ba20 +355, 0x74a91935 +356, 0xe83cf9ed +357, 0x3138e936 +358, 0x103bfb72 +359, 0x2084abe4 +360, 0xf3a05dd9 +361, 0x9213f3a4 +362, 0xe7674dd7 +363, 0xcd09d629 +364, 0x260461f2 +365, 0x411c2428 +366, 0xbb5f6f2e +367, 0x6feb8c93 +368, 0x3cde3ece +369, 0x7a424d2c +370, 0x808a0948 +371, 0x653c3fdf +372, 0x26f88849 +373, 0xf540b6ae +374, 0x1f82e8ac +375, 0x300f7e39 +376, 0xb6e62e7b +377, 0x970441a1 +378, 0x91f2946c +379, 0xaad281f +380, 0x43be1dcf +381, 0x95a1b4c8 +382, 0x2d956dea +383, 0xc532ca29 +384, 0xc93f1fcf +385, 0x70762aab +386, 0x231a72ef +387, 0xe5bd1b75 +388, 0xfa31468 +389, 0x77e1b7b5 +390, 0x19d80215 +391, 0xd45704b7 +392, 0x33472a0d +393, 0x833a435e +394, 0x2354a326 +395, 0x8af39828 +396, 0x603a7960 +397, 0x288c2d54 +398, 0x75bd7c23 +399, 0xe2dd42e1 +400, 0x9a87b486 +401, 0x32e9bcd1 +402, 0x8630f74f +403, 0x160408ea +404, 0xd2127c63 +405, 0xaf327f8e +406, 0x8d879a61 +407, 0xc5c88f60 +408, 0x53a19fa1 +409, 0x706dacb4 +410, 0xd04ea0f +411, 0x94806c1a +412, 0x941cfe69 +413, 0x956a5562 +414, 0xee1f71c +415, 0xe6ba12d +416, 0x333e31f6 +417, 0x17aee12e +418, 0x20ccfedb +419, 0xd7bb7f92 +420, 0xba7d14f3 +421, 0xb935d4fb +422, 0xbdb8f5e1 +423, 0xb24e7adc +424, 0xc9abef71 +425, 0x3e3d8125 +426, 0x5fc0878b +427, 0x5ba172d9 +428, 0xe28f648c +429, 0x5137f3a7 +430, 0xb57273df +431, 0xe68df236 +432, 0xbc29802b +433, 0xb1419e66 +434, 0x69ecb739 +435, 0x490e8eb6 +436, 0x61e25a6c +437, 0xc1fa0de6 +438, 0x2bf2fbf1 +439, 0x9487e8da +440, 0xce5c5532 +441, 0x75859040 +442, 0x2606bdeb +443, 0x1b77c072 +444, 0xe5fbeed1 +445, 0xea9e1ab3 +446, 0x55cf96ae +447, 0x283ed27d +448, 0xc94067a1 +449, 0x8687b3e5 +450, 0x4031b307 +451, 0xc5790e82 +452, 0x4031ee7f +453, 0x952c4503 +454, 0x379ec606 +455, 0x7c35e19d +456, 0x2d333769 +457, 0xbca36d54 +458, 0xcdc70741 +459, 0xa3ab56fb +460, 0x187a2fd6 +461, 0xdd1f32f1 +462, 0xc007ac56 +463, 0x14c441c1 +464, 0xf290ed47 +465, 0xc833edac +466, 0x13f0a8fe +467, 0x63c10b6e +468, 0x6af1be34 +469, 0x5bd4930e +470, 0xfe56bfbb +471, 0x1b412c8e +472, 0xf0c7712a +473, 0xf3a96226 +474, 0xbd0aaad8 +475, 0xbd00355e +476, 0x8ba9eca1 +477, 0x81f136a0 +478, 0x7de3a327 +479, 0x7be298ea +480, 0xe60e320a +481, 0xaf4373b +482, 0x6eacbf3 +483, 0x1291760f +484, 0xd48ed89b +485, 0x596603d4 +486, 0x53abc8 +487, 0x82123b2f +488, 0x1276dc8 +489, 0xfeb474bb +490, 0x4013da51 +491, 0x111cb9d6 +492, 0x5726df82 +493, 0x45806861 +494, 0x2580801a +495, 0x1326049e +496, 0xb9474bf9 +497, 0x6c5d85ed +498, 0x9c4a9352 +499, 0x9eb915ed +500, 0x914505 +501, 0xd14c5b9a +502, 0x57ef8ffd +503, 0x480d8719 +504, 0xb18d7fce +505, 0xfd29e178 +506, 0x2679f6c9 +507, 0xd94a086e +508, 0x6e46f559 +509, 0xb7c3a2e3 +510, 0x793a4c3b +511, 0x4e5252f9 +512, 0x1bdb53a4 +513, 0xbed5794 +514, 0x31a3ebc7 +515, 0xa6eb54e1 +516, 0xc6ae5d92 +517, 0x392acfc8 +518, 0xb283fb8f +519, 0x80b15ffe +520, 0x763b49a8 +521, 0x3febc1d3 +522, 0x60f2b20 +523, 0xd93aeba9 +524, 0xeddf06bb +525, 0x13992ab3 +526, 0x4521bcf6 +527, 0x5ad82a14 +528, 0xf2bfc79c +529, 0xf664b9b +530, 0xeb9540a2 +531, 0x5641dc50 +532, 0x9282d9c4 +533, 0x5d2443a4 +534, 0x407b5011 +535, 0x84a415d7 +536, 0x5db90eae +537, 0xd2947d4c +538, 0x8bd8856d +539, 0xbc05a99b +540, 0x1c2e0f5 +541, 0xb94d03a2 +542, 0xb8ed5ac1 +543, 0x199943d9 +544, 0x12482e5c +545, 0x20aa7c9f +546, 0x8733e45c +547, 0x277b4f44 +548, 0x673d5a73 +549, 0xabc0aad9 +550, 0xbed6cd98 +551, 0x2943c24b +552, 0x5237d6f9 +553, 0x1cb1a392 +554, 0xc7b69454 +555, 0x4f792707 +556, 0xa32ef400 +557, 0x7a5b6b72 +558, 0xa8683acc +559, 0x418d0491 +560, 0x56e2470e +561, 0xbe385495 +562, 0xe7944341 +563, 0x438abaab +564, 0x82ad2c2 +565, 0x7afc306b +566, 0xfcb88957 +567, 0x530414bd +568, 0x2e3c7d41 +569, 0x633f7573 +570, 0xeffeefb2 +571, 0xf6de11f9 +572, 0x337710f2 +573, 0x88bf46dc +574, 0x6fdaf5dc +575, 0x34229d26 +576, 0x46b0aba0 +577, 0x78e40a29 +578, 0x7f9623cd +579, 0x6cfe8779 +580, 0x1d4af99 +581, 0x78f97244 +582, 0xa198d714 +583, 0x9124883e +584, 0x1cf88a12 +585, 0x69fe0966 +586, 0x78484a68 +587, 0xf9d8718b +588, 0xcbf3ba5b +589, 0xf67fb149 +590, 0xc95977c1 +591, 0x474f57f5 +592, 0x11bb9ec1 +593, 0xe28f21be +594, 0x8ca6e21b +595, 0x2609defc +596, 0x989b6f6b +597, 0x1c87383e +598, 0xacd78f57 +599, 0x8c46cfcb +600, 0xc37cce08 +601, 0x327d196a +602, 0xf63c3572 +603, 0xc56780b5 +604, 0x9ac37d16 +605, 0xe692a39c +606, 0x563938a3 +607, 0x1e80e32f +608, 0x745652af +609, 0xe425c9a8 +610, 0x11c71e82 +611, 0x9c721f6d +612, 0xef89b973 +613, 0x494c7e80 +614, 0xadc29895 +615, 0xc7ee35ad +616, 0x19beeb0c +617, 0x9c25ae3f +618, 0x27bf930f +619, 0x223970a0 +620, 0x7cdb17ca +621, 0xa49054f +622, 0xf8321dcb +623, 0x3f96a9eb +624, 0x4468072a +625, 0xfd7d727 +626, 0xee0af4f1 +627, 0xe6585512 +628, 0x56a6d8a1 +629, 0x40586642 +630, 0xb46bdaa0 +631, 0xe053a140 +632, 0x4de1953d +633, 0xb6cbc718 +634, 0x2ed92c19 +635, 0x9da2840 +636, 0x6ab418b1 +637, 0x179f64cf +638, 0x7c281c0 +639, 0x7015b62a +640, 0x8d31e38e +641, 0xa6de57ca +642, 0xe509c4e1 +643, 0xa010162c +644, 0xf71abd42 +645, 0x3d24ac8b +646, 0xc2deb72f +647, 0xd81570ba +648, 0x17fc7d15 +649, 0xf17997b6 +650, 0xfa2ec5b5 +651, 0xbf7e189b +652, 0xb3d9e761 +653, 0xe1194bd1 +654, 0x8d5280dd +655, 0xdea2d148 +656, 0x6d85e66c +657, 0x37f5fb07 +658, 0x65c1dd1 +659, 0xf52c04f8 +660, 0x4460d846 +661, 0x1729f55f +662, 0xe03a699d +663, 0x9f05ff9f +664, 0x31abe986 +665, 0x64899f61 +666, 0x52fba7 +667, 0x2833ce74 +668, 0xa34d0e57 +669, 0x7203d492 +670, 0x1a63d91e +671, 0x463781b7 +672, 0xf9842e7b +673, 0x809276ad +674, 0x88237b9d +675, 0xaa648b06 +676, 0x9cf916bd +677, 0x3b3068e4 +678, 0x20d6ae7d +679, 0x7855dafd +680, 0x9ebd14ed +681, 0xc5934a1c +682, 0xb3c421a1 +683, 0xa2b709a2 +684, 0x91fa8b34 +685, 0x9009a54 +686, 0xb2c4215f +687, 0x7b294eb1 +688, 0x1802911e +689, 0xa2067de5 +690, 0x5ebd85e9 +691, 0xc4f8e698 +692, 0xd143d368 +693, 0x2ca2b6fb +694, 0xb5d27ebc +695, 0x410146ca +696, 0x9d6948fe +697, 0xfafd0af5 +698, 0x290e9c5f +699, 0x2ff06292 +700, 0x417903d5 +701, 0xc51af07c +702, 0xd2bbaf6b +703, 0xfa3720f1 +704, 0x4a6eb52d +705, 0xed86ad3c +706, 0x72a8676e +707, 0xc3c2bbed +708, 0x62b6a951 +709, 0xe08f9534 +710, 0xe2686ea5 +711, 0x3dbbf99b +712, 0xfec5319f +713, 0xef9c67eb +714, 0x9d69d19b +715, 0xc732ed2 +716, 0xc6e829bd +717, 0xe712e882 +718, 0xd24594ca +719, 0x102b8426 +720, 0xa5145730 +721, 0x62fecd71 +722, 0xe6439ca2 +723, 0x58819419 +724, 0xef722791 +725, 0x5ef6ab17 +726, 0x85ce3714 +727, 0xd4e18303 +728, 0xf91eb9c2 +729, 0x86bae692 +730, 0x6d81c21c +731, 0xd9985982 +732, 0xfdd55f22 +733, 0x72ecd91a +734, 0x4b1cee6 +735, 0xefa672ec +736, 0x3f18114f +737, 0xacae5e62 +738, 0x68369afd +739, 0xff5e6612 +740, 0x3760af8c +741, 0xd8c878bf +742, 0x3945fe59 +743, 0x2cf7f99a +744, 0x2cc59bb4 +745, 0xbba95cd6 +746, 0x6511688d +747, 0xcf326178 +748, 0xf850cc68 +749, 0x4bd2540e +750, 0xa02cf5e5 +751, 0x5546fcb5 +752, 0xe2b289fd +753, 0x960c6ba +754, 0x3a2c9d74 +755, 0x2def7a8f +756, 0x54e57d43 +757, 0xf953c277 +758, 0xd9b414b1 +759, 0x19a25920 +760, 0xaf2691a1 +761, 0x81e88159 +762, 0x49a3eab +763, 0x276a797d +764, 0x98337885 +765, 0x37055fd0 +766, 0x6927effc +767, 0xb6de7fc0 +768, 0x9e920f9a +769, 0xd2dc9145 +770, 0xe2861109 +771, 0xe42e2c1e +772, 0x836fe968 +773, 0x23452a15 +774, 0xd49f0e2b +775, 0x2998f647 +776, 0x94f8c803 +777, 0xf8be479e +778, 0xfd44079f +779, 0x685ab9c1 +780, 0xea8eeab3 +781, 0x580ff5d8 +782, 0x88ad0666 +783, 0x19df5d86 +784, 0xe4862012 +785, 0x3ad25460 +786, 0x677449ce +787, 0x1c7e0b9a +788, 0x287a98d0 +789, 0xed39d094 +790, 0x40501707 +791, 0xb99073a4 +792, 0x31847bd4 +793, 0x91e5b7 +794, 0x46815e56 +795, 0xc823384c +796, 0xdb6fb24 +797, 0xabe50dd8 +798, 0x2a33797b +799, 0x4fb617ec +800, 0x811a36df +801, 0xb6b7a25f +802, 0x8962cd0a +803, 0xc40818fe +804, 0x5dbe4e57 +805, 0x591f6c61 +806, 0x22aa4809 +807, 0xc0e4a72 +808, 0xa8a0e2e7 +809, 0xf91d553a +810, 0x77674da7 +811, 0x196657d6 +812, 0x5ae38c0f +813, 0x8bcf1ed2 +814, 0x9e0a2c8f +815, 0xf94e5215 +816, 0x11299b2b +817, 0xc499eca3 +818, 0x25e58d1b +819, 0xdd722954 +820, 0x816f4c21 +821, 0x2504fd9b +822, 0x722a597a +823, 0x92f80aab +824, 0xe2d7e54d +825, 0xefb26dba +826, 0x9ebf8863 +827, 0xd297ec21 +828, 0xa0ebfbb5 +829, 0xec609873 +830, 0xd079b3d1 +831, 0x920f722d +832, 0xfd58146 +833, 0x5fbb5784 +834, 0x30187f5d +835, 0x887f4ec6 +836, 0x6839a2ed +837, 0x72bccd98 +838, 0x7565903e +839, 0x8d3afaef +840, 0xfb713a03 +841, 0x34216b35 +842, 0xbe0da7e9 +843, 0x4b11764e +844, 0x6666922a +845, 0x3f2dc90d +846, 0xeca8fb8d +847, 0x91579404 +848, 0x8d413df7 +849, 0x2a0f8307 +850, 0x39d5a495 +851, 0x79ba5e62 +852, 0xbb06fd0f +853, 0x47ba4208 +854, 0x4a2efb9c +855, 0xee3a07f0 +856, 0x291a73e0 +857, 0xe42a46c5 +858, 0x203455b2 +859, 0x40545253 +860, 0xa618bb0a +861, 0xd4792a15 +862, 0xd6e62559 +863, 0x8149e2f0 +864, 0x5f6499a9 +865, 0xa63fc585 +866, 0xe33e1c1f +867, 0x36ecb45b +868, 0x267883ca +869, 0x905d98fb +870, 0xfac3512c +871, 0x374d0a0e +872, 0x9920f3e0 +873, 0xfb961c9f +874, 0x70f2d752 +875, 0x69c44d12 +876, 0xcb6075d2 +877, 0xaf802ac8 +878, 0x2c4b792b +879, 0xa2203217 +880, 0xc2c15619 +881, 0xb13af213 +882, 0x759b165c +883, 0x411ecdf2 +884, 0x158e5fba +885, 0x70874450 +886, 0x226a484f +887, 0x87b95ecf +888, 0x45cef22f +889, 0xfaf186bd +890, 0x3544972a +891, 0xb4a2f73 +892, 0x5f5d10de +893, 0xf3d05e29 +894, 0x7616ba85 +895, 0x4d2e198 +896, 0x1f240293 +897, 0x317c2286 +898, 0x3bd97e7b +899, 0xd7e39d6f +900, 0x142ee43c +901, 0x688ada72 +902, 0xad8deac8 +903, 0xf7cc8d5e +904, 0xa84600f5 +905, 0xda6b1b3 +906, 0x5bad09de +907, 0x6f4276c7 +908, 0xa789933f +909, 0xede4329a +910, 0xa31f2df5 +911, 0x869c0c3c +912, 0x6658f5b +913, 0xdb451b7c +914, 0x16ec0b18 +915, 0x2e35872c +916, 0xf7bf3c44 +917, 0xda59c872 +918, 0x1ab63c0c +919, 0x9a361a82 +920, 0xd2e1afcc +921, 0x5c41ac55 +922, 0xd1d761db +923, 0x3639bb85 +924, 0x7a418cfb +925, 0xf0b06b8f +926, 0xa2ef4d47 +927, 0x4fac4d1b +928, 0x47e42283 +929, 0x6ee6a7df +930, 0xfe786975 +931, 0x4475b665 +932, 0xd881e311 +933, 0x6b02224 +934, 0xcba19b84 +935, 0x4efa35f6 +936, 0x3873a72d +937, 0x984d7964 +938, 0xe23cda62 +939, 0xea9949d2 +940, 0x243b83b1 +941, 0x48d1bcc4 +942, 0xe35b6a23 +943, 0x125288f1 +944, 0x72fdd401 +945, 0xa2af6873 +946, 0x7c211096 +947, 0xa00a13dd +948, 0x7b4ce5d6 +949, 0x1e4be120 +950, 0xc771cc00 +951, 0x343ae31 +952, 0xe8e0be50 +953, 0xd9095a3f +954, 0x616b7c17 +955, 0xa96e1580 +956, 0x60501426 +957, 0xeaac50b +958, 0x130c33b5 +959, 0xba30925b +960, 0xf942c440 +961, 0xc52e8e20 +962, 0x5f460318 +963, 0x94e1dadd +964, 0xdfa4f20e +965, 0xc9bbd26a +966, 0x75322ecb +967, 0x3dc3ff18 +968, 0xfa896826 +969, 0xe4ad213c +970, 0x7a0f97c3 +971, 0xd7b7b08f +972, 0x6ebcab4e +973, 0x1a37d816 +974, 0x16299fee +975, 0x89d94a3a +976, 0x11c2f073 +977, 0x4ef27a32 +978, 0xaaf42781 +979, 0x9862c844 +980, 0xaa672e94 +981, 0xba4f2690 +982, 0x1f767d21 +983, 0x157e1a5e +984, 0x5b6de343 +985, 0xc494501e +986, 0xe97b507b +987, 0x98cae4c8 +988, 0xc4a6b036 +989, 0x746f8686 +990, 0xe761c86 +991, 0xefdaaa15 +992, 0xb907b816 +993, 0xe9d05992 +994, 0xed2e1b0e +995, 0xe129d3ee +996, 0xb41bb95f +997, 0xaec36181 +998, 0xdcdcf5f0 +999, 0xf175572a diff --git a/numpy/random/tests/data/pcg32-testset-2.csv b/numpy/random/tests/data/pcg32-testset-2.csv new file mode 100644 index 000000000..2d4c8aed1 --- /dev/null +++ b/numpy/random/tests/data/pcg32-testset-2.csv @@ -0,0 +1,1001 @@ +seed, 0x0 +0, 0xe4c14788 +1, 0x379c6516 +2, 0x5c4ab3bb +3, 0x601d23e0 +4, 0x1c382b8c +5, 0xd1faab16 +6, 0x67680a2d +7, 0x92014a6e +8, 0x628ae389 +9, 0xa794034d +10, 0x5cc38cd9 +11, 0xfc913a3b +12, 0x81c851dc +13, 0x90c820e4 +14, 0x60dfa703 +15, 0xd613ae14 +16, 0x38ea1699 +17, 0x51f04d1b +18, 0xc4ef01a1 +19, 0x321eec02 +20, 0x4c37a737 +21, 0x6bfd1aa8 +22, 0x71a28325 +23, 0x4656d6e9 +24, 0x17509653 +25, 0x830bd521 +26, 0x6d35e3aa +27, 0x4ab85020 +28, 0x21c1da2c +29, 0x6a6057a2 +30, 0xf3a90dc1 +31, 0xa1cbdcd9 +32, 0xf70b61bf +33, 0x3b2b09a8 +34, 0xbc2ef54d +35, 0xce07f38f +36, 0xb51bc60b +37, 0x729efb83 +38, 0x7e4a5f66 +39, 0xdd824ead +40, 0x9be85945 +41, 0x57f8779c +42, 0xdb449e87 +43, 0xc0be253f +44, 0x18b4267e +45, 0xff78821 +46, 0xb53e3425 +47, 0x4550b21b +48, 0xefe89a4c +49, 0x74c130b9 +50, 0x1656a3a0 +51, 0x194da2a6 +52, 0x1a6cdb1d +53, 0x7c1fd58e +54, 0x3162d1e9 +55, 0x3e2f2c7d +56, 0xb0ab9b5c +57, 0x79156d4d +58, 0x97b85150 +59, 0x967a02ce +60, 0x1e64548d +61, 0x4196d24a +62, 0xd047eef5 +63, 0x8451cc3c +64, 0x7227eb94 +65, 0xb1191064 +66, 0x82e162d0 +67, 0xb473f07d +68, 0x92ea0426 +69, 0xbf2a25fa +70, 0x9935be52 +71, 0x28baec93 +72, 0xa29368b5 +73, 0xe3d6d97d +74, 0x85ecf1d4 +75, 0x482e4bc8 +76, 0xe4f22219 +77, 0x7531047 +78, 0x3c41ef1f +79, 0x19db5112 +80, 0xc1534caf +81, 0x6c45710a +82, 0xb323c369 +83, 0x2dac53c6 +84, 0xd5dc48b4 +85, 0x1dc6d7a1 +86, 0x3ae2bc10 +87, 0x6a7635e8 +88, 0xdeee7b7f +89, 0xcb705cd3 +90, 0xba11e537 +91, 0xb64a4936 +92, 0xff4b245e +93, 0x39cb1219 +94, 0x64833e10 +95, 0x76b0f975 +96, 0x333d7c7d +97, 0x88ccfb17 +98, 0xad78dace +99, 0xd82fb71 +100, 0x1595d411 +101, 0x47f9d57a +102, 0xd4dad6cb +103, 0x78bf16bd +104, 0x71b053d2 +105, 0xa4bb076e +106, 0xd7c57664 +107, 0x3fbcbf8f +108, 0xc816befc +109, 0x6df46890 +110, 0xd16f271f +111, 0xeeeb1571 +112, 0x58222e89 +113, 0xa55e81d3 +114, 0xafbe7622 +115, 0x938475a8 +116, 0xd8740af2 +117, 0xf937dbd7 +118, 0x7d3940fa +119, 0x694c55f2 +120, 0x2261fb68 +121, 0x6ce39e94 +122, 0xab43634 +123, 0xd92ff7c4 +124, 0xe8db22d +125, 0x52e250b1 +126, 0xaf0f7029 +127, 0xc23dd3a +128, 0xd66dc2b9 +129, 0xea7f01f3 +130, 0x4df54b3f +131, 0xf1eff09c +132, 0x2813663e +133, 0x21ae8115 +134, 0xb00d790d +135, 0x11e6adbb +136, 0x61005f4c +137, 0x3de17bf0 +138, 0x7b2050b9 +139, 0xe20dd275 +140, 0xafa0bdcc +141, 0x9c6d4c6c +142, 0xe938606 +143, 0x8eecdd8f +144, 0xea9a90a9 +145, 0x99cbb123 +146, 0x16fccad1 +147, 0x7e81fdd9 +148, 0x116e6abd +149, 0xdeb9ff4e +150, 0xc589f525 +151, 0x57d701a9 +152, 0xcf05e950 +153, 0x533a2839 +154, 0x12d592e7 +155, 0xae61f43f +156, 0x419ae221 +157, 0x81126e0a +158, 0xc3988c97 +159, 0xb3262eaa +160, 0x3baddf9e +161, 0xf19d8a16 +162, 0x2a8b130f +163, 0xe4c9ccea +164, 0xf5ae2ea +165, 0x75aaa98d +166, 0xdd45ce49 +167, 0x98e0d4f6 +168, 0xb1ec10a1 +169, 0xc9592952 +170, 0x23bb1f45 +171, 0xd0827b45 +172, 0x7a79b800 +173, 0x9d1b8348 +174, 0xe2958863 +175, 0x5143e17e +176, 0x44110af9 +177, 0x49d76858 +178, 0xdba4688e +179, 0x4e4d61dd +180, 0x729b81cc +181, 0xf3576e03 +182, 0x9b028e9d +183, 0x68d8d869 +184, 0xda15e018 +185, 0x5384abb2 +186, 0x1027ed5e +187, 0xaf5401f1 +188, 0x31411375 +189, 0xc75d87be +190, 0xad73f5fd +191, 0xadb3add7 +192, 0x4d5452ee +193, 0xdef42029 +194, 0x89d58a78 +195, 0x464d6b4a +196, 0xd01f533a +197, 0xb9533dd4 +198, 0x55c5d023 +199, 0x3dcf8fef +200, 0x198395ca +201, 0x7cdca51c +202, 0x6f4074f +203, 0xb9f79995 +204, 0xbbe3d9a5 +205, 0x520d417e +206, 0x9a8df0bd +207, 0xe390f486 +208, 0x5b578b3f +209, 0xb4cdf767 +210, 0x12d45034 +211, 0xe661e293 +212, 0x70cd3e91 +213, 0xdbc7f190 +214, 0x49829849 +215, 0x12017fbe +216, 0x1e35bf48 +217, 0x1effc3c7 +218, 0xe1f574cb +219, 0xf613ab7d +220, 0xd09d16fa +221, 0xa58bcf5a +222, 0xac39afdc +223, 0xd611d1ab +224, 0x36edd3b2 +225, 0xd9ea5d98 +226, 0xf6f2fce4 +227, 0x42cb31ce +228, 0xdd1f6530 +229, 0x3e43a7d0 +230, 0x175ec7fc +231, 0x8077af4b +232, 0x37cbcc22 +233, 0x26a89f +234, 0x998c930e +235, 0xb84e5f21 +236, 0x83817130 +237, 0x2ad05d66 +238, 0x48f3b861 +239, 0xd69f626 +240, 0x1d09f12 +241, 0xf207e7f0 +242, 0xcc709acc +243, 0x1b2881d7 +244, 0x7e18cc6c +245, 0xbfd9589c +246, 0xce0d301e +247, 0xc8668b4b +248, 0x584482bd +249, 0x722e14ae +250, 0xd79dfcff +251, 0xcc7e9c21 +252, 0xd081f540 +253, 0x3b49f7fa +254, 0xf23efb2a +255, 0xfd7fe8f8 +256, 0x9abcbf25 +257, 0x5b713674 +258, 0x1300e351 +259, 0xe884f0ad +260, 0x3c290461 +261, 0x4f64c1a1 +262, 0x17c55223 +263, 0xd5953a5f +264, 0xd85e042e +265, 0x75dfc597 +266, 0x379edfb +267, 0x75ebddc9 +268, 0xc19b98e1 +269, 0x1dd1b751 +270, 0xc5760a60 +271, 0x5f6e2f17 +272, 0x29e8610e +273, 0xb2edd7db +274, 0x9233eeca +275, 0xbc02b187 +276, 0xc997bb5b +277, 0x88ad3a98 +278, 0x3d1167ad +279, 0xcea54c9c +280, 0x7ea493eb +281, 0x586e3aa8 +282, 0xe2e027c7 +283, 0xae50ef9e +284, 0xd32e0c38 +285, 0xeba0edf6 +286, 0x980ad22a +287, 0x3b14e644 +288, 0xd7bfbff8 +289, 0xe0af1647 +290, 0x292d72dd +291, 0xb8c421bb +292, 0x114d690e +293, 0x85a86bd +294, 0x39f2b5e2 +295, 0x7c9c6b43 +296, 0xca387767 +297, 0x84f24ecf +298, 0x2aec5804 +299, 0x27d0f2 +300, 0xcd7bb6a9 +301, 0xe925969f +302, 0xc6454099 +303, 0xf7435a9d +304, 0xf7bc998f +305, 0xfa81f361 +306, 0xcba07d00 +307, 0x3e8a8a14 +308, 0xf0e7f785 +309, 0x25aecff +310, 0xe1a90226 +311, 0x4af1339d +312, 0x983f4fb9 +313, 0xbaec847f +314, 0x4e504dbb +315, 0xe7d0be86 +316, 0x73cb80ef +317, 0x336db698 +318, 0x8bf7de05 +319, 0x36e4e6ba +320, 0x47a8239b +321, 0x2a98e1d0 +322, 0x64a6c087 +323, 0x4a8591cb +324, 0x642d5d67 +325, 0x9f4b84b2 +326, 0x6bdf1176 +327, 0x7e2b1639 +328, 0xc90453f5 +329, 0xe72d0b96 +330, 0x5f0e1d0c +331, 0x156af798 +332, 0x6124d8e8 +333, 0xaa2f2ad7 +334, 0x145b30b7 +335, 0xd6582106 +336, 0x203abbad +337, 0x929d8d43 +338, 0x14d5b6dc +339, 0xef0f4eb2 +340, 0x8ff54463 +341, 0x588113a +342, 0x1bc43ba6 +343, 0x44f44097 +344, 0xb84cfdc6 +345, 0x3ee638af +346, 0xdd169321 +347, 0xaaac5f56 +348, 0xbb022bc2 +349, 0xf9ef8bde +350, 0x2829b2fb +351, 0x563368fa +352, 0x82ce66ae +353, 0x6d820e38 +354, 0xb87a080e +355, 0x756469af +356, 0x78086990 +357, 0xa220e762 +358, 0x14ba6bdb +359, 0xfa775c1b +360, 0x65fa7396 +361, 0xbae24370 +362, 0x8e42ddb8 +363, 0x1f46b8ac +364, 0x3c9236c5 +365, 0xd3a2184c +366, 0x308ba74 +367, 0x5638eb84 +368, 0x64076fe6 +369, 0x37fe334f +370, 0x8de24732 +371, 0xf0d0b02b +372, 0x18492b71 +373, 0x848f38ac +374, 0x9b46dc75 +375, 0xf5d3c06a +376, 0x203afe47 +377, 0x19857724 +378, 0x38033528 +379, 0xf7fa640c +380, 0xf1cb86e8 +381, 0x1fcd5b99 +382, 0xb07f1023 +383, 0x3bb9ab75 +384, 0x57f54e78 +385, 0xf5b51d4b +386, 0xe94eba44 +387, 0xa5a39292 +388, 0x50803af +389, 0x34ea9cc5 +390, 0xabf621ca +391, 0xb275f802 +392, 0xf46dffd6 +393, 0xd33e27d1 +394, 0xca9a56e +395, 0x6eda85a4 +396, 0x639b78ba +397, 0x799d1980 +398, 0xf3c09bf1 +399, 0x6d4cdbe +400, 0x112dae8d +401, 0xd97414b1 +402, 0x9499df3d +403, 0xa58ece6c +404, 0xe56bf91b +405, 0x3bdbfd9 +406, 0x91aae1fd +407, 0xec1fce54 +408, 0x60e0eced +409, 0x278d5b22 +410, 0xdee29da2 +411, 0xf1f55d27 +412, 0xd532ab83 +413, 0xb0fe9589 +414, 0x88fcc255 +415, 0xf524359b +416, 0x7270a00b +417, 0x42489eaf +418, 0xc020d6bb +419, 0xf9ed0f78 +420, 0x4bc5cdec +421, 0x55061393 +422, 0x6b84a5a4 +423, 0x826c0471 +424, 0x9e69e30d +425, 0x9dfd9b15 +426, 0xf4014c40 +427, 0xcd04ef4d +428, 0x7376c02c +429, 0xb15a9e3c +430, 0xf76c1fa9 +431, 0xcd51bdd8 +432, 0x99f2859e +433, 0xb62c6a4d +434, 0x52239d8b +435, 0x27fa2869 +436, 0x6dba918c +437, 0x9891e444 +438, 0x71e29f5 +439, 0xa9cd3ac9 +440, 0xf6ec3b80 +441, 0x8c8d3226 +442, 0x7c528725 +443, 0xd543932b +444, 0xf76b3e02 +445, 0xeccaf183 +446, 0x8f757854 +447, 0x785edb62 +448, 0x54397da0 +449, 0xe1fe0557 +450, 0x7a79d418 +451, 0xd2740507 +452, 0xc3561bc7 +453, 0xef7c3f18 +454, 0xecf8effe +455, 0xc7a073ad +456, 0xeb5ea9fd +457, 0x33dade18 +458, 0x89d0e41c +459, 0x7720d298 +460, 0xe912f029 +461, 0x7794462 +462, 0xa436dcf6 +463, 0x55cbb318 +464, 0x7b4a78e0 +465, 0xa8ce0afb +466, 0x7e18bb28 +467, 0x92c4f8f6 +468, 0x6828052c +469, 0xbf619f8 +470, 0x272d1d15 +471, 0xb34e2e52 +472, 0x52158f7f +473, 0x682fb062 +474, 0x52e80435 +475, 0x787e0fb3 +476, 0xe331da39 +477, 0xfad42e58 +478, 0x1bdb3f90 +479, 0xe313ab2 +480, 0xe61af9bb +481, 0x46f03903 +482, 0x926b3d33 +483, 0x2b23ce3b +484, 0xed04d4af +485, 0x34c49faf +486, 0x142f503c +487, 0x47cf6a21 +488, 0x5352250c +489, 0xf5942210 +490, 0xca5950ae +491, 0xc5302422 +492, 0x41a5e9b1 +493, 0x30076390 +494, 0x8951d0e4 +495, 0xebe74e22 +496, 0xfcb7dbf8 +497, 0xd55076e7 +498, 0x88a1165b +499, 0x1a89b5a3 +500, 0xda2c3e2e +501, 0xdc1d606d +502, 0xfda0315c +503, 0x5f5610dd +504, 0x3eba316c +505, 0x72cae07b +506, 0x5336095 +507, 0x6a110322 +508, 0x46cb153b +509, 0xa2b11116 +510, 0xe2543988 +511, 0x51f53bae +512, 0x3b10466d +513, 0x189ddd56 +514, 0x1fd355b6 +515, 0x1230e8d3 +516, 0x2050d313 +517, 0x2fbb5c16 +518, 0x64b03f4f +519, 0xbd6cdc1a +520, 0x9d423316 +521, 0xc71a702f +522, 0xf2254f39 +523, 0xd953728b +524, 0xef3c8bb5 +525, 0x685a2fab +526, 0xcea73dff +527, 0x4a7fa029 +528, 0xa27e8058 +529, 0x561a1413 +530, 0x570fc5bc +531, 0x917e93ee +532, 0x15fdbb15 +533, 0xabee295e +534, 0xc40f5307 +535, 0xba18b087 +536, 0x6ea6e339 +537, 0x7e282248 +538, 0x875062c2 +539, 0xd1520c30 +540, 0xb4cef1a5 +541, 0x55812dd1 +542, 0x9c67743c +543, 0x22fd5992 +544, 0x1dacbfa +545, 0x5b35eab1 +546, 0xfa8c9316 +547, 0x490bc71c +548, 0xe5129bfb +549, 0xe7acb79f +550, 0x87667765 +551, 0x945be067 +552, 0x8acf5c32 +553, 0x466e0ee +554, 0x8fa89be0 +555, 0x4eb4afcc +556, 0x3302055b +557, 0x8f2e3ab9 +558, 0xc5bc175e +559, 0x903a3e85 +560, 0x4055dd04 +561, 0x37873bac +562, 0x2965a951 +563, 0x2206c56a +564, 0xf34dc2db +565, 0x34e43ba2 +566, 0xb61caa44 +567, 0xfd3eb260 +568, 0x9dcdc817 +569, 0x7019df83 +570, 0x6fcd9bea +571, 0x270cba0a +572, 0xd6cc3241 +573, 0x6345c906 +574, 0xd213fb94 +575, 0x6195e5b5 +576, 0x804abab7 +577, 0xb4cace45 +578, 0xded19bbc +579, 0x617db00c +580, 0xafb933d6 +581, 0x8192cae8 +582, 0x45ffd8af +583, 0x13ae0868 +584, 0x840f4541 +585, 0x12cd1a05 +586, 0xbb5b7d6d +587, 0x3907ab3 +588, 0xd77a1582 +589, 0x4e741292 +590, 0x28c60865 +591, 0xbaad11e2 +592, 0xa9d3e364 +593, 0x88a197cb +594, 0xe90f021f +595, 0x2056017a +596, 0xeb0a2fd9 +597, 0x1d3435aa +598, 0xdaa0b802 +599, 0x8121bf09 +600, 0x95a88f55 +601, 0xa8b9c257 +602, 0xb0ab4914 +603, 0xf360b741 +604, 0x5563d4ab +605, 0xad33cf0e +606, 0x397d315a +607, 0x6893767f +608, 0x79dd5b31 +609, 0xa9ea6777 +610, 0xcf48c06 +611, 0xb4cceafc +612, 0xf53cab50 +613, 0x72426c8 +614, 0xd128aa5a +615, 0x511eec88 +616, 0x668ab20a +617, 0xb9b53dbe +618, 0x3b03a0fb +619, 0x8f416a98 +620, 0xaa15b7f6 +621, 0xc7767aba +622, 0xa64d3342 +623, 0x42cf1388 +624, 0xfc3ee7c0 +625, 0x892a2902 +626, 0xdb054bf6 +627, 0x4973223f +628, 0xb9f74682 +629, 0x72f2ece +630, 0xddf94382 +631, 0x67581d86 +632, 0x9cb9cd6f +633, 0xed74731a +634, 0xcca05451 +635, 0x3b21fdc0 +636, 0x9e18e52b +637, 0xa40bb287 +638, 0x8bb05e07 +639, 0xa33555fe +640, 0x4c819ed +641, 0x5373903e +642, 0x611403c2 +643, 0x133e25fb +644, 0x9c7a44e4 +645, 0x67197b8d +646, 0xfa910436 +647, 0xa86a825d +648, 0xfc9b24c1 +649, 0x464a718e +650, 0x7421bc26 +651, 0x3c3186b7 +652, 0xf7304619 +653, 0x7ac7be81 +654, 0xae6adcc4 +655, 0xca96bf8c +656, 0x49711d50 +657, 0x74c51f0 +658, 0x275804c0 +659, 0x228098c5 +660, 0x73a31b94 +661, 0x7f01db79 +662, 0xb36209c8 +663, 0x6ccf8677 +664, 0x70dbcce0 +665, 0xa533d8cd +666, 0xd0b0f097 +667, 0xd9a3b784 +668, 0x80a929fc +669, 0x9708f29a +670, 0x95e1e56f +671, 0xd07a0b45 +672, 0x566acdb6 +673, 0x92663054 +674, 0x3667dc9a +675, 0x80f850ff +676, 0x549dd640 +677, 0xc3ff18ca +678, 0x8c70d392 +679, 0xf5547e3b +680, 0x8dbee1d7 +681, 0x51fe33b8 +682, 0xb1ea480b +683, 0x6646f6d0 +684, 0x4a8e7de9 +685, 0xcb053e32 +686, 0x6311aee8 +687, 0xcc2a411b +688, 0x5330e60b +689, 0x4680e825 +690, 0x96bdd8a2 +691, 0x8cf4268a +692, 0x8445c833 +693, 0xc237eef1 +694, 0x459670e8 +695, 0xedf26624 +696, 0x5713340f +697, 0x5a3e87a3 +698, 0xa24a7c2d +699, 0xfa9fdceb +700, 0x746fd14e +701, 0xc6aef3e5 +702, 0x3d957e9b +703, 0xc1926f7a +704, 0xee717768 +705, 0x101fe323 +706, 0xec0d63ab +707, 0x8b8e6f42 +708, 0x8c3d2286 +709, 0xb573dd68 +710, 0x53b68ec0 +711, 0x696525cf +712, 0xdab65d8e +713, 0xd2c6ed42 +714, 0xa1fc10f6 +715, 0x1554666 +716, 0x6ed42947 +717, 0x87f7e62 +718, 0xaf34733b +719, 0xc55baa8b +720, 0xcbff66f +721, 0x2516c228 +722, 0xec6980fb +723, 0x4f53d66c +724, 0x1be17a32 +725, 0xdcfb31df +726, 0x4b17d04f +727, 0x81e1f54b +728, 0x749eae52 +729, 0x3811c4d5 +730, 0x5d11e6a1 +731, 0x535d5d6c +732, 0xbb74cd20 +733, 0xd1b18b71 +734, 0xfbf7221a +735, 0x817c4279 +736, 0xcef30b85 +737, 0x41dee06c +738, 0x9d340a3a +739, 0x691f0449 +740, 0x363a515d +741, 0x73a1af6c +742, 0x25718271 +743, 0xb4a52d50 +744, 0x1e392f40 +745, 0x3c811345 +746, 0xc9aa8565 +747, 0x357c24e0 +748, 0x19ad7230 +749, 0xed250e20 +750, 0x4acc4824 +751, 0x825d53a +752, 0xcf2f515f +753, 0xb7973ff4 +754, 0xb03ce53f +755, 0x1afad500 +756, 0x39f64ee8 +757, 0x60bea483 +758, 0xedf16817 +759, 0x88beff73 +760, 0x4909868 +761, 0x879a96da +762, 0x52d4ac6b +763, 0x46fabe65 +764, 0x88fa5751 +765, 0x71df4521 +766, 0xfc6eb286 +767, 0xf83e78ad +768, 0x885e5aca +769, 0x77e63e4a +770, 0x2bdf5c02 +771, 0x2528323c +772, 0x5b5d1ce9 +773, 0xf795be8c +774, 0x5e113b2b +775, 0xa993c7aa +776, 0xe5f8560a +777, 0x77e1e8d +778, 0x5e9db88a +779, 0xdac4e96b +780, 0x9126b945 +781, 0x15bf293a +782, 0x1dc9a8f4 +783, 0x909b48b1 +784, 0xb50ce29e +785, 0x21671c87 +786, 0xcda80dec +787, 0xf5aff1a9 +788, 0xd70cdb2e +789, 0xd293139a +790, 0xcbf4f51d +791, 0xb23c6d7a +792, 0x1a06aa33 +793, 0x21880210 +794, 0x92679678 +795, 0x8d5bb26b +796, 0x23304100 +797, 0x8f5d1df4 +798, 0x143b39ff +799, 0x29e97d16 +800, 0xbfad952f +801, 0x257ca1d8 +802, 0x32ad2f8f +803, 0x84d320c3 +804, 0xcc4c59a +805, 0xbb5ae046 +806, 0x3d5fcf1d +807, 0xa0130b0 +808, 0xad86e9de +809, 0x1e422521 +810, 0x6b56a617 +811, 0xbe64d9fc +812, 0xfff31ed0 +813, 0xd1ad616e +814, 0x13486a20 +815, 0x1754613b +816, 0x52c7b9da +817, 0xc05d75aa +818, 0xd719cd98 +819, 0x61890574 +820, 0xc4711a8b +821, 0x9afd5635 +822, 0x4dabed21 +823, 0x94f173 +824, 0xb8b6e708 +825, 0x1d590111 +826, 0x60315dfd +827, 0x7fb8ae79 +828, 0xc69f4f2b +829, 0xcaf1c898 +830, 0x861a0c8b +831, 0x6ed14eaa +832, 0xc77da58 +833, 0x8fd4f29a +834, 0xa38187fb +835, 0x6ed1ee88 +836, 0xf1a9f55a +837, 0x74368cc8 +838, 0xf327e944 +839, 0x97a578af +840, 0x8a5345e5 +841, 0x63ee0a30 +842, 0xa7e4919b +843, 0x51e26930 +844, 0x38dbe017 +845, 0xedace3a9 +846, 0x9cda2ad4 +847, 0x96b1119 +848, 0xff56282a +849, 0x71773edf +850, 0xe41fb69c +851, 0xe7bce539 +852, 0x221ffeed +853, 0x35d3f67f +854, 0x7e089168 +855, 0x6fd47823 +856, 0x43bfb28d +857, 0x9ce49e62 +858, 0xde32120 +859, 0x6eacfe4e +860, 0x116c6128 +861, 0x5f975284 +862, 0xc547361c +863, 0xf48e8251 +864, 0x2ac8a3bd +865, 0x9a0fce5b +866, 0x1764e3d9 +867, 0xa31e6954 +868, 0xb9dca055 +869, 0x1cd35c79 +870, 0x1b502882 +871, 0xf973ab10 +872, 0x8b585146 +873, 0x841fd3f8 +874, 0x4999200f +875, 0x7ad10c4b +876, 0xcf1695bd +877, 0x26c58bc3 +878, 0xdc1f8310 +879, 0x546e1e86 +880, 0x2e39fec8 +881, 0x8c65e2ed +882, 0x6469bac +883, 0xbc4af1ff +884, 0xa1669010 +885, 0x41dabd80 +886, 0x5797e218 +887, 0x9bed24c1 +888, 0xa7552347 +889, 0x4e214099 +890, 0x34d4f986 +891, 0x316cc527 +892, 0xde30c21c +893, 0x4f273c1e +894, 0xc3dd9324 +895, 0xe61fda1c +896, 0x1d0f8076 +897, 0x5570867e +898, 0x289d6062 +899, 0x465b8b26 +900, 0xb72307de +901, 0xe78c8647 +902, 0xfee9723e +903, 0xa1534c9b +904, 0x4d652645 +905, 0xe623b6c2 +906, 0x454cfc8 +907, 0xc5a7fcaf +908, 0x1de804d9 +909, 0xa2501de7 +910, 0xe036c091 +911, 0xa4a55d1d +912, 0x50409892 +913, 0x58fd2731 +914, 0xb6fd3618 +915, 0xa0180bd2 +916, 0xd9bb2fe8 +917, 0x7c8e7a2c +918, 0xd90906fc +919, 0xf8721260 +920, 0x451b372d +921, 0xeeb1c70 +922, 0xc1a18778 +923, 0xd466244a +924, 0x88e4b84a +925, 0x4fc3af63 +926, 0xcf4387e4 +927, 0xb8872734 +928, 0x276eadef +929, 0xd2c164a1 +930, 0xd3c812d9 +931, 0x5a94f176 +932, 0xfba6f632 +933, 0xf7aeba97 +934, 0x9207585f +935, 0x70a41d67 +936, 0xa0b70910 +937, 0xd579fc6b +938, 0xf06a8fca +939, 0x471fd406 +940, 0xb15a0491 +941, 0x2f340f7a +942, 0x3df02de3 +943, 0x6022f8d6 +944, 0xa15b11c2 +945, 0x45715dd6 +946, 0xf293d85e +947, 0x7a2100d +948, 0x7dff786e +949, 0x52c6a183 +950, 0x5fbce2db +951, 0xbc29ec65 +952, 0x3dd14b27 +953, 0x1bedecd1 +954, 0xbfcba31c +955, 0xb911a26d +956, 0x6b6de680 +957, 0x36e8769 +958, 0x908de4a0 +959, 0xe1abee1f +960, 0x83acd7f8 +961, 0x5008c1eb +962, 0xd8bc7a2b +963, 0x6f639c56 +964, 0xe1f2634b +965, 0x267222ec +966, 0x48fa416c +967, 0xfa01e3cb +968, 0x2d28a700 +969, 0x58dcdc97 +970, 0x685ac2e7 +971, 0x9318840b +972, 0x99247a55 +973, 0x8d749b83 +974, 0x403f8415 +975, 0x373eb9c6 +976, 0xb840b6a2 +977, 0x9bb7bfc4 +978, 0xd5800634 +979, 0x3ef4a02d +980, 0x2ffa791f +981, 0x8a671150 +982, 0x40fdfc5e +983, 0xfa4bd35e +984, 0xf4ca1642 +985, 0x17fb231a +986, 0x42a3e57c +987, 0x58cf119d +988, 0x32f19c67 +989, 0xf3e2e153 +990, 0x66fce6fb +991, 0x9d61059b +992, 0x1628eafb +993, 0x9a6cf683 +994, 0x5ff5df3a +995, 0x206fb3c9 +996, 0x1914913c +997, 0x58c002ad +998, 0xd099145f +999, 0x155aab4b diff --git a/numpy/random/tests/data/pcg64-testset-1.csv b/numpy/random/tests/data/pcg64-testset-1.csv new file mode 100644 index 000000000..da6d77d40 --- /dev/null +++ b/numpy/random/tests/data/pcg64-testset-1.csv @@ -0,0 +1,1001 @@ +seed, 0xdeadbeaf +0, 0xb174ddf3fe597da6 +1, 0xfc217240c1e61e6f +2, 0x20279da26fec9cbf +3, 0xa5f4ee34651f4e1e +4, 0xb254d7901c68b9db +5, 0x6bf2a64e4052c36f +6, 0xbec4c7418c0f61b6 +7, 0xb03e595a4ef2b2bd +8, 0xc8e051957ccb74c6 +9, 0xf5082df7473c6f62 +10, 0xb72aa3dc22752a38 +11, 0x7a941561514bd680 +12, 0x90a95f42834f347b +13, 0x88e17b9d59def797 +14, 0x18f19c86bfe60368 +15, 0x667f89277be8d1d8 +16, 0x63305475e7aeff27 +17, 0xd7e4d5c09fb0fb4c +18, 0x7dd6deab03a8c26a +19, 0x42bbcb746e2d4b26 +20, 0xe91f2ac4fa90689c +21, 0x2f83458da0af3125 +22, 0x49a43537a00fae89 +23, 0xef02111d1ebc16eb +24, 0x32b3b3019875f3e7 +25, 0x89eb15c48cd02774 +26, 0xa9f1b37865752731 +27, 0xe0eff9dadc47fb3 +28, 0xae859b1c54cc90c2 +29, 0x7b7c5e04d5015dec +30, 0x38faeff5ce3266ff +31, 0xd2ddd0d19fbc24ee +32, 0xe0d4f692829a31a9 +33, 0x30a6aa3f408e71c2 +34, 0x298362be21de6d44 +35, 0xb7efab759e691149 +36, 0x2ae1f84bba093d4c +37, 0xf6ab55f78f8b9258 +38, 0x2275d0af583cec95 +39, 0x18cfe066b183ac3c +40, 0xcc0a546d54064cf5 +41, 0x5de027ea3c25c225 +42, 0xdaf31ef489fe71e1 +43, 0xa7a2b1a72a4360e7 +44, 0x678a55d7a0506791 +45, 0x36facd8799ad2b78 +46, 0x32fec94506dca70e +47, 0x34e890d8539871f8 +48, 0xec48b5362b0d7818 +49, 0xe2e58921cf8228d3 +50, 0xd163588ec22730a4 +51, 0x17e2322b6be47d25 +52, 0xe1544989a0c6d24f +53, 0xa3a10fb279cdc347 +54, 0xad4ee318a5853900 +55, 0xc96a185feef4a85d +56, 0x82ec5b3aed6636fb +57, 0x2aac2ef8f25426d7 +58, 0xa81e3114165e0d08 +59, 0xc1d8128f83969da5 +60, 0x157505508eaf50f1 +61, 0x77c175067c9c199c +62, 0x973052089bd7af0 +63, 0x3cd70041e32c1921 +64, 0x7783719f13a254a0 +65, 0x2216485ff502d9ff +66, 0x7dae695d2c7f3b79 +67, 0x809ce710156fea36 +68, 0xb90ac31262460e4e +69, 0xc1afe8019306e7d7 +70, 0x6c57638edba4ca0a +71, 0xbe6133f6ab1e9aeb +72, 0x8f5699ff0bcf341d +73, 0x69d0218df036bcbc +74, 0xf0976fd79735d47d +75, 0x82b36a795e5cc74b +76, 0x263c30766b985686 +77, 0xf7426f94511d5ba0 +78, 0x8b04f9573050ed9e +79, 0x7280d4ec202e8359 +80, 0xa8235fbd1324f172 +81, 0x6dbd5d500a809a8c +82, 0x26c53c69292bca1d +83, 0xe348f657b20305ec +84, 0x562f0e2fbb375421 +85, 0xdf2be07bebfbe447 +86, 0x4275044640683760 +87, 0xad5d68bfe4ab4858 +88, 0x3c0e57df5b3306f0 +89, 0xc9d87622ac847565 +90, 0x83d04fd9e102c311 +91, 0x71996b9c65aaf5c0 +92, 0xe3df32742d6fc446 +93, 0x58d3a6573a39d0cb +94, 0x74dfa090e96d289d +95, 0x7856f45e5416c1ea +96, 0x80a18e88b3e4dff8 +97, 0x60565bbcb04f56ac +98, 0x9f4cf5ec45fae3a6 +99, 0x885d2909fe34e3f0 +100, 0x7a1db9118f60dee0 +101, 0xc4c17dc810746c7e +102, 0x8b954b14effe83b1 +103, 0x4f89fb0940999c86 +104, 0xc62e634bceca1c97 +105, 0x7e06e87dffd1619f +106, 0xd1ccbce841371671 +107, 0xe7f99698c66df1b3 +108, 0x5302c2f0e4e1f4e0 +109, 0xa57d11d3d7ee652e +110, 0x8abe0ed0e5508407 +111, 0x6780588af9f6c2ff +112, 0x8603a9fc73b6a4cd +113, 0x169c13a0b7a166b9 +114, 0x868969fb53578598 +115, 0x6089e0eacbe69039 +116, 0xf82482d424397dc2 +117, 0x11475d20896fc890 +118, 0x7983933df29e2aa0 +119, 0x4889c4780cd8e9cc +120, 0x53ebb258f3ea266b +121, 0x121896059b256fd1 +122, 0x2f9934516b2f8090 +123, 0xbabb9fa1d1efa60c +124, 0xfb0b1370ea044797 +125, 0x782ab293b597bc8e +126, 0x297fc0b3977271f5 +127, 0xa573e4d0674d02fc +128, 0xc7e8ddb6efe8a2db +129, 0xaae8a024e62f6e32 +130, 0x3217a47698c9e439 +131, 0xd7015db847a3de0b +132, 0xbc0b4368776e10a7 +133, 0x69d9ef0178679bfb +134, 0x28fd8f0936b66fab +135, 0x45b1c4d4aa9b5aca +136, 0x28feade39cd3ac00 +137, 0xa7e6515c534520f1 +138, 0x735703b5f4bfd54e +139, 0x798271ae0c91b8d8 +140, 0xf858458f9efa8d2 +141, 0x6a41f5845422a9e +142, 0x7fb0bba5f097aab0 +143, 0xbfaea58fe090e745 +144, 0x84770504bfb15b35 +145, 0x67ae11aa368049b8 +146, 0x846c5e493ee15e4a +147, 0xbbcf3baf029f056c +148, 0xd30c23bde142a356 +149, 0x32cd403edb746a8d +150, 0x40161ab00c636730 +151, 0x3a882c3c60d3e19a +152, 0xca8faab24d826529 +153, 0x241a687288551d04 +154, 0xbbc607fb9b48ac00 +155, 0xa844329d0c2d475a +156, 0x8fa4aa1d7296b9e4 +157, 0x82c7dc1f588ce2fc +158, 0xcbdaa663041e078c +159, 0xec108d219b2b147a +160, 0xcab01864270b334 +161, 0x6d3d08545041621b +162, 0x2aae054b8e5648f +163, 0x1bf5a72fa70e7eab +164, 0x2dddb2050af45a3a +165, 0x2b910b7078021a75 +166, 0xf7160201ede45f4e +167, 0xfaf75ae996f079bb +168, 0x407984a9451e659c +169, 0xbdf9c0a9ea078ac0 +170, 0x1e7717b8345acbb6 +171, 0x25cc2df4c0c8dc4a +172, 0xfda1715b573850db +173, 0x50e5cedad99e2651 +174, 0x9a67673ed73cfc0 +175, 0x802ec4fc9e946805 +176, 0x677cd320e641999f +177, 0xbfeb1b6053fe4f78 +178, 0x220cfc90bd31541 +179, 0xe4fdfae10ae6c86f +180, 0x76c568fd869af80d +181, 0xd17dc57109200bb1 +182, 0xeb96ba01c95382be +183, 0x6a9c7ebea5b5f7ac +184, 0xc1680450532fb8cd +185, 0x26b0829f68888094 +186, 0x98335aa1612d7c70 +187, 0xad8662125bf32ae3 +188, 0x15f18a9025ae26e8 +189, 0x5d065dba0d17c9fc +190, 0xf68e1d59f10ff109 +191, 0xcfbd97901a79f8b0 +192, 0x3e72a9fd1d95f143 +193, 0xe7ee82c1bb740dfd +194, 0x3a0f4ae5db22527b +195, 0xf4d025080ed4ea92 +196, 0x6924a99549b4657 +197, 0xcb83b51552208e2f +198, 0x9f306634214b44e9 +199, 0x4fb3307b0e1a7535 +200, 0x73d202d4225c5394 +201, 0xd5a2fa42f8cc8c5c +202, 0x7b3b3e3f7b948d3c +203, 0xa2dbc4d30d8c148e +204, 0xd1bfc1f05a8f2c5d +205, 0x2b00a4efa2f19262 +206, 0x9d4a05bb18647f48 +207, 0xff21fbaf0b46d13f +208, 0x126f9c5f2132af20 +209, 0xd4b7629b0d9a6b89 +210, 0x2d61949fb3126ecc +211, 0x30d61648763db1ce +212, 0x9c5234d15120bf17 +213, 0x2eb0eccb6cc14c8a +214, 0xcf18eff5ca2af8a4 +215, 0xab5fe599ea68c377 +216, 0xe47a0bb8436af89 +217, 0xd3728a566187c400 +218, 0xb8b54592b62f633e +219, 0xe02b958f9c13a180 +220, 0x9e5f5cc85283f24a +221, 0xbd1ab869878744a +222, 0xb93fd6297a29c8dc +223, 0xf22f06ee61dc2413 +224, 0xc93fe440766cbd8e +225, 0x7459d9b19375a51c +226, 0xd4ec87c57baa4127 +227, 0x1514d0226dc0409e +228, 0xc6b0d7e1bd56b190 +229, 0xc0c61c73c9dbffee +230, 0x2f1154afb48a93e2 +231, 0xd2ca05901bae0117 +232, 0x6263f647273694a0 +233, 0x94a98bf80488205b +234, 0xcb0d63747735bead +235, 0x9cbd4e1659932c5b +236, 0x1807e01931b5ade0 +237, 0x1d9f7721d3067854 +238, 0xb25dbde4ec77e547 +239, 0x4b186592a39adcd6 +240, 0xe8ad5514de72a98f +241, 0x2deac1cb096a09b4 +242, 0x6952f4b82a2c87 +243, 0xaa1590223ed83ffe +244, 0x9baf13d08f572e12 +245, 0x83ec1bca1e724d88 +246, 0x5c61bf2222b4907 +247, 0xd950ff64ad7b956e +248, 0x36bf5e992bf1f211 +249, 0x75ad67249d7a6c35 +250, 0xeb12dcef5c2bfe7d +251, 0xc508da925157e39d +252, 0x91cbd7491ea7f70e +253, 0xf10c018ec0b0e55 +254, 0xeeffb21fef1e87f1 +255, 0xe31692b834d067dd +256, 0xd69bbafdeb5c0d15 +257, 0x41358dadb9260eb1 +258, 0x5fa3c67d353cd6b2 +259, 0xdbb743cac20b2eda +260, 0xe7877ba98b2bfe4 +261, 0xf14d679436fd2dcf +262, 0xa313e39059d62afe +263, 0x7eaa134c761a6183 +264, 0x7719af9ad1fecaec +265, 0x533f921a4702d433 +266, 0xe072f9665ec3a3c8 +267, 0xba89560ab4ba08fa +268, 0xe94f0aa266e56d53 +269, 0x774b84bcb152afc +270, 0x787c9517e589748d +271, 0x3831a5303adfd362 +272, 0x19cb20184a4264f8 +273, 0x9bc5e99e1773700e +274, 0xed323bf38642f651 +275, 0x860868c0eba789f2 +276, 0x8c1602ffd9a5621a +277, 0xe298d8fc74e146ce +278, 0x3181a2083c76037f +279, 0x27942fd6842079c0 +280, 0x38fe8c0406516df +281, 0xd211a4a42857bec3 +282, 0x56002508b351879d +283, 0x2472ed93614c7e99 +284, 0xbcafdaadc0f77b7c +285, 0x86becbd3e5303107 +286, 0x930251d84de72320 +287, 0xea79aa2964954052 +288, 0x6dbc5e63b50b1724 +289, 0xb098535ed4bc7372 +290, 0x6490d6d8541fb656 +291, 0xc738f6ccb4b7076b +292, 0xd69ee4fd6ce63026 +293, 0xfa98e9d78a628338 +294, 0x9c30b63a70d607b6 +295, 0x8d544b5d224a25d9 +296, 0xa051f7fe38445228 +297, 0xf6931861338a00f5 +298, 0xecd71cd64b0b5dcd +299, 0xdbc818e7126193b +300, 0x3aaaa032aad8199a +301, 0x6fd68a3818e0c439 +302, 0xc82a651ba9ede8c9 +303, 0xe6d958e267017187 +304, 0x73a9eab64de651ae +305, 0x5a6757f7f222bb3c +306, 0xe62e7cca6bd17a32 +307, 0xc4f6c31f528dd387 +308, 0xdecd8b663c995773 +309, 0x69a21dedcbfef9c7 +310, 0xb33f8ac00f17b6b2 +311, 0xe32b3c962d613ba3 +312, 0xa9c317d026600d41 +313, 0x901d971c49671213 +314, 0x46c3f3d35db8808b +315, 0x1336297232af9791 +316, 0xed88d9242e11edb3 +317, 0xc70c48843f54af0 +318, 0x611062a0461deedf +319, 0x7e3183514f127f20 +320, 0x7b549d10bace1c47 +321, 0x6db523d19d0a7af3 +322, 0xf6e677e5222a21a4 +323, 0x28e5188ba7055c32 +324, 0xbe7b41d2ce539c4f +325, 0x5c085a18c3b7bbe0 +326, 0x209cf345b3c3b06c +327, 0x79ca5407dd486857 +328, 0x8e07ac4c65338ccd +329, 0x56dd5372249cadad +330, 0x27e0b07863fa27ff +331, 0x78dec95d299a8699 +332, 0xbd5d71253b73d456 +333, 0xbf83b6cedd205e9 +334, 0xee2352ee69aa68e +335, 0x4b14f253d684cfbc +336, 0x12ffa5d5f8a34bec +337, 0x2e38346fbc793f67 +338, 0x2ab5862872b4850b +339, 0xcbc8aec1e2bb6760 +340, 0xd79ef783845cc329 +341, 0xdbdcde91e1685704 +342, 0x29880643aa1095e4 +343, 0xcd5ccc1fe9a616af +344, 0xc7b6cdc4a43c132c +345, 0x7b08597fdec7fc9c +346, 0xa01ab3827e120a16 +347, 0x89ce37de99ca7748 +348, 0xb4644823ea6b90d5 +349, 0xdbe189861c409209 +350, 0xbfeb614759981b60 +351, 0x48c2c3a6d2419755 +352, 0x1aa1df0e99b3417e +353, 0xb9f061bf98c0da28 +354, 0x8bce2755a0b5b8ae +355, 0xc9bb2ff33d60b3e7 +356, 0x6abcbb1ea0d3a575 +357, 0x983a3c16a0e5d6f8 +358, 0xa122e616797ccdbe +359, 0x751dfe60252a01d0 +360, 0x8d1bcbbde84f6a11 +361, 0xb6bc4f2942ba0e57 +362, 0xb298977a4bb20e12 +363, 0xcf658188dd931722 +364, 0x39735757b19c90a3 +365, 0xc2fcf1df99f1b7c4 +366, 0xd42c50f6a912aaea +367, 0x95d0cb8a953965c4 +368, 0x75c7d03289269f25 +369, 0xd8d96184031fb36b +370, 0xb3b34b5ba8bac75 +371, 0xcfbf16d241e46f8c +372, 0xec465e59019b6f6f +373, 0x4051ce0bc2562a63 +374, 0x859f05ce7b75da05 +375, 0xf2661ef2e3c733ef +376, 0x8067f432dd5af0c4 +377, 0x6e8542a346911713 +378, 0xfcda2ac6aa45ca20 +379, 0x571f23fdacb25fe2 +380, 0x2546f5badf7adb8b +381, 0x929ebe6fbd330e2b +382, 0x9d41d6ded9facbeb +383, 0x4cf9d9da6c125106 +384, 0x495d5708443faa36 +385, 0xb0023a41a6057e59 +386, 0x37fa1cd9ce66b20a +387, 0x96a376fca4aff5a8 +388, 0xc22469c4a3e1ea85 +389, 0x5ab79b721966249b +390, 0x2124be452f7d4ca4 +391, 0xe71bb882b954ca11 +392, 0x322bdcaf9c7b0efa +393, 0x4c99c8753878439f +394, 0x3ffd6caec9f9ac49 +395, 0xfba842dd40a3c72e +396, 0xfd93517d31681d77 +397, 0x44c139a74249a128 +398, 0x828a145610684c8 +399, 0xb53696f802522b6 +400, 0xa2da2199474d079a +401, 0x739e508fbbdeb714 +402, 0xe75c4734a7c95f94 +403, 0x5c22c226f2bd8487 +404, 0x7108fa6b99b0d72e +405, 0x3c60b40f6e4bebde +406, 0x395150555d56dd18 +407, 0x13246a6e4d795fe3 +408, 0x27dca990fb678027 +409, 0xc5a92c32724a7373 +410, 0x30fed89f4171a817 +411, 0xf7f7810edea2e7eb +412, 0x46e930eef5351212 +413, 0xe1331cd8a678dc66 +414, 0xd4cc0a5f96a72457 +415, 0x2559f8d286b1da16 +416, 0x73831b2f6e4a4ba +417, 0xd929ccf267504761 +418, 0x8a7a1b357f8bbc38 +419, 0xd5e0d3e200d0d633 +420, 0xc2cc05cc3ac5abb +421, 0x75b8f78a06ca465b +422, 0xeaf1d6aa9c0baef3 +423, 0xa6c9bc3dbe45e62e +424, 0xb1496074b4c338d7 +425, 0xc18ebb892108cec +426, 0xf6cbbf4cd0f8f9ba +427, 0xd73759407ecbdcf6 +428, 0x54dc0805c85a3b0c +429, 0x4ba3936d6be048f3 +430, 0xa3fbea19803cf35 +431, 0x78b1d3a837d4bed +432, 0x6ed09ac2c177453b +433, 0x16134c4e8b30f6ba +434, 0x94718ce4868f01a3 +435, 0x612fa336da82e66d +436, 0x5d8833c9483b235d +437, 0xf5c72d4883bed9a2 +438, 0x2a6e27d1ed337134 +439, 0xfba250d6b9cc0d2b +440, 0x432f8734b61e4366 +441, 0x45e8becd5ccb4f32 +442, 0xffc7d68cb343170a +443, 0x247cb9a6b29b1a35 +444, 0x89876df3681dc65 +445, 0xd1e646c49aac769b +446, 0x4c3cd721635602d0 +447, 0x5139344709c749fc +448, 0xc5130d981e1a6b14 +449, 0xff269bea082608cb +450, 0xf45a5d57a6d4c6a6 +451, 0xc4c9f3e5398db827 +452, 0x2b3a0eacd42665b4 +453, 0x94d847d848a8e65d +454, 0x1a8aff186e1d75d2 +455, 0x6ad986366c54a242 +456, 0xbd832c0607523e7e +457, 0x973064c20c31842d +458, 0x34d0513e6d602f80 +459, 0x91b3c812f83392ed +460, 0x4c49ba38b6a4cf90 +461, 0x82e3370e1c5ad5d4 +462, 0xa29a01fa53250a13 +463, 0xbe8ed1e615a1ee6a +464, 0x17fb15941a9fe6b4 +465, 0x84aea1c0138fb970 +466, 0xab065efb4558003d +467, 0x3345b340257a2551 +468, 0xfd2ebda1048c0dcd +469, 0x2aa72fce0cb23982 +470, 0x9952f9363830ff6d +471, 0xdb240e279cb7f901 +472, 0xb4a1e7b54206aca4 +473, 0xe13bdbb980623f25 +474, 0xd989f009368f8a9a +475, 0x7084b7695149660d +476, 0x55b92a3f139c7f1 +477, 0xdb43c75c633debd0 +478, 0x94e362574c70b9a8 +479, 0x218a1a06d9223f9b +480, 0x82f3c3808f86bb95 +481, 0x63e9de6cee4b77b2 +482, 0x3bc5effa36bb166 +483, 0x8369cbe5fa0ecab +484, 0x2a5808b4d7bc8572 +485, 0x6856e29700de99f5 +486, 0x107e86fcfd4a48d9 +487, 0x15c9ee6528c1c223 +488, 0xbf7318d4206c5e75 +489, 0x15d7a6aa9343c9e8 +490, 0x93419fe0ee3bd5df +491, 0x916c7f75ededdd53 +492, 0xe89d6230690f74f1 +493, 0xf92f96834e0eb27 +494, 0xed5adc06c305adc9 +495, 0xf656fe40e7ecb4d7 +496, 0x32a2d3eda46114b6 +497, 0xb3f17867d23c75e2 +498, 0x2a2cc838c4d89c33 +499, 0x413df7052f8866e7 +500, 0x373bd93e91bbed18 +501, 0x78c8e5aa1e1e2dda +502, 0x6bd362f6be6d572b +503, 0xba1926efd387aeb5 +504, 0x3b826b77ae3e53fd +505, 0x383cf5a66fb6723c +506, 0xf5a4e1dded64d931 +507, 0x76d9843a304729d3 +508, 0x205b8753b6d309f0 +509, 0xd2a68ef67d8e7758 +510, 0x60d517f325411c0c +511, 0x37a3bb4950cf08d5 +512, 0xea3d4f95542ffe2d +513, 0xa88708db07fb1d34 +514, 0xd96555e1194f7ee0 +515, 0xdd046e642b59fa51 +516, 0x18ff34e73582d46b +517, 0x7ed73af03535c5fe +518, 0x8ffd64801d2c5187 +519, 0x7134902903c9cfe2 +520, 0x74fa0b238ad1e1ec +521, 0xa220ff0032395fd5 +522, 0x4ed0a7a2d9c3a064 +523, 0xb02cb878b4c9a04d +524, 0x8437cebea5ae2bec +525, 0xabcc162a0027aefa +526, 0xc8e86ab8f5c09011 +527, 0xc28dfaf764ec07d4 +528, 0xb19127d64ae5db18 +529, 0x857cb1b00ac7fbc7 +530, 0x173a441c4b494aad +531, 0x255af1a4d50952c3 +532, 0x87ff01c7d0139add +533, 0x489b15e4c97cfcde +534, 0xd4abbccecfb67239 +535, 0xa1a2912ad34ac4fb +536, 0x94b7f12e10bf720 +537, 0xdb8840c295333634 +538, 0x5a29aab5b359f2c0 +539, 0x630352d282b695bd +540, 0x399f00854d3fbdf3 +541, 0x19e917e0eb8bf070 +542, 0xa464b4dc93d1fe7d +543, 0xf152d3cdecbd7647 +544, 0x517907b570a6b082 +545, 0xfeb06f4bd978e7bc +546, 0xa22859ad14c0f183 +547, 0x33c11e90be9721e3 +548, 0x8394f642b5a40d7d +549, 0x9525633e7e60ab73 +550, 0xf97401c9b4b96001 +551, 0x3d78ce1ecf900029 +552, 0xa85791d9754a2765 +553, 0x16e77aadd9a30946 +554, 0xc91d4defe72f39f2 +555, 0x2fb67bd91edc4b51 +556, 0x95d635e95b468fa7 +557, 0x28b81869d1739e29 +558, 0x5b098fa22cb1747f +559, 0x6544b8704bd2400a +560, 0x91a64f9ec6e93245 +561, 0x2b46ba92268db263 +562, 0xbb52d7758efd5416 +563, 0x7032adc08e6d39da +564, 0xe9d3bbefdb61feb6 +565, 0x2d603389c757996b +566, 0x5871ed32ce17d042 +567, 0x31d622a6b8438f70 +568, 0xc71af17db6bf7aed +569, 0xe419e3c6fbe86530 +570, 0x648471d670f18dcd +571, 0xd13f9e25078599ed +572, 0xdaf86e56826d07a3 +573, 0x3c9374e4420a8580 +574, 0xcd75b12ad6d8d9fe +575, 0x2d4530f6e2b93ca3 +576, 0x303bb663ad4ca963 +577, 0xf8caecede4436b61 +578, 0x315a8124669a907f +579, 0x1c18d130a4b93836 +580, 0x9e0b83663631562a +581, 0x400059c1ce071c7f +582, 0xb27f7f67e7cbd970 +583, 0x6b446e8c4866f3d0 +584, 0x4ab1755d2734121c +585, 0xb9fc8e017d89edf2 +586, 0x3a9aa7f50355c0c9 +587, 0x899fece06a169b2e +588, 0x19d7d7088db0b27d +589, 0xe4f8862ca8f6b87e +590, 0xceaf0d6ab4ba624d +591, 0x318965c56f79886d +592, 0xb1840d9bb60b720e +593, 0x387427e7549150ca +594, 0x9be3edb621a5d2ef +595, 0x9758993cca6a481 +596, 0x3733c5cd48a1590c +597, 0x9bbe26951c666fb1 +598, 0x74c7e89fefb4ba59 +599, 0x6aa490a23907053f +600, 0xa62febef1e8d7300 +601, 0xdbfb07bbba2fd4cd +602, 0x11ee9e4bbd4f358 +603, 0x6b40912657c7f02f +604, 0x8d56c1a9216714bb +605, 0x7fcd86985949c2f9 +606, 0x706bb172d5677f2c +607, 0xfb657efea1331957 +608, 0x6e3032f72a3fe367 +609, 0x509fb8c5b618a18e +610, 0x3599e957259222e7 +611, 0xaafc78bea53c9102 +612, 0x404addaf7ac55279 +613, 0x97db28b3b0a2dddc +614, 0xd3f5b151a9f5aefb +615, 0x1a6534a9be80a19a +616, 0x78f989eb80e055b7 +617, 0xe0200fe015112dce +618, 0xfbe67decef6204dd +619, 0x662fef92c8e00970 +620, 0x9a7838962250f5d7 +621, 0xac0eabb1621567b3 +622, 0x1874cf715cdc5daa +623, 0xd3281a25a82ceecc +624, 0xd8ac0e497b11156c +625, 0x3c8bf98f8210af89 +626, 0x971973ff9d428a3f +627, 0x1af47276bc157e63 +628, 0x671cd5e661ed0a05 +629, 0x71b8ffba9b976a0 +630, 0x8763f1fa85c5f5d5 +631, 0x61f3c56f3441aad4 +632, 0x86482f5e90362e3c +633, 0x8e9d9aceba401c48 +634, 0x51d916579d19d42b +635, 0x67bdfa28310ad3c7 +636, 0xb9ab819d6a00add8 +637, 0xaa12cb0ed2d507bf +638, 0xc636190dfc7f6d43 +639, 0xf3f1e6c104c5e782 +640, 0xaed0be2f07ad4313 +641, 0x1d782d74661278bf +642, 0x58e6501bc7e61fa2 +643, 0x8ca4ad0e02d7fb42 +644, 0x8afc9e9fe83d4b78 +645, 0x72cb69cf4abf0b1d +646, 0x7601a7b3500d474d +647, 0x97fee7da53b533b0 +648, 0xd6ab646f53c0e19a +649, 0x6480f60992f2fcc0 +650, 0x64ec7590c60a4c00 +651, 0x3ccab37f11acbe91 +652, 0x9ddd546f201299fd +653, 0x9a0dc59d0b545d96 +654, 0x8c5f366bd21664f5 +655, 0xc0af97b445bfc5ee +656, 0x29762536dc00c3fc +657, 0xfc30927fd8f1c257 +658, 0xac9aadfced7d59fb +659, 0x8d039f87658a29cd +660, 0x13a3d73580eacf6f +661, 0x80b80e0adcc11ac5 +662, 0x1e53c21e639f9d08 +663, 0x8a73352dc442bca7 +664, 0xec7cb2fe0e6b0100 +665, 0xfa5e63f403ac3f33 +666, 0x493d9a0018185f8c +667, 0x1b1d1f41c6cf5cb4 +668, 0x95b4caca3e2500a7 +669, 0x4e759e6f89f62f91 +670, 0xd0a76a3198d7c05f +671, 0x86eee6259cab63b5 +672, 0x1daab21067011b59 +673, 0xd02d9236ebc91b38 +674, 0x693e17ac2b70e1b7 +675, 0xceb5899aa14d0f86 +676, 0x59ffc317faf17ab2 +677, 0xce94f02892a0fa30 +678, 0xf7c9d6f9e753737c +679, 0x87258cf7ff6a29b5 +680, 0xb39fc8ea8aa52a0e +681, 0xadd4b4e73af1103f +682, 0x511f423730b25a4e +683, 0x7f673288e53502b2 +684, 0x9aa499e3b6295919 +685, 0x83841ad95e6a7a6 +686, 0x6e549a2457a850c +687, 0x4763220b923113c3 +688, 0x99737bb550aa5049 +689, 0x89eb31b3f707c4 +690, 0xdad5331dda8a58d3 +691, 0x5f1681518d5a21b8 +692, 0x258a0b9b24110918 +693, 0x8854bb025009fa21 +694, 0x7ac331fd885642af +695, 0xe520f0e9bedf0bf6 +696, 0xc9419e8801aa2afb +697, 0x356fdc0fc3702b37 +698, 0x6d6a25f39fbc9524 +699, 0x930f65c4dbf8ae94 +700, 0xa73d7bbf8c19c4b3 +701, 0xe473f700513139fa +702, 0xfef8f0e84c521bae +703, 0x88525351995576a7 +704, 0xa156b646ab95f272 +705, 0x1a46ff3b9ae7e723 +706, 0xf6d82b8bd9f2a80 +707, 0x837b8127d8f39ebf +708, 0x1f8e120ea11fc9bb +709, 0xbd0918421430f8c9 +710, 0x4ef121a688d130c7 +711, 0x3fef66f1cf180b77 +712, 0xa92070bdc6a0100 +713, 0x2444dcbb4853c174 +714, 0xe46b7d6234504df8 +715, 0xe5ac8fd968a5d1fd +716, 0x988828d885f04f30 +717, 0x9730c37b69f3d963 +718, 0xdb9a0d16bf0a2aab +719, 0xe75d00b3681941b9 +720, 0x518421d62db82da0 +721, 0x4da04c94268c1dae +722, 0xdcf2635a55b7da9e +723, 0xb679d8206c55a04c +724, 0x1fbf58865fec1e83 +725, 0x53ca7cc07c0e5785 +726, 0xd18eee3f5b57c813 +727, 0x9fc8d328e41d1299 +728, 0xb2231521e026e15 +729, 0x1a7e2a8df269acde +730, 0xe5f547b160b0a6de +731, 0xab01e7130bd70c14 +732, 0x82a051680f661a75 +733, 0x479da77dd9686ca2 +734, 0x1417cc197738b272 +735, 0xb65b5ced585a8186 +736, 0x40b5a74813e7a05b +737, 0x55481e0f404fc2c5 +738, 0xef1ca09a2640c44a +739, 0xa0f1d37ee2db47cf +740, 0xcabb0c8e551f0587 +741, 0x84227dd83ad941ef +742, 0x7b47691b6e8327d +743, 0x4fe615394f53d6d2 +744, 0x60bca7e568f65c80 +745, 0x8676b74f2d5600f4 +746, 0x70f256171f1eb9b1 +747, 0x6b1d25099f80e1fd +748, 0xd8e77e8a67ff3338 +749, 0x3ec375feb7727aca +750, 0x26b9ad4afd4be26b +751, 0x849e6f9bc5ec636 +752, 0xa34e3fad187c089f +753, 0xe369ba87f04ecc37 +754, 0x83c6e1c3985cab4e +755, 0x6ffc032379a15336 +756, 0x654645504b159afc +757, 0xabc97562087edfad +758, 0x4633765a9f068fe5 +759, 0xa226c586394d348b +760, 0x7034d9fd40133a22 +761, 0x89e1d142a1a20097 +762, 0x7a3e1387a5ecdf70 +763, 0xf0ae75084f0a1bc4 +764, 0xdcf97778ae782977 +765, 0x87996a44dbac128d +766, 0x94b102ac15479072 +767, 0x9d670a01e10c48a0 +768, 0x8f977a03176d0cb1 +769, 0x8522bdbed25653c +770, 0x8f2b64a9cd6b5483 +771, 0x86b2beaa71c92fbc +772, 0x40f896707639f820 +773, 0x40e7df1535fc03ad +774, 0x1d34c491e13debde +775, 0x862d5ad393292476 +776, 0xd33ee4efdd4b14d9 +777, 0x63ce5c7643b85ecd +778, 0xd28a7fe0700fd15 +779, 0x8c3536390f9b7b55 +780, 0xfaf87a9036dd0265 +781, 0x187e261c23b454a5 +782, 0x95362150f08e5f86 +783, 0x6588c21939d9521d +784, 0xc7cee242280b7526 +785, 0xc1b8f83462038485 +786, 0x68c2f342724de8d6 +787, 0x35c283dbca3c62fd +788, 0x556c441e9fdc5cee +789, 0x898ba42c4ad3f5ba +790, 0xc654a072fe9ce540 +791, 0xcc2da7cabdc658d4 +792, 0x518b6badf9c1ba7 +793, 0xd43b259427de48cd +794, 0xfe7e74d4415bea8a +795, 0xdee4cacb454d92c +796, 0xdfb09dde6d6c3000 +797, 0x5c0d4ce2c7a8d426 +798, 0x29ccf2d288f4de4a +799, 0x4106e7f40d2597ad +800, 0x3bc376950bccf69 +801, 0x65b74e149d1066e3 +802, 0x751d008e4f823e5e +803, 0x4a3b9a34d8ece205 +804, 0x372e79ed6d9461fc +805, 0x78e08cab6244f8d2 +806, 0x7d273315b6d9250b +807, 0x26c401cb05f556b2 +808, 0x3324d95fbc93408d +809, 0x14fb55fb83ab0a8a +810, 0x7ea7efcddd0a747f +811, 0x150a110bd5cb1b57 +812, 0x1122b31f5d20ad23 +813, 0xbd996a43507da1 +814, 0x6d11fad057e5a75a +815, 0x22a4d3223d77684b +816, 0x349973b5dda3d3e8 +817, 0xe4dab5aec267e32d +818, 0x371cbd61bbb7858c +819, 0x7e49182abfc0fc68 +820, 0x937722b126a7d173 +821, 0x29604490ccbe6611 +822, 0x6c8b230bdcc8dfaa +823, 0xb1c267c94d4550ee +824, 0x80d1fa6e33cde91f +825, 0xe205a132f35af0a7 +826, 0xe4e8e50899fea5c8 +827, 0x3a6517d09206dfef +828, 0xeff4e4f8efd0a4ba +829, 0xd8df88c992b3df74 +830, 0x5b0df3c40071c0ac +831, 0xd44a062781f833f0 +832, 0xef35653edcb68251 +833, 0x21f879df2bd3cfe0 +834, 0xdb5e837565891932 +835, 0x6da15316efae41e7 +836, 0xd33cdc0d05f8dd6d +837, 0x3c6588502a24be1c +838, 0x3d25da26bee94818 +839, 0x79979979960d383d +840, 0x8a20663424f816ec +841, 0x74c587d5824ee15 +842, 0x145f90c6b342c489 +843, 0xe2c2d15b8de95387 +844, 0xd9deaecc24e84ede +845, 0xce52add2f5c3ea3 +846, 0xd1da2db8cca0014d +847, 0xcbeed544f8791232 +848, 0xb55b421de003edf0 +849, 0xde102a5a87a9a5da +850, 0xd74fc9d34c964bd3 +851, 0xda7e1e271d197070 +852, 0x1167b33a6bad0d13 +853, 0xd35c886fd0e28798 +854, 0xfb3334085bbcef67 +855, 0x88f4957ddc912f99 +856, 0x7c1b0e356835cffa +857, 0x8c737bc009bf5a1c +858, 0x44edc242bfd88b0f +859, 0x391f8b5db15f8b01 +860, 0xd44794c8a4245701 +861, 0xefa90e38ba4a2f6e +862, 0x597f65c886e697b4 +863, 0x28972f6be3ca8677 +864, 0x18a487b5e89a9dbb +865, 0xffb15ebcb8a15fb1 +866, 0xa1f64108b7feeab0 +867, 0x36fc88b440612004 +868, 0x72a723294ba9af87 +869, 0x1a38da0ff8f187d7 +870, 0x529d7f6cd18f664a +871, 0x6a5941953b4732c7 +872, 0xe91243bd8fb27a03 +873, 0xb80c55de03262828 +874, 0xacb9183e5b28a8d0 +875, 0x4c4ca12eb3d5d2e5 +876, 0x758635a20eb18211 +877, 0x211e03e90d6bd001 +878, 0xe36e20fbf0f271b5 +879, 0x4daecb676fc64ebd +880, 0x8f1e82c4dd582eb7 +881, 0x6e3c35a21bca1b8f +882, 0xf3c2a69420f159e8 +883, 0x2cda4d630caba89f +884, 0x4c93f3f96360d308 +885, 0x4192046fb5e9d801 +886, 0x349f2b172f49599c +887, 0x7bbff8dd8b480e6c +888, 0x83b33fafc4388bf +889, 0x9a5440f806d9d1b +890, 0x8d6b62101dcfe51f +891, 0xbc7dd6987af227ca +892, 0x4338e67e0d6ba6a0 +893, 0x4a23deabbb5fc3ce +894, 0x9f8edc91e6356eb8 +895, 0xf6b723dd2dd5f80b +896, 0x35c558dd3443021d +897, 0xa559dd33c2cf594d +898, 0xa50ceeced7a82783 +899, 0x21107b581db4ee9f +900, 0x13e8dd9302e8c97d +901, 0xbd8491f437e57ad6 +902, 0x72f4c2a57c06f35f +903, 0x518fbb95071d8d7d +904, 0xcdbbe8d47f9b13e9 +905, 0xe8152b0f387251cd +906, 0x411070a4f345676 +907, 0xc589c285b962389 +908, 0x8b0eb9e285844319 +909, 0xe2b007f446a21b38 +910, 0x868ffafb958a6c40 +911, 0x19ccccd559408de0 +912, 0xa7666f366db0ae71 +913, 0xd78c5f137da6dbc2 +914, 0xeeecc913fdb9af03 +915, 0x7a5afb2f3d54a396 +916, 0x64fadf73d7ba200b +917, 0xaa1b82c6b4b346aa +918, 0x9a312d9482244a60 +919, 0xadb3c0a30f68d0f4 +920, 0x21eee75a717008c1 +921, 0xcda2779023f54837 +922, 0xea3c577c6d7783e2 +923, 0xdaae89efcd431a13 +924, 0x9a6102d2dafaded8 +925, 0xd29443448e01734e +926, 0x6b968e58c3d5bcd0 +927, 0x13949d0c5c0f9d19 +928, 0x7053eef909932489 +929, 0x49fb97e33c279171 +930, 0xc955e4854e254d03 +931, 0x3300cb752a7834fd +932, 0x8319585b09da0928 +933, 0xd35c64e4ce23a294 +934, 0x9a41d980ba1774dd +935, 0xff570729be1f3f02 +936, 0x3f68ae1c3e690a41 +937, 0x6f58a3e861159e42 +938, 0x111d9975e94f0004 +939, 0x276d3ea0ff1ca6c +940, 0x4209cb1f5ca1c594 +941, 0x71699dc4c58f1bcf +942, 0xe0288bffc5a27a2e +943, 0x6c0962c36163c4f5 +944, 0x3a8ad088b4fd204f +945, 0xb945dc7721092d36 +946, 0x315f4c1738bdf365 +947, 0xe07ddd7121cafb70 +948, 0x626fadaee66f331e +949, 0x6fe3f71dd5e7ebe1 +950, 0xe3cfb6b53bd8713c +951, 0x30f5b732f7070968 +952, 0xce2f941f93b957f2 +953, 0x116897bad7f55bca +954, 0xb9d2c4a98826c3ff +955, 0x9672c28485d1c95c +956, 0xd0656535c3df1e44 +957, 0x15294f18a999528d +958, 0x82a98977ad1e933a +959, 0xddd17b6eeced5f84 +960, 0x9901a04270fa2d5c +961, 0xcd2a8d3ab69a0c62 +962, 0x706bf86127a4597b +963, 0xe614aa96ed708afb +964, 0x7f6361ae8f59987 +965, 0x6a355657b59c4874 +966, 0x5211dca87f30cdd +967, 0xa21cbbc602f58ee4 +968, 0x68dff176c9b02a7b +969, 0x68f89bb7bca83c5a +970, 0x229cb884febc7e56 +971, 0xce4f300cf6b70884 +972, 0x6ad3f343c76c5e0c +973, 0xb059a099f121222e +974, 0x9e990641d81a63b8 +975, 0x5564e79afe160ecb +976, 0x2a9fa9c590511dcb +977, 0xca36751ba40931da +978, 0x23a332a9fe1104aa +979, 0xdfe116c321547662 +980, 0xf484bfbe18f2c1cf +981, 0xf8f2b4adf2d1ad4 +982, 0x4308800511929ba +983, 0xe2773c41e0082a51 +984, 0x6b74adc21bac6b3a +985, 0x1faa6a3704bd1b66 +986, 0x89e3e641298e87cd +987, 0xcb2f118548abcdc3 +988, 0x690e34dfb4153ab9 +989, 0x103d668edb5f7e88 +990, 0xb29d9f22b3b1d4a4 +991, 0xc4ce3be9022b314d +992, 0x1cb3d5af1306da15 +993, 0x8236da372d964cce +994, 0x79188ac299f06c2b +995, 0x953dfd978aad2545 +996, 0x6058e1066e7285cd +997, 0xf47307b50589e391 +998, 0x2923873ecd9c4d32 +999, 0x4c44d61328ac5e4a diff --git a/numpy/random/tests/data/pcg64-testset-2.csv b/numpy/random/tests/data/pcg64-testset-2.csv new file mode 100644 index 000000000..779761d0f --- /dev/null +++ b/numpy/random/tests/data/pcg64-testset-2.csv @@ -0,0 +1,1001 @@ +seed, 0x0 +0, 0xd4feb4e5a4bcfe09 +1, 0xe85a7fe071b026e6 +2, 0x3a5b9037fe928c11 +3, 0x7b044380d100f216 +4, 0x1c7850a6b6d83e6a +5, 0x240b82fcc04f0926 +6, 0x7e43df85bf9fba26 +7, 0x43adf3380b1fe129 +8, 0x3f0fb307287219c +9, 0x781f4b84f42a2df +10, 0x36dac886f4232c6f +11, 0xa32006a96a8d46b +12, 0xa56e609a788ce098 +13, 0x75711678fa371144 +14, 0xbcdd4619fa063896 +15, 0x5cb5c9a1594f1a04 +16, 0x799e6cc7d09bf3fd +17, 0xda1a4b52f72a8c6f +18, 0x374b6f698c864e48 +19, 0x96a3e4d45b8d252d +20, 0x5fc89e7cbf7735e4 +21, 0xe0cfe37beef7efe6 +22, 0xc3467c95f4649808 +23, 0x95cbda6a3275f18a +24, 0x3a4dc1e59bdb4172 +25, 0x47f8755023ac78b5 +26, 0xef8e166bf07dfa95 +27, 0x40065cf0fa99882d +28, 0xbaa083ad70102eb6 +29, 0x7c88e9d1a72a8dc +30, 0x1484e44aa83e901e +31, 0xf0f8df78086fdeba +32, 0x5114e38e0cff505d +33, 0x7e04bb9a2828c944 +34, 0xb88c0de9e2af5658 +35, 0xecba992ca7e9178d +36, 0x8b40b65347cfeffb +37, 0xfce9281a9381a55f +38, 0xfde34f9f228fc03f +39, 0x8c46656aa79eba9d +40, 0x1ed0d3f416073189 +41, 0xd7adcc20a26d48d1 +42, 0x2429dcfa355eddba +43, 0xec100f2285aaad68 +44, 0x91a83984506e1ef4 +45, 0x4c10c0f973e3cba5 +46, 0x45d0d0ad9ab6890e +47, 0xa52b22d88ddb6090 +48, 0x63f7e7549bf80c43 +49, 0xfb03f87e5ea7137d +50, 0x822f96594246a4aa +51, 0x42242b1335cd3424 +52, 0xf78652fc51ec76ac +53, 0x24db7314bda69cc5 +54, 0xcce4cf66737c8427 +55, 0xffd70eeca33ed90f +56, 0xc154aff2caddd546 +57, 0x59d47a8ccd59e1bb +58, 0xabf793045ca561f8 +59, 0x3f1486708729b21d +60, 0x76ed98409f3f9abe +61, 0x3f0bb2cd7cedd012 +62, 0x448f78da1713ac85 +63, 0xddbae7151c1578b2 +64, 0xcf94237ec0973cd7 +65, 0x76a0657cedebac81 +66, 0x2b13b564bed7a3b3 +67, 0x47a6fc0f4604c781 +68, 0x22acf016523ae80f +69, 0xf728771b939c13a2 +70, 0xab4aee3986c80ec8 +71, 0x61d8c8c918b3fe52 +72, 0x7a40380c747f9044 +73, 0xfaf974af2e96a882 +74, 0xb8bd56d90c69d42c +75, 0x7cea307dda515497 +76, 0x56d0858a27ded2a3 +77, 0x8717ea17698706b7 +78, 0x6b34d0c0587e8867 +79, 0x387a8142ee80d29a +80, 0xbba414cee59e3194 +81, 0x6d2fe8bec0e51a8 +82, 0x11d5dc961ba15ec5 +83, 0x7af1ae07932b2fb8 +84, 0xb13ea6b28d63b57e +85, 0x7e89a6f060cf59c5 +86, 0xad1f662c4daa4764 +87, 0x929a054dec3e229f +88, 0xf7f41c2a34920f09 +89, 0xf0eac1b75822b72b +90, 0x24f311773d90d399 +91, 0x9c2147da3d098c17 +92, 0xa62963f5bb0f8b9e +93, 0x97f650195285e480 +94, 0x602433fd24fe4125 +95, 0x6f17d6e3b5fd704c +96, 0x3ad6f2cf0ffd6a04 +97, 0x73a6d93edf693e03 +98, 0x467d4e6fecdfdb20 +99, 0x6aadbba2b2f8a2f8 +100, 0xc865bae9d8713526 +101, 0xa94d7c6b462e5acc +102, 0xdcbb47fdacd4d865 +103, 0x80aa6a71fd60cb40 +104, 0xf27ad62910288223 +105, 0x88f93784d309825c +106, 0xf7f9a500b821c886 +107, 0x6cd6e37a5dca4830 +108, 0x57694853b9c75561 +109, 0x9c7ef1aa6b8f2c1 +110, 0x12046439309d6e40 +111, 0xee3d652c43bd35b9 +112, 0x3838110676b26d7a +113, 0x9efd697137fa24c9 +114, 0x1eeaa149a7edd5be +115, 0x17eb32cd212e374a +116, 0x73dd5b7d7fd3b280 +117, 0x788e514de9649f29 +118, 0x6e2fb96fbf87fe8b +119, 0xc736a34c7ea74137 +120, 0xa4d48bb7df0e3c51 +121, 0x25b66ee78063d37f +122, 0x9058e087b9696e7 +123, 0xa2e6397ebdd3d935 +124, 0x394a16ba856e6899 +125, 0xe4aad4f1bc61d046 +126, 0x5e4904686af5c43 +127, 0x4e58956c61a1880a +128, 0x7328c827d6236eff +129, 0x29463809b511cf73 +130, 0xceb2c403cef62247 +131, 0x9ccc00f358aa8346 +132, 0x6fdc1c42421ba33 +133, 0x1111d660460f5300 +134, 0x97a4f922e55a9226 +135, 0xbc2a217152bfbc63 +136, 0x3617700c68d104d9 +137, 0x8eecc63c4a929622 +138, 0xc69cf9d8f8b45df3 +139, 0xa2a8ca8262f8921b +140, 0x4339edf9e292f9e0 +141, 0xfe385e2e7f6e1a1a +142, 0x5f30d1b803abc1d9 +143, 0xf123207050238c3c +144, 0x79e3401200b54b1a +145, 0x858d7ce163d4de92 +146, 0x5803a44cd013b965 +147, 0x17c65b0b01800940 +148, 0xc50b38bb58dcb3c7 +149, 0xe476e9925898603 +150, 0x3972fb0fa748a3a5 +151, 0x93da971efb1036f7 +152, 0x658bab8ef6082bf2 +153, 0xf664abd0de92444f +154, 0xa2145e8039e61d87 +155, 0x28af5560cb0ee0ac +156, 0xc1e43e6a30cefef6 +157, 0x74f61d623cc6965e +158, 0x3ee0139a07b6c130 +159, 0x214992e8a6134c54 +160, 0xaa83b771c9421231 +161, 0x15487762c93cf5c6 +162, 0xa3d37b883fffdfe8 +163, 0xe398d2bd15c1c511 +164, 0x3154f894aedd5938 +165, 0xc7ed5190721ec2b5 +166, 0xca02cf8dcfef83b4 +167, 0xa22c6a2e5460e0f3 +168, 0x2d72e4d264875109 +169, 0xf282e30c8b945616 +170, 0xa1a286624feece2e +171, 0x6f773be8548d3fe +172, 0x8c6dc6f48c83c30f +173, 0x13dc5926122501a1 +174, 0x5537f3d25d126e0d +175, 0xdb654b8409365aa5 +176, 0x55d8f727e066e818 +177, 0x534841122140f9a3 +178, 0x4e4ecc7b2ce8efa0 +179, 0x3655d535028e4044 +180, 0x6c2ad71379f15365 +181, 0xd1f1238395ce193c +182, 0x4ecd9ccc56595a72 +183, 0x3304220c15b60f7a +184, 0x3726fecf394006bf +185, 0x4523e03e39a92ac1 +186, 0x191c97036c0e20a8 +187, 0xbfbcf849ecc37cd5 +188, 0x3c6090d256b1c780 +189, 0xf7e94dd0d3e02fd8 +190, 0x83034fb1c17bb99f +191, 0xa7be8e0eb37c9260 +192, 0x177d2c560b0b55af +193, 0x55da4c839514e82e +194, 0xc9b393b79b0e7617 +195, 0xe9658403d3a140 +196, 0xc86401b988be38e7 +197, 0xe82baf54ee5df9e1 +198, 0x3a562e6572a853a4 +199, 0xcb83facbed1cb364 +200, 0x4db406f08ea62242 +201, 0x9cc816f5376ab97a +202, 0xe65a32f96a78b09 +203, 0x59e7b42c496e2c2f +204, 0x7e3e59a4546b6b33 +205, 0xc51a371516d5adc4 +206, 0x19ba384285a523ca +207, 0x5b998f71002a0912 +208, 0x81ee2f95f53dbce1 +209, 0x966a0c0bbf15492e +210, 0x80f88202ff2d29c2 +211, 0xf827f45274e32733 +212, 0x66a2611b73547490 +213, 0x1b2c3c3ae80997d0 +214, 0x264a86e09c63e4c9 +215, 0x35d4bf9c9d0d89a2 +216, 0x6051e319babb305f +217, 0xdf0d08608262be49 +218, 0xbe7aa9a7697278c2 +219, 0xac531985f79fca17 +220, 0x7ce7de0d95ba34d +221, 0x9a03956d30de1ee0 +222, 0x8106a5873e7950b0 +223, 0x804c06b1fab989fc +224, 0x20d5fe19357e95dd +225, 0xf3e89c08d1841c79 +226, 0xfc93b079bdb323cb +227, 0x8f6eb1dea40eda88 +228, 0x6e7f6b657f6d971e +229, 0xf2b15bb03a49e9bf +230, 0xcf7fed1aff1786b +231, 0xe53366adc5bafe42 +232, 0x89b853ed67fc2387 +233, 0xd13dadf3828f1df7 +234, 0x2f884ffbb83075b9 +235, 0x8efd2baea4771d71 +236, 0x7872e80c946c6bce +237, 0xcc487bc4ea869070 +238, 0x820609347e4fdd75 +239, 0xe939e3c63701a997 +240, 0xf70ed361e42164e9 +241, 0xa9f29046fce9ba8d +242, 0x61edfa750175e868 +243, 0xb7d2424653bde389 +244, 0xdadd225205e74ef4 +245, 0xecfb9a633ee3c774 +246, 0xcbc69459f0634f30 +247, 0xdbcd82538e0785e2 +248, 0x2b272f59ad36e01c +249, 0x601a38897a57cc68 +250, 0xfa012b9e5722d8be +251, 0x5bce8d48277d7338 +252, 0xd1b6ca2b93483dc2 +253, 0x8b94eceb88f55be9 +254, 0x93403aea5df5da18 +255, 0x57b6fcaf351c16b8 +256, 0x70f5e54095404bd8 +257, 0x9124d47160362770 +258, 0x987ed72af8aa305d +259, 0x71e3a8d5156f82c7 +260, 0xf788e966e86f7004 +261, 0xcf0cd5911c4bb0e1 +262, 0x3340b119d3e2f28f +263, 0x9952106be6e3bf95 +264, 0x99a6213e19fe9d1a +265, 0x4f0d3811a8a5d481 +266, 0x62d732ee5f975dd2 +267, 0x3abc8340ab323ebd +268, 0x15da761a2518c843 +269, 0xb453de7d4d15b261 +270, 0x4adc2d7cc2cc0049 +271, 0xcc9b7fa135c7dba4 +272, 0xa14857a738db2b52 +273, 0xce036b49e28c19c7 +274, 0xaee7e9fde421bd4c +275, 0x15dd298915099a9e +276, 0xa3fa6550b639b66b +277, 0x5f27c59b035a6532 +278, 0x2eef2e6292288715 +279, 0xabd211c514e3699e +280, 0x6d7bf9b33f8b09e5 +281, 0x91ff83561361c170 +282, 0x8f8e309797a91e4f +283, 0x2b11ef1cedf1036b +284, 0x6fc36ed305d27972 +285, 0x7e294e03a91eb01f +286, 0xbe16009d8b2f38a4 +287, 0x2bf69c7b54e60cea +288, 0x860079a07fade829 +289, 0x8f0ce6ae4c90d38a +290, 0xab10e5f8ab4835fc +291, 0x49ed43ddd4ca0a76 +292, 0x201eaa53b6df058c +293, 0x2d9a4fdb16f6c1c +294, 0xd3406193e1dd0760 +295, 0xad38857b542ddb6a +296, 0x52ec1e450363aad8 +297, 0x6e65469594331886 +298, 0x4b027ce344dd6660 +299, 0xbc801654b4a1ccad +300, 0x155be4bc51328b2c +301, 0xa9a1965f9b2b5bdb +302, 0x386b8dc34de0889 +303, 0xd60ee4b1b9cbb057 +304, 0x6c1e60b6914c4876 +305, 0xd07bf84dc30bf653 +306, 0x362d5b19b3f4f7e9 +307, 0xd145b8fef9a6a3d2 +308, 0x5c401126b505dd09 +309, 0x8f5d1d4446f9cb4c +310, 0x725618359f1a3e38 +311, 0xaedad9cf455de2e5 +312, 0x7f7e4e549b4bde1b +313, 0x35002b8e995f815 +314, 0x9aecaf8f393cade0 +315, 0xf346a49595886d86 +316, 0x459d5a9e92e9c149 +317, 0x60885682c3d6ff0d +318, 0x90f5e985e08bfc3d +319, 0xbf413a432e1a1b81 +320, 0x789503524aa48aa9 +321, 0x7880e5bb484bd49e +322, 0x7426535c324b7176 +323, 0x190ad37f84acba3 +324, 0xbd52510631d4f5d7 +325, 0x98f794ad565c986d +326, 0xa0ea374e66c0bf56 +327, 0xd683fe7102145335 +328, 0x9b3dac61db2f2930 +329, 0x470d31e3096c2450 +330, 0x1f445f8292f6f3dd +331, 0x1687ff432def56a7 +332, 0x887d4e6617525278 +333, 0xcd81ce8cc70b13ff +334, 0xaadbc4c3525c18e1 +335, 0x96d81490c362b621 +336, 0x128b95092e36796c +337, 0xffeffbed0980cdb7 +338, 0x3bcef6c52b36d07a +339, 0x400879c888eeabe2 +340, 0x373c9978059787d +341, 0x35979fef9e20050a +342, 0xf4581367f3fc43b +343, 0xcec7b91352ed0186 +344, 0xa7b06e92b765203 +345, 0x6713f0b11fb9f296 +346, 0x95c53b86deafbd95 +347, 0x3694844a5eca42df +348, 0xd0f334ea2c650574 +349, 0x5ae6771044110ddf +350, 0x9f61d9087e7d36e5 +351, 0x28f04e48625e3e5e +352, 0x6164d6b5445cf130 +353, 0xa36b5c2de27084be +354, 0xa099a43d5c5f21bb +355, 0x706edfb05fbe8b9e +356, 0x7aacffffc81ebc3b +357, 0x6f49121baebd0e6a +358, 0x41fda7ba6df8f4cb +359, 0x1bea4b596dbac5ac +360, 0x71dd0261d65b02c6 +361, 0xad7f50624c15e9c9 +362, 0xf7c4eeb84d4866b6 +363, 0xa5e23dd382f48bdb +364, 0xe6ffdf875d534bfa +365, 0x40104d8444f75a7c +366, 0x8218a42f24a88364 +367, 0x9d3f9382759cae86 +368, 0x101d7adffbd9ebde +369, 0xf9fe3578d6b739dd +370, 0xd23c47039e882eb2 +371, 0x37fc4fff590191b3 +372, 0x2a672fc8cd3e0cf7 +373, 0x995b8faabb4332c7 +374, 0xabc6117aa665a743 +375, 0x3fc49d11869352ea +376, 0x4ccc3cfa9540797f +377, 0x111c57f059fa3ef4 +378, 0x44a737bac79496bd +379, 0x37924823edfe0774 +380, 0xa4d8ee07ab241d02 +381, 0xbb0bf46c50f349ac +382, 0x4db0a8506e22199c +383, 0x93239f377c85ba51 +384, 0x56f51e3970e409f5 +385, 0xe82d51ebc177609e +386, 0xec866d8b473eaeb +387, 0x42f8018bb955abed +388, 0xf58ba8a916b04fa1 +389, 0xf12d2f0cb0a41cff +390, 0x8102b5f91923cc2a +391, 0x91d95fcb9cb1346d +392, 0x819ccf0d122537ac +393, 0x34646b1c3f9a8527 +394, 0x4a3a7df812ff79cb +395, 0xc3d0b50ed434ad24 +396, 0x3e6cd372b453b5f0 +397, 0x39101f6226c43c8c +398, 0xff41e5b6b7ff540c +399, 0x1e8d77bc3f12e0f4 +400, 0x748d0860be568eee +401, 0x5baac1f743bfeff3 +402, 0x8bdbd895b2eed2d8 +403, 0x5d3a01fa82bd88d4 +404, 0x577271d2de3e06f4 +405, 0xd4fccaeb0db61acb +406, 0xa088377ed2b1d841 +407, 0x6f2e9e1566f37b5b +408, 0xb8d85eef688c049a +409, 0x6b7c06c55078761 +410, 0x223cd94cad1e0c32 +411, 0xbf27c193ae5881e3 +412, 0x5b784893a36d57dc +413, 0xdc9fa53968c262dd +414, 0xd7e820c76855fb61 +415, 0x72260eb94f096e2a +416, 0x49144b5732ca1b94 +417, 0xba8d85a47582d428 +418, 0x558abe242dc84de2 +419, 0xc27b1d54557b9de5 +420, 0x80c1f06559385330 +421, 0x4a5c1d4252675c73 +422, 0x225e3a9f7b2da067 +423, 0x9ac95bac9d2234a1 +424, 0x696e500589e0e490 +425, 0xd0fe548d81c82185 +426, 0x68d8b783037b4743 +427, 0xbe1664f1a8d814f +428, 0x2304308b691ca712 +429, 0x68e680af6b7189c5 +430, 0x13abe6c989949072 +431, 0x4c209f5029a59d0b +432, 0x63361139df6fea7a +433, 0xf07c52d8272cbdb +434, 0x665023146f27fa7 +435, 0x7cb535c55ad7ad0e +436, 0x76e366c7317eb1b0 +437, 0xa7d9b80b51585e9b +438, 0x85f0bd60122198b9 +439, 0x34bc89d7e7827fd5 +440, 0xdfa1167988c85807 +441, 0xe78f45588bfdba02 +442, 0x172a023eba7357b2 +443, 0x7bc4c79e06ea755b +444, 0x8aace6120b766b95 +445, 0x17b43a5a81b0db26 +446, 0xbc2b95819d959ff6 +447, 0x1b8841f2fe9c4622 +448, 0xc094a747ec30d67a +449, 0xf5b93ec01484b937 +450, 0x659bbe8bdfd43f01 +451, 0x9d96c22bcf9c64c9 +452, 0xcf7df324fba052ec +453, 0x5e4acd4f9e048e0b +454, 0xe3a0e7e9869c5dd2 +455, 0x4eb444727e1c346e +456, 0x7f6cda1ca7b3eb67 +457, 0x72fccac63ca649e9 +458, 0x711bfbf79a093651 +459, 0x5d48599fae7fd6a3 +460, 0xcc640119a296b34e +461, 0x39acfb198b2b439 +462, 0xde759b50e2db66f9 +463, 0xe83bf8363827e06 +464, 0x484d50365017de87 +465, 0x4c3b5dbacd68394b +466, 0xbbe47788c079218c +467, 0xd44099290c25fe62 +468, 0x3b7d1bd6f91f3857 +469, 0xe7366a677d2b7eb3 +470, 0xfaa770590b197910 +471, 0x610b7a2fe8c4e80e +472, 0x13451e1bf520a796 +473, 0x7e3d18c47e821077 +474, 0x8fd3a77c86eb9804 +475, 0xf24be740c87eadab +476, 0xd5a52e6d0b58345 +477, 0xae386b5ca037a8d +478, 0xb59fd16baf160f26 +479, 0xd4a05b473f6e0a8a +480, 0x47ede6678c2c6420 +481, 0x8851ed397da6f850 +482, 0x1de775cdb392d89b +483, 0x74e6c8ec9513ea38 +484, 0x30ae39e04187a984 +485, 0x614cfd09d043d601 +486, 0x3e0173138f562ee1 +487, 0x822d415a26bdba96 +488, 0x432f6dec77edd9a8 +489, 0x47a3a179627546b8 +490, 0x845dd7ffb1fe6d78 +491, 0x9778d5782de13a48 +492, 0x760198319b3cacce +493, 0x420ee262d07dd7c +494, 0x847c7424c365df20 +495, 0x56b3b590fb83ba16 +496, 0x7cd2410390a3e797 +497, 0xbb0c21b47aab8857 +498, 0x2743883e70a36a18 +499, 0xff8b29cdc75ebb7 +500, 0xe1e04a0f0379686f +501, 0xcfdf3083b792f281 +502, 0x27392ca026b55e88 +503, 0xeeb195994fd56abb +504, 0x7cf210041345882c +505, 0x3ddca2b8951fea4e +506, 0x21c89d88a3833996 +507, 0xe7128bccc4b25c9b +508, 0xe39b0fb96a4c05ae +509, 0xedf5326550594554 +510, 0x4aa45fe66b575558 +511, 0x2799fc8d3b06f777 +512, 0x2824863087187501 +513, 0xa15fa00818118906 +514, 0x559fc9e9344a310 +515, 0x1682745f8d571671 +516, 0x80b54f29f47a28d0 +517, 0x38e28103ffd9f771 +518, 0xedb5f440dab80945 +519, 0xdb0b8d04cece6091 +520, 0x1f60a7cae5ae8412 +521, 0x6719c0405e92b31d +522, 0x56752def7d642302 +523, 0xa5b0900f93c352dd +524, 0x5b82baf53be8983d +525, 0x7726202ccee5cbb6 +526, 0x1641c84c7f87a765 +527, 0x835ae1a82be4265e +528, 0x5f9ccee69c1d9da +529, 0x3e2a2228e21039b7 +530, 0xa45873582866d005 +531, 0x7fbeffc99401e59e +532, 0xcf66a6a974057890 +533, 0xd53704a96af96fd +534, 0x1a8b5e3460704b64 +535, 0x6939b27bb32ba451 +536, 0x3c39293e637a0115 +537, 0x335a6e6b779b8c4e +538, 0x75235d767dfd3d00 +539, 0xbdf0b36936b17c90 +540, 0x982dc5e4915a3a3a +541, 0x74657ac256407f55 +542, 0x603a724457b796b6 +543, 0xf178694f7a3f98bd +544, 0xe712de12db2aba47 +545, 0x1ca272d99a3355d8 +546, 0x93e7054d3e8dafc7 +547, 0xa29597810eff04c1 +548, 0xade242c0ae4bcea3 +549, 0xbcd226e2bd9d0e64 +550, 0x2e02e5736f889a +551, 0x3622dc09f5fdd576 +552, 0x6e66bd2a10d78705 +553, 0x71d8f19110d5b4d0 +554, 0xacae934ab3d759f0 +555, 0x68d670d5f9272132 +556, 0x571fb09d082e7da7 +557, 0x154540c51b7d8b33 +558, 0x1e2f3710c0b6890 +559, 0xaf26a826ef444b30 +560, 0x9fc9fdbd9342be72 +561, 0x9b33b306d22a35e0 +562, 0xb6d5895f56d4197b +563, 0x92fef06c1353b2e3 +564, 0x804e3eb42e65b938 +565, 0x73d5cd4bb7270902 +566, 0x274b8ac4925da8fd +567, 0xa9a57999f5df2e2f +568, 0xa6000be059e088b +569, 0x57de4fc48c9e9e84 +570, 0x16727392e94ee9bf +571, 0x53c9032f62848c4d +572, 0x8a8ddd8fcf0676dd +573, 0x1436de7c1735087 +574, 0xfa93b7d1425e8667 +575, 0xec34ca5f3f84bb2f +576, 0x489ed44d0880c4c8 +577, 0xb3b6051de7a6f740 +578, 0x2f303cb0f4040f11 +579, 0x302c42a6adbcbcb2 +580, 0x28ed7b87695cd600 +581, 0xee78d3b782a2fcd0 +582, 0xc47a2441a1082032 +583, 0xec9965704a044f33 +584, 0xcb1563e968460dc +585, 0xfecbb4fa2b544f93 +586, 0x3f3d7437a6d29a3d +587, 0xe4bfaccd729414ca +588, 0xb741ed954572d172 +589, 0xf34b49bf10ae47b6 +590, 0x1fbd1f068f1b796d +591, 0xc1d556e64345b226 +592, 0x85bbfa50a899c7be +593, 0x5310045dcf0fea8 +594, 0xbc6f6fb7f00e5960 +595, 0xf8bdf4074f2b5f5e +596, 0x2a5817aa122dc97f +597, 0x6d5ef86d6b8ad0ce +598, 0x96e7ccc235abb79e +599, 0x8d531c4cea492f66 +600, 0xfc124a123b4ce02a +601, 0xc6087ffd9130c2ca +602, 0x3a724c46f0f06175 +603, 0x59980713cfe4fe92 +604, 0xecde418e64a11bd +605, 0x5c9b333a0f0337cc +606, 0xcf014d508fc8e83a +607, 0x83998bb2aa4e16ba +608, 0xde8f5167ac0a40d9 +609, 0xe93b1846914c0dc7 +610, 0x668831ca8fd50c25 +611, 0xec764b87e402c28e +612, 0xd0e1303e56f6b268 +613, 0xa6b9f3c4872dbcd5 +614, 0x12a89c116ad924f0 +615, 0x23857c375ae928c8 +616, 0x29b117f63f2e8c1b +617, 0x64ff6cce272aa46d +618, 0xd40fb15b38d59f70 +619, 0x6e5a6257c4cc0c66 +620, 0x7b54845e6e119a4e +621, 0x9d88bf3dd9fa0f0e +622, 0xb6687fd4980a5d43 +623, 0x4f2e3fef88b640b8 +624, 0xf07ac2f7e2df40fa +625, 0x24059bd0ecb6c6a9 +626, 0x6204a47cbd57453d +627, 0x8477fd1a13ea9678 +628, 0x4555083f5eada49f +629, 0x352443e5d984691c +630, 0x3e904f796a9c5ffa +631, 0x11e182bc43754609 +632, 0x608cdbe03699a5d4 +633, 0x2619146efbf59f0 +634, 0x9b852370063940ee +635, 0xa1d8e7e91e42a52b +636, 0x19179affce38fa3c +637, 0xf68ff1ccce70380c +638, 0x12103cb41741ab38 +639, 0xdca7902fa6d960b2 +640, 0xad46a2fc70025445 +641, 0xac92f0b2d150d716 +642, 0x5de115babb43326e +643, 0xf335366fd69e4bcd +644, 0xe9aecd1f88889cd +645, 0xbce60087987b51d1 +646, 0xcfd395a167103939 +647, 0x2fdcb12826ac806c +648, 0xbd5129970869ccd6 +649, 0x5e922b68030c2698 +650, 0x7ada02a56d17779a +651, 0x7a1254c652b99ccc +652, 0x8be78733623db772 +653, 0xc22439789b68f0a8 +654, 0xee51ad4ab1a9a6ed +655, 0x44b15fa27694d9be +656, 0xc5b93e6c57805153 +657, 0xcf03df495c283a89 +658, 0x5c2a41954bb44bb +659, 0x9e651cb8c650dd +660, 0x73a20ee82570d4a8 +661, 0x5f805cab085e971f +662, 0x5354410872a8f587 +663, 0x1b50ef4e9519338d +664, 0xdeb873412301a1ce +665, 0x3a286bb2f5f8db39 +666, 0xad117a0d4dc7f82e +667, 0xdd880d581169d989 +668, 0x8356be106382a704 +669, 0x7c684ad93e996ff3 +670, 0x6b2d09e61ac02c11 +671, 0x99ad8c074fe046dc +672, 0x4a9b4f0e7c4ffa24 +673, 0x38afdcb5893b466 +674, 0x7ad58ef97c3d35c +675, 0xdd7c17c0d67ab69 +676, 0x61c77caf27938c86 +677, 0x978fc491080c0cee +678, 0x4c1750f8684c1ca4 +679, 0x86b4c683d5fe657e +680, 0x720e2bd8ec76cffc +681, 0x73ca52b4a7dd3b85 +682, 0xeb10a691e12ea3ca +683, 0x90355e369297b259 +684, 0x6c6bc16f639678ca +685, 0xd989f4c724f8fba7 +686, 0xbb1ba7e2ca1c4391 +687, 0x81e4194500a0d267 +688, 0xbb25489c1dcbf93f +689, 0x74d26b75e9f57fd +690, 0x59c085fa99b6493d +691, 0x3359805b0fc3fef9 +692, 0x60ef0f3a85e60650 +693, 0xf1a3692c8591e8d6 +694, 0xd7c8d2e7f3d3546e +695, 0xe8fc8518c11ca881 +696, 0x3380ef12114d1818 +697, 0x87203c98ff21fcaf +698, 0xbc37f8e034002ef8 +699, 0x891b7c3f55d02300 +700, 0x814eec8ff8956f0a +701, 0xa370639852acceae +702, 0x6c566310b6b00f15 +703, 0xd69fe78b9c8a05a6 +704, 0xb7b0df518738419e +705, 0x2a0c1185b29ed965 +706, 0x636c841214c0a8cf +707, 0xbf56297859e9bb72 +708, 0x2b5b9d432d6d008f +709, 0x1ea586cf0f86f542 +710, 0x23a2a1af76cbc988 +711, 0x6c72c799b6ed93f3 +712, 0x2266785315f3bb13 +713, 0xb68cd6e87b94065a +714, 0x5d395704514bb808 +715, 0x334bde59d526ee4 +716, 0xc5a6d87f96f055fa +717, 0xd47001378b4dcf08 +718, 0x7305818a39057557 +719, 0x8f72c128eac6d32 +720, 0x4957ed799339bbdc +721, 0xeb47d505f61dd5fa +722, 0x8ce8817cd6acc93a +723, 0x84ef66e511a52f35 +724, 0xbf5aa34bbaef7e1f +725, 0xadaa5ba2a5ee660e +726, 0x6eec8ac924058eea +727, 0x8af63be4d1a1b202 +728, 0x88eccf85fd9fce32 +729, 0xf19a1122f394af05 +730, 0x8dcd15d1c14f5077 +731, 0x6c0f2e6135e36545 +732, 0xe58f89bec4d929c8 +733, 0x4eea88221d983ef9 +734, 0x51ae3956d53e1a80 +735, 0x40d8a172bf713bb6 +736, 0x3e33536e43ad4fa2 +737, 0xeff9938a179138fa +738, 0x3e372bff1f51df8b +739, 0x59b86a407817c86c +740, 0x947164c2c57f9bd8 +741, 0xd8e67bb799d84475 +742, 0x4d9ed254d8189595 +743, 0xa021d8d181328996 +744, 0xc703e402f8e4688b +745, 0xd1eb104c970dd5fe +746, 0xd5bf4683b9337f8e +747, 0x98f405a2d998f06 +748, 0x59c734ddd208e85c +749, 0xbd167be2d43fde24 +750, 0x70602daab163fbe2 +751, 0xeb2f2b37cbfe13e7 +752, 0x28baa8f3fc4c4666 +753, 0xe212ffe352ea5ce6 +754, 0x538b93d2285eda3a +755, 0x3a9482ac69a39e1b +756, 0x3a98983ed4367767 +757, 0x1dc851c69e35d601 +758, 0xac7f83e4b02e9bb8 +759, 0xa939f99c5615ef7b +760, 0x439437f129076339 +761, 0x79a251bb1d50ce25 +762, 0xaa7b6ff8f13a7424 +763, 0x1b244bd86404327b +764, 0xc84d99185ab2a7d6 +765, 0xf6dcde975493c40b +766, 0xdee46f4346cf6af +767, 0x739b75df1fe18712 +768, 0x3d05cb298311f3e9 +769, 0x1fba9d9c10dc7780 +770, 0x31637fc416267053 +771, 0x46694e36246b8be2 +772, 0x8c67095ae6eaf1e4 +773, 0xebe2a68c27963dca +774, 0x532d344b14306cf2 +775, 0x6a847c8f3ae2ac92 +776, 0x8034bcb5a50cbd6a +777, 0x7544766784261059 +778, 0xe641799652df63ca +779, 0xd8cacad7099c07de +780, 0x429e62da116e4876 +781, 0x4442c8b57a5b7ef5 +782, 0xa7ea9c348cbeebaa +783, 0xce1a34f57bb2a7fa +784, 0xbb29ef457c9509cc +785, 0x1ba1030b19a32c1c +786, 0x412d1eb07cee79b8 +787, 0x3627dd37c6b36848 +788, 0x45432b319f26a2a9 +789, 0xb9a12e188cee2a29 +790, 0xeee69e0f1b1efd66 +791, 0xd4ccd61bc3fb8837 +792, 0x1b600476917cbf62 +793, 0x522950ddce26c142 +794, 0x956d8a5dbe9aa431 +795, 0x31cfba73bb524b7d +796, 0xc3b709a56885a6ac +797, 0x7341d4e32fffcdf8 +798, 0x5ed87c5315e4775 +799, 0x60fa512183e3dad5 +800, 0x4df6df14e9c2935f +801, 0xdec2dc983ab42a9 +802, 0x28265e213fd6de41 +803, 0x2f85d825454add06 +804, 0xf18119191ac41aa +805, 0xf870e36e83f4face +806, 0x2a4b213d973d83c8 +807, 0x2c7094cde18ba8ec +808, 0xb5998e0a1914446b +809, 0xefcb960ff010503a +810, 0xa8d928b99104aef5 +811, 0xe7a6893116e383a8 +812, 0x552dbe180a51b6c9 +813, 0x16b73f3832c9990c +814, 0xfefee9504783e187 +815, 0xc12d3aa0c1f8608b +816, 0xd5232106c7adea7e +817, 0xb207e82667fb71ed +818, 0xe93c50ef54a791cf +819, 0x3099900fdf7b1750 +820, 0xaa2a46c352132ad0 +821, 0xf2414daa174335e4 +822, 0x33080f98c42bbad2 +823, 0x9df24fe0b5b13394 +824, 0x840eedf2eec5fdb6 +825, 0x3715e262efbc907d +826, 0xa70a8cccfbe8a11f +827, 0x4a57a6f16ea4c9f3 +828, 0xe03dbe2f1493e9e1 +829, 0xbd92759a7becd4e4 +830, 0x21a3d87c3766887e +831, 0x6414f570caa74ef1 +832, 0x4e27490fc3fc0234 +833, 0xd4c40310c6ab2eba +834, 0xfbe8acd168ffd62d +835, 0x30b19992f1975ac8 +836, 0xaf93d22a8561f631 +837, 0x4574ebab81bed3b1 +838, 0x5390c6026e3940c7 +839, 0x7a5154d076a8b504 +840, 0x9676f2495f742943 +841, 0x8cfdb9e11bdb4502 +842, 0x36af5c8754d9ca17 +843, 0x61477e76367296ee +844, 0xd6f5f40f66acc700 +845, 0xe62c2462e96af1b8 +846, 0x18029746ac09ef3e +847, 0x871bbe15da7e0176 +848, 0x2443e806f54d179 +849, 0x9103af1634f9d0ac +850, 0xe6e5358eaa0efa2b +851, 0xdff4859198244a67 +852, 0x6e48c357be6042b +853, 0x6bb9e8aeb24d656a +854, 0x1b89fbb05f8438cb +855, 0xe0cea835b4db045d +856, 0x4eafe5c195e29d47 +857, 0xd2f0a452be9163f0 +858, 0xa7ae1d0eee928fe6 +859, 0x42c7a26c82a062c4 +860, 0xa8e93bcd89c5704e +861, 0x73784be379f09c34 +862, 0x91f8e599342d013f +863, 0x79c20bc462215ccc +864, 0x6ee77bc91b3753a6 +865, 0xd2c116d1eb2650d0 +866, 0x388f9767cfe30ebe +867, 0xdde5d5966815e7ae +868, 0x459b838c87ca1dec +869, 0xdf96cdb2bc916a60 +870, 0x215c4195b935d5ca +871, 0x56c9f516528598e5 +872, 0x1d8492a9923640f3 +873, 0x97830ac45234686f +874, 0x67f75117a7c952bb +875, 0xf1939dc69391e65d +876, 0xfc44bb1162cb2868 +877, 0x92b33d9df8fc6925 +878, 0x6c4496920de0d558 +879, 0xa4616bb101e924aa +880, 0xa0afc9701ad83cdb +881, 0x62d555323b0494d2 +882, 0xf18b31447a2dfdc3 +883, 0xb2ece318c128d4f3 +884, 0x29efea45a76b9b8f +885, 0xae05362b365d9cd2 +886, 0x5c4d374ce6aefb44 +887, 0xb9cdc65eec94136e +888, 0xf0212f42e3d4f5dc +889, 0xcde7c5085f95d8d8 +890, 0x9cc3799673a644e8 +891, 0xf878d89199bead01 +892, 0xab684fb9666abf61 +893, 0x3070d399b7a07d3d +894, 0x6d8c51673eeeef73 +895, 0x9bf4062ff5471832 +896, 0x92774cd03c511d00 +897, 0xc1aad7c6980df547 +898, 0x3291e3a234d50cc0 +899, 0x75645079bbe9d34a +900, 0x7f28bab9eba28fae +901, 0xa84415684ed6d765 +902, 0x56d9d67653cd172 +903, 0xa7bfed939db93e91 +904, 0x92940e5162d50470 +905, 0xcd6bf601e08f07a9 +906, 0x2ea9104d785e35cb +907, 0xd771ddd541649214 +908, 0x352554afbf9258d +909, 0x9d855486b77c5bc3 +910, 0xdb03cd71e906e1df +911, 0x7c2621690aabc265 +912, 0x1dd4ac7369a04640 +913, 0x57796cbc93d4d854 +914, 0x42a373d152eca785 +915, 0xbe7389edb8b144d3 +916, 0x8b6245bf01d2e4df +917, 0xacd1f9fcca317652 +918, 0x84545ac79a3eb960 +919, 0x2d2f28e6a8459db3 +920, 0x42b3a2e26ddeccdd +921, 0xe858272777abcef6 +922, 0xd9b5be7340dec08d +923, 0xe991af3579ac4fb6 +924, 0x7c30699b349fa6c1 +925, 0xbb842be14f7b5b9a +926, 0x1d31e1ca791a1cf0 +927, 0xf2bd448ebb878bc0 +928, 0x26a6adf6709863cb +929, 0xb11aa978539e3a34 +930, 0xce554a11bbbedd1d +931, 0x553d3c012682a47b +932, 0xb3c90ed36715903 +933, 0xda3c5c706e39e395 +934, 0x4e7f66006d583c2a +935, 0x6424190e9d28ca3a +936, 0x9916685e7384f3bf +937, 0x1285e17347eb806d +938, 0x877f10baf13e6659 +939, 0x222700ed5086438d +940, 0xd2473d08396634b8 +941, 0xb6b68f3bc883a77d +942, 0x168a489b0b7f5f63 +943, 0xee34dcf1f93ad3fa +944, 0xd25ef824f614f65a +945, 0xe30981905354f477 +946, 0x9463ef623c5eb3f8 +947, 0x46657408ea66980d +948, 0xa2e58d51d6e8e7f9 +949, 0xd80d7df3007e9845 +950, 0xd90fa96f4fc0f7aa +951, 0xd2a6059d171bbb33 +952, 0xb8bacb8f11c65c2d +953, 0x401de84b6a8b1ac +954, 0xf8b6eed644c802d9 +955, 0x30c927749fdd8e6 +956, 0x17c2f4f9c4524e16 +957, 0xa9c677daae4acc7e +958, 0x82c78d9c6b10446f +959, 0x5e544188277da629 +960, 0x7c6e1bd3b861dcd7 +961, 0xd4b00871a7f67d0d +962, 0x6b66ee142821e6d5 +963, 0x176d5e39f3b22474 +964, 0x58ea746f62acf933 +965, 0xc61fabd9961c3a51 +966, 0xb27ce0f87b416e3d +967, 0xd3c82b525b000e70 +968, 0x99578704fb3ff4e4 +969, 0x747da52468875493 +970, 0x5c5bfab7a474465b +971, 0xd82276bdb30e3dbd +972, 0x1d758772eebffe2 +973, 0xfed9d1e3ca887a6e +974, 0x23dd5f7b3ff9472b +975, 0xae2e842b51c9c598 +976, 0xe851bc45531123d7 +977, 0x1a18d2777151c29 +978, 0x9e82f3be14b12a48 +979, 0xdf9fdb3abc3e72cf +980, 0xdbea56e918ccb176 +981, 0x47abbd896eb0ca1a +982, 0xe850ee3cef9334dd +983, 0x3d69fe95275e7f2e +984, 0x4fcb936c048d8812 +985, 0xc98f0f6bb9865a99 +986, 0xc951cdb73514709 +987, 0x3ca839c27ca26de9 +988, 0x1478848a311f9cc5 +989, 0x35d2244064967478 +990, 0xe71df2d9732ffdc0 +991, 0xa12417d7b7b9e0ce +992, 0xa1bb6da3f284f77c +993, 0xf551e1c3171575eb +994, 0x16083ac8a062747d +995, 0x866d6c3a630fd4da +996, 0x8a972ff46b3c5c4c +997, 0x70af3b475e4a3d5d +998, 0x2c143fd5c01d9cf5 +999, 0x68089ffadc8ea2b9 diff --git a/numpy/random/tests/test_direct.py b/numpy/random/tests/test_direct.py index 7c6091254..794a895b8 100644 --- a/numpy/random/tests/test_direct.py +++ b/numpy/random/tests/test_direct.py @@ -8,7 +8,7 @@ from numpy.testing import (assert_equal, assert_allclose, assert_array_equal, import pytest from numpy.random import (Generator, MT19937, DSFMT, ThreeFry, - Philox, Xoshiro256, Xoshiro512, RandomState) + PCG32, PCG64, Philox, Xoshiro256, Xoshiro512, RandomState) from numpy.random.common import interface try: @@ -386,6 +386,56 @@ class TestPhilox(Base): assert_state_equal(bit_generator.state, keyed.state) + +class TestPCG64(Base): + @classmethod + def setup_class(cls): + cls.bit_generator = PCG64 + cls.bits = 64 + cls.dtype = np.uint64 + cls.data1 = cls._read_csv(join(pwd, './data/pcg64-testset-1.csv')) + cls.data2 = cls._read_csv(join(pwd, './data/pcg64-testset-2.csv')) + cls.seed_error_type = TypeError + cls.invalid_seed_types = [(np.array([1, 2]),), (3.2,), + (None, np.zeros(1))] + cls.invalid_seed_values = [(-1,), (2 ** 129 + 1,), (None, -1), + (None, 2 ** 129 + 1)] + + def test_seed_float_array(self): + rs = Generator(self.bit_generator(*self.data1['seed'])) + assert_raises(self.seed_error_type, rs.bit_generator.seed, + np.array([np.pi])) + assert_raises(self.seed_error_type, rs.bit_generator.seed, + np.array([-np.pi])) + assert_raises(self.seed_error_type, rs.bit_generator.seed, + np.array([np.pi, -np.pi])) + assert_raises(self.seed_error_type, rs.bit_generator.seed, + np.array([0, np.pi])) + assert_raises(self.seed_error_type, rs.bit_generator.seed, [np.pi]) + assert_raises(self.seed_error_type, rs.bit_generator.seed, [0, np.pi]) + + def test_seed_out_of_range_array(self): + rs = Generator(self.bit_generator(*self.data1['seed'])) + assert_raises(self.seed_error_type, rs.bit_generator.seed, + [2 ** (2 * self.bits + 1)]) + assert_raises(self.seed_error_type, rs.bit_generator.seed, [-1]) + + +class TestPCG32(TestPCG64): + @classmethod + def setup_class(cls): + cls.bit_generator = PCG32 + cls.bits = 32 + cls.dtype = np.uint32 + cls.data1 = cls._read_csv(join(pwd, './data/pcg32-testset-1.csv')) + cls.data2 = cls._read_csv(join(pwd, './data/pcg32-testset-2.csv')) + cls.seed_error_type = TypeError + cls.invalid_seed_types = [(np.array([1, 2]),), (3.2,), + (None, np.zeros(1))] + cls.invalid_seed_values = [(-1,), (2 ** 129 + 1,), (None, -1), + (None, 2 ** 129 + 1)] + + class TestMT19937(Base): @classmethod def setup_class(cls): diff --git a/numpy/random/tests/test_smoke.py b/numpy/random/tests/test_smoke.py index d5a0c38a5..a53956193 100644 --- a/numpy/random/tests/test_smoke.py +++ b/numpy/random/tests/test_smoke.py @@ -9,7 +9,7 @@ import pytest from numpy.testing import (assert_almost_equal, assert_equal, assert_, assert_array_equal, suppress_warnings) from numpy.random import (Generator, MT19937, DSFMT, ThreeFry, - Philox, Xoshiro256, Xoshiro512, entropy) + PCG32, PCG64, Philox, Xoshiro256, Xoshiro512, entropy) @pytest.fixture(scope='module', @@ -841,3 +841,53 @@ class TestEntropy(object): time.sleep(0.1) e2 = entropy.random_entropy(source='fallback') assert_((e1 != e2)) + + +class TestPCG64(RNG): + @classmethod + def setup_class(cls): + cls.bit_generator = PCG64 + cls.advance = 2 ** 96 + 2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1 + cls.seed = [2 ** 96 + 2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1, + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.rg = Generator(cls.bit_generator(*cls.seed)) + cls.initial_state = cls.rg.bit_generator.state + cls.seed_vector_bits = None + cls._extra_setup() + + def test_seed_array_error(self): + # GH #82 for error type changes + if self.seed_vector_bits == 32: + out_of_bounds = 2 ** 32 + else: + out_of_bounds = 2 ** 64 + + seed = -1 + with pytest.raises(ValueError): + self.rg.bit_generator.seed(seed) + + error_type = ValueError if self.seed_vector_bits else TypeError + seed = np.array([-1], dtype=np.int32) + with pytest.raises(error_type): + self.rg.bit_generator.seed(seed) + + seed = np.array([1, 2, 3, -5], dtype=np.int32) + with pytest.raises(error_type): + self.rg.bit_generator.seed(seed) + + seed = np.array([1, 2, 3, out_of_bounds]) + with pytest.raises(error_type): + self.rg.bit_generator.seed(seed) + + +class TestPCG32(TestPCG64): + @classmethod + def setup_class(cls): + cls.bit_generator = PCG32 + cls.advance = 2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1 + cls.seed = [2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1, + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.rg = Generator(cls.bit_generator(*cls.seed)) + cls.initial_state = cls.rg.bit_generator.state + cls.seed_vector_bits = None + cls._extra_setup() diff --git a/numpy/random/xoshiro256.pyx b/numpy/random/xoshiro256.pyx index 380d04af7..9c44328ff 100644 --- a/numpy/random/xoshiro256.pyx +++ b/numpy/random/xoshiro256.pyx @@ -3,7 +3,6 @@ try: except ImportError: from dummy_threading import Lock -from libc.string cimport memcpy from cpython.pycapsule cimport PyCapsule_New import numpy as np @@ -202,7 +201,7 @@ cdef class Xoshiro256: Seed the generator. - This method is called at initialized. It can be called again to + This method is called at initialization. It can be called again to re-seed the generator. Parameters diff --git a/numpy/random/xoshiro512.pyx b/numpy/random/xoshiro512.pyx index 91b0ce51b..27c26486a 100644 --- a/numpy/random/xoshiro512.pyx +++ b/numpy/random/xoshiro512.pyx @@ -203,7 +203,7 @@ cdef class Xoshiro512: Seed the generator. - This method is called at initialized. It can be called again to + This method is called at initialization. It can be called again to re-seed the generator. Parameters |