diff options
author | Kevin Sheppard <kevin.k.sheppard@gmail.com> | 2019-05-23 15:28:22 +0100 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2019-05-27 22:58:35 +0300 |
commit | dabf42be29208a59bbacffd40d9d8dca6e200f49 (patch) | |
tree | 929ddc66702b257a8ffa372939d38bb42c041414 /numpy/random/src | |
parent | 7c52c2810e20a9e483e564751b8e2342c97f56c2 (diff) | |
download | numpy-dabf42be29208a59bbacffd40d9d8dca6e200f49.tar.gz |
MAINT: Remove remnants of bit generators
Remove traces of the three removed bit generators
Add lock to Cython examples
Diffstat (limited to 'numpy/random/src')
-rw-r--r-- | numpy/random/src/xoroshiro128/LICENSE.md | 9 | ||||
-rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128-benchmark.c | 35 | ||||
-rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128-test-data-gen.c | 83 | ||||
-rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128.c | 60 | ||||
-rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128.h | 53 | ||||
-rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128plus.orig.c | 102 | ||||
-rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128plus.orig.h | 5 | ||||
-rw-r--r-- | numpy/random/src/xorshift1024/LICENSE.md | 9 | ||||
-rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024-benchmark.c | 35 | ||||
-rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024-test-data-gen.c | 74 | ||||
-rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024.c | 32 | ||||
-rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024.h | 40 | ||||
-rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024.orig.c | 68 | ||||
-rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024.orig.h | 7 |
14 files changed, 0 insertions, 612 deletions
diff --git a/numpy/random/src/xoroshiro128/LICENSE.md b/numpy/random/src/xoroshiro128/LICENSE.md deleted file mode 100644 index 969430149..000000000 --- a/numpy/random/src/xoroshiro128/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -# XOROSHIRO128 - -Written in 2016 by David Blackman and Sebastiano Vigna (vigna@acm.org) - -To the extent possible under law, the author has dedicated all copyright -and related and neighboring rights to this software to the public domain -worldwide. This software is distributed without any warranty. - -See <http://creativecommons.org/publicdomain/zero/1.0/>.
\ No newline at end of file diff --git a/numpy/random/src/xoroshiro128/xoroshiro128-benchmark.c b/numpy/random/src/xoroshiro128/xoroshiro128-benchmark.c deleted file mode 100644 index 9a7b52bfb..000000000 --- a/numpy/random/src/xoroshiro128/xoroshiro128-benchmark.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * cl xoroshiro128-benchmark.c xoroshiro128plus.orig.c \ - * ../splitmix64/splitmix64.c /Ox - * - * gcc -O3 xoroshiro128-benchmark.c xoroshiro128plus.orig.c \ - * ../splitmix64/splitmix64.c -o xoroshiro128-benchmark - * - */ -#include "../splitmix64/splitmix64.h" -#include "xoroshiro128plus.orig.h" -#include <inttypes.h> -#include <stdio.h> -#include <time.h> - -#define N 1000000000 - -int main() -{ - uint64_t count = 0, sum = 0; - uint64_t seed = 0xDEADBEAF; - s[0] = splitmix64_next(&seed); - s[1] = splitmix64_next(&seed); - int i; - clock_t begin = clock(); - for (i = 0; i < N; i++) - { - sum += next(); - 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/xoroshiro128/xoroshiro128-test-data-gen.c b/numpy/random/src/xoroshiro128/xoroshiro128-test-data-gen.c deleted file mode 100644 index d50e63f5e..000000000 --- a/numpy/random/src/xoroshiro128/xoroshiro128-test-data-gen.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Generate testing csv files - * - * cl xoroshiro128-test-data-gen.c xoroshiro128plus.orig.c / - * ../splitmix64/splitmix64.c /Ox - * xoroshiro128-test-data-gen.exe * - * - * gcc xoroshiro128-test-data-gen.c xoroshiro128plus.orig.c / - * ../splitmix64/splitmix64.c -o xoroshiro128-test-data-gen - * ./xoroshiro128-test-data-gen - * - * Requres the Random123 directory containing header files to be located in the - * same directory (not included). - * - */ - -#include "../splitmix64/splitmix64.h" -#include "xoroshiro128plus.orig.h" -#include <inttypes.h> -#include <stdio.h> - -#define N 1000 - -int main() -{ - uint64_t sum = 0; - uint64_t state, seed = 0xDEADBEAF; - state = seed; - int i; - for (i = 0; i < 2; i++) - { - s[i] = splitmix64_next(&state); - } - uint64_t store[N]; - for (i = 0; i < N; i++) - { - store[i] = next(); - } - - FILE *fp; - fp = fopen("xoroshiro128-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 = state = 0; - for (i = 0; i < 2; i++) - { - s[i] = splitmix64_next(&state); - } - for (i = 0; i < N; i++) - { - store[i] = next(); - } - fp = fopen("xoroshiro128-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/xoroshiro128/xoroshiro128.c b/numpy/random/src/xoroshiro128/xoroshiro128.c deleted file mode 100644 index baefcf3a8..000000000 --- a/numpy/random/src/xoroshiro128/xoroshiro128.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Written in 2016-2018 by David Blackman and Sebastiano Vigna (vigna@acm.org) - -To the extent possible under law, the author has dedicated all copyright -and related and neighboring rights to this software to the public domain -worldwide. This software is distributed without any warranty. - -See <http://creativecommons.org/publicdomain/zero/1.0/>. */ - -/* This is xoroshiro128+ 1.0, our best and fastest small-state generator - for floating-point numbers. We suggest to use its upper bits for - floating-point generation, as it is slightly faster than - xoroshiro128**. It passes all tests we are aware of except for the four - lower bits, which might fail linearity tests (and just those), so if - low linear complexity is not considered an issue (as it is usually the - case) it can be used to generate 64-bit outputs, too; moreover, this - generator has a very mild Hamming-weight dependency making our test - (http://prng.di.unimi.it/hwd.php) fail after 5 TB of output; we believe - this slight bias cannot affect any application. If you are concerned, - use xoroshiro128** or xoshiro256+. - - We suggest to use a sign test to extract a random Boolean value, and - right shifts to extract subsets of bits. - - The state must be seeded so that it is not everywhere zero. If you have - a 64-bit seed, we suggest to seed a splitmix64 generator and use its - output to fill s. - - NOTE: the parameters (a=24, b=16, b=37) of this version give slightly - better results in our test than the 2016 version (a=55, b=14, c=36). -*/ - -#include "xoroshiro128.h" - -extern NPY_INLINE uint64_t xoroshiro128_next64(xoroshiro128_state *state); - -extern NPY_INLINE uint32_t xoroshiro128_next32(xoroshiro128_state *state); - -void xoroshiro128_jump(xoroshiro128_state *state) -{ - int i, b; - uint64_t s0; - uint64_t s1; - static const uint64_t JUMP[] = {0xdf900294d8f554a5, 0x170865df4b3201fc}; - - s0 = 0; - s1 = 0; - for (i = 0; i < sizeof JUMP / sizeof *JUMP; i++) - for (b = 0; b < 64; b++) - { - if (JUMP[i] & UINT64_C(1) << b) - { - s0 ^= state->s[0]; - s1 ^= state->s[1]; - } - xoroshiro128_next(&state->s[0]); - } - - state->s[0] = s0; - state->s[1] = s1; -} diff --git a/numpy/random/src/xoroshiro128/xoroshiro128.h b/numpy/random/src/xoroshiro128/xoroshiro128.h deleted file mode 100644 index 63682776b..000000000 --- a/numpy/random/src/xoroshiro128/xoroshiro128.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _RANDOMDGEN__XOROSHIRO128_H_ -#define _RANDOMDGEN__XOROSHIRO128_H_ - -#include <inttypes.h> -#include "numpy/npy_common.h" - -typedef struct s_xoroshiro128_state -{ - uint64_t s[2]; - int has_uint32; - uint32_t uinteger; -} xoroshiro128_state; - -static NPY_INLINE uint64_t rotl(const uint64_t x, int k) -{ - return (x << k) | (x >> (64 - k)); -} - -static NPY_INLINE uint64_t xoroshiro128_next(uint64_t *s) -{ - const uint64_t s0 = s[0]; - uint64_t s1 = s[1]; - const uint64_t result = s0 + s1; - - s1 ^= s0; - s[0] = rotl(s0, 24) ^ s1 ^ (s1 << 16); // a, b - s[1] = rotl(s1, 37); // c - - return result; -} - -static NPY_INLINE uint64_t xoroshiro128_next64(xoroshiro128_state *state) -{ - return xoroshiro128_next(&state->s[0]); -} - -static NPY_INLINE uint32_t xoroshiro128_next32(xoroshiro128_state *state) -{ - uint64_t next; - if (state->has_uint32) - { - state->has_uint32 = 0; - return state->uinteger; - } - next = xoroshiro128_next(&state->s[0]); - state->has_uint32 = 1; - state->uinteger = (uint32_t)(next >> 32); - return (uint32_t)(next & 0xffffffff); -} - -void xoroshiro128_jump(xoroshiro128_state *state); - -#endif diff --git a/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.c b/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.c deleted file mode 100644 index 1b5f46e4b..000000000 --- a/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Written in 2016-2018 by David Blackman and Sebastiano Vigna (vigna@acm.org) - -To the extent possible under law, the author has dedicated all copyright -and related and neighboring rights to this software to the public domain -worldwide. This software is distributed without any warranty. - -See <http://creativecommons.org/publicdomain/zero/1.0/>. */ - -#include <stdint.h> - -/* This is xoroshiro128+ 1.0, our best and fastest small-state generator - for floating-point numbers. We suggest to use its upper bits for - floating-point generation, as it is slightly faster than - xoroshiro128**. It passes all tests we are aware of except for the four - lower bits, which might fail linearity tests (and just those), so if - low linear complexity is not considered an issue (as it is usually the - case) it can be used to generate 64-bit outputs, too; moreover, this - generator has a very mild Hamming-weight dependency making our test - (http://prng.di.unimi.it/hwd.php) fail after 5 TB of output; we believe - this slight bias cannot affect any application. If you are concerned, - use xoroshiro128** or xoshiro256+. - - We suggest to use a sign test to extract a random Boolean value, and - right shifts to extract subsets of bits. - - The state must be seeded so that it is not everywhere zero. If you have - a 64-bit seed, we suggest to seed a splitmix64 generator and use its - output to fill s. - - NOTE: the parameters (a=24, b=16, b=37) of this version give slightly - better results in our test than the 2016 version (a=55, b=14, c=36). -*/ - -uint64_t s[2]; - -static inline uint64_t rotl(const uint64_t x, int k) -{ - return (x << k) | (x >> (64 - k)); -} - -uint64_t next(void) -{ - const uint64_t s0 = s[0]; - uint64_t s1 = s[1]; - const uint64_t result = s0 + s1; - - s1 ^= s0; - s[0] = rotl(s0, 24) ^ s1 ^ (s1 << 16); // a, b - s[1] = rotl(s1, 37); // c - - return result; -} - -/* This is the jump function for the generator. It is equivalent - to 2^64 calls to next(); it can be used to generate 2^64 - non-overlapping subsequences for parallel computations. */ - -void jump(void) -{ - static const uint64_t JUMP[] = {0xdf900294d8f554a5, 0x170865df4b3201fc}; - - uint64_t s0 = 0; - uint64_t s1 = 0; - for (int i = 0; i < sizeof JUMP / sizeof *JUMP; i++) - for (int b = 0; b < 64; b++) - { - if (JUMP[i] & UINT64_C(1) << b) - { - s0 ^= s[0]; - s1 ^= s[1]; - } - next(); - } - s[0] = s0; - s[1] = s1; -} - -/* This is the long-jump function for the generator. It is equivalent to - 2^96 calls to next(); it can be used to generate 2^32 starting points, - from each of which jump() will generate 2^32 non-overlapping - subsequences for parallel distributed computations. */ - -void long_jump(void) -{ - static const uint64_t LONG_JUMP[] = {0xd2a98b26625eee7b, 0xdddf9b1090aa7ac1}; - - uint64_t s0 = 0; - uint64_t s1 = 0; - for (int i = 0; i < sizeof LONG_JUMP / sizeof *LONG_JUMP; i++) - for (int b = 0; b < 64; b++) - { - if (LONG_JUMP[i] & UINT64_C(1) << b) - { - s0 ^= s[0]; - s1 ^= s[1]; - } - next(); - } - - s[0] = s0; - s[1] = s1; -} diff --git a/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.h b/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.h deleted file mode 100644 index 20c96fe04..000000000 --- a/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.h +++ /dev/null @@ -1,5 +0,0 @@ -#include <stdint.h> - -uint64_t s[2]; -uint64_t next(void); -void jump(void); diff --git a/numpy/random/src/xorshift1024/LICENSE.md b/numpy/random/src/xorshift1024/LICENSE.md deleted file mode 100644 index 3ca8ed4b9..000000000 --- a/numpy/random/src/xorshift1024/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -# XORSHIFT1024 - -Written in 2017 by Sebastiano Vigna (vigna@acm.org) - -To the extent possible under law, the author has dedicated all copyright -and related and neighboring rights to this software to the public domain -worldwide. This software is distributed without any warranty. - -See <http://creativecommons.org/publicdomain/zero/1.0/>.
\ No newline at end of file diff --git a/numpy/random/src/xorshift1024/xorshift1024-benchmark.c b/numpy/random/src/xorshift1024/xorshift1024-benchmark.c deleted file mode 100644 index 0eef33537..000000000 --- a/numpy/random/src/xorshift1024/xorshift1024-benchmark.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * cl xorshift1024-benchmark.c xorshift2014.orig.c - * ../splitmix64/splitmix64.c /Ox - * - * gcc -O3 xorshift1024-benchmark.c xorshift2014.orig.c / - * ../splitmix64/splitmix64.c -o xorshift1024-benchmark - * - */ -#include "../splitmix64/splitmix64.h" -#include "xorshift1024.orig.h" -#include <inttypes.h> -#include <stdio.h> -#include <time.h> - -#define N 1000000000 - -int main() { - uint64_t count = 0, sum = 0; - uint64_t seed = 0xDEADBEAF; - int i; - for (i = 0; i < 16; i++) { - s[i] = splitmix64_next(&seed); - } - p = 0; - clock_t begin = clock(); - for (i = 0; i < N; i++) { - sum += next(); - 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/xorshift1024/xorshift1024-test-data-gen.c b/numpy/random/src/xorshift1024/xorshift1024-test-data-gen.c deleted file mode 100644 index a2ae08df4..000000000 --- a/numpy/random/src/xorshift1024/xorshift1024-test-data-gen.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Generate testing csv files - * - * cl xorshift1024-test-data-gen.c xorshift1024.orig.c / - * ../splitmix64/splitmix64.c /Ox - * xorshift1024-test-data-gen.exe * - * - * gcc xorshift1024-test-data-gen.c xorshift1024.orig.c / - * ../splitmix64/splitmix64.c -o xorshift1024-test-data-gen - * ./xorshift1024-test-data-gen - * - * Requres the Random123 directory containing header files to be located in the - * same directory (not included). - * - */ - -#include "../splitmix64/splitmix64.h" -#include "xorshift1024.orig.h" -#include <inttypes.h> -#include <stdio.h> - -#define N 1000 - -int main() { - uint64_t sum = 0; - uint64_t state, seed = 0xDEADBEAF; - state = seed; - int i; - for (i = 0; i < 16; i++) { - s[i] = splitmix64_next(&state); - } - p = 0; - uint64_t store[N]; - for (i = 0; i < N; i++) { - store[i] = next(); - } - - FILE *fp; - fp = fopen("xorshift1024-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 = state = 0; - for (i = 0; i < 16; i++) { - s[i] = splitmix64_next(&state); - } - p = 0; - for (i = 0; i < N; i++) { - store[i] = next(); - } - fp = fopen("xorshift1024-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/xorshift1024/xorshift1024.c b/numpy/random/src/xorshift1024/xorshift1024.c deleted file mode 100644 index d68ecc7d3..000000000 --- a/numpy/random/src/xorshift1024/xorshift1024.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "xorshift1024.h" - -/* This is the jump function for the generator. It is equivalent - to 2^512 calls to next(); it can be used to generate 2^512 - non-overlapping subsequences for parallel computations. */ - -extern NPY_INLINE uint64_t xorshift1024_next(xorshift1024_state *state); -extern NPY_INLINE uint64_t xorshift1024_next64(xorshift1024_state *state); -extern NPY_INLINE uint32_t xorshift1024_next32(xorshift1024_state *state); - -void xorshift1024_jump(xorshift1024_state *state) { - int i, j, b; - static const uint64_t JUMP[] = { - 0x84242f96eca9c41d, 0xa3c65b8776f96855, 0x5b34a39f070b5837, - 0x4489affce4f31a1e, 0x2ffeeb0a48316f40, 0xdc2d9891fe68c022, - 0x3659132bb12fea70, 0xaac17d8efa43cab8, 0xc4cb815590989b13, - 0x5ee975283d71c93b, 0x691548c86c1bd540, 0x7910c41d10a1e6a5, - 0x0b5fc64563b3e2a8, 0x047f7684e9fc949d, 0xb99181f2d8f685ca, - 0x284600e3f30e38c3}; - - uint64_t t[16] = {0}; - for (i = 0; i < sizeof JUMP / sizeof *JUMP; i++) - for (b = 0; b < 64; b++) { - if (JUMP[i] & UINT64_C(1) << b) - for (j = 0; j < 16; j++) - t[j] ^= state->s[(j + state->p) & 15]; - xorshift1024_next(state); - } - - for (j = 0; j < 16; j++) - state->s[(j + state->p) & 15] = t[j]; -} diff --git a/numpy/random/src/xorshift1024/xorshift1024.h b/numpy/random/src/xorshift1024/xorshift1024.h deleted file mode 100644 index 38ec27430..000000000 --- a/numpy/random/src/xorshift1024/xorshift1024.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _RANDOMDGEN__XORSHIFT1024_H_ -#define _RANDOMDGEN__XORSHIFT1024_H_ - -#include <inttypes.h> -#include "numpy/npy_common.h" - -typedef struct s_xorshift1024_state { - uint64_t s[16]; - int p; - int has_uint32; - uint32_t uinteger; -} xorshift1024_state; - -static NPY_INLINE uint64_t xorshift1024_next(xorshift1024_state *state) { - const uint64_t s0 = state->s[state->p]; - uint64_t s1 = state->s[state->p = ((state->p) + 1) & 15]; - s1 ^= s1 << 31; // a - state->s[state->p] = s1 ^ s0 ^ (s1 >> 11) ^ (s0 >> 30); // b,c - return state->s[state->p] * 0x9e3779b97f4a7c13; -} - -static NPY_INLINE uint64_t xorshift1024_next64(xorshift1024_state *state) { - return xorshift1024_next(state); -} - -static NPY_INLINE uint32_t xorshift1024_next32(xorshift1024_state *state) { - uint64_t next; - if (state->has_uint32) { - state->has_uint32 = 0; - return state->uinteger; - } - next = xorshift1024_next(state); - state->has_uint32 = 1; - state->uinteger = (uint32_t)(next >> 32); - return (uint32_t)(next & 0xffffffff); -} - -void xorshift1024_jump(xorshift1024_state *state); - -#endif diff --git a/numpy/random/src/xorshift1024/xorshift1024.orig.c b/numpy/random/src/xorshift1024/xorshift1024.orig.c deleted file mode 100644 index 03c1c17fe..000000000 --- a/numpy/random/src/xorshift1024/xorshift1024.orig.c +++ /dev/null @@ -1,68 +0,0 @@ -/* Written in 2017 by Sebastiano Vigna (vigna@acm.org) - -To the extent possible under law, the author has dedicated all copyright -and related and neighboring rights to this software to the public domain -worldwide. This software is distributed without any warranty. - -See <http://creativecommons.org/publicdomain/zero/1.0/>. */ - -#include <stdint.h> -#include <string.h> - -/* NOTE: as of 2017-10-08, this generator has a different multiplier (a - fixed-point representation of the golden ratio), which eliminates - linear dependencies from one of the lowest bits. The previous - multiplier was 1181783497276652981 (M_8 in the paper). If you need to - tell apart the two generators, you can refer to this generator as - xorshift1024φ and to the previous one as xorshift1024*M_8. - - This is a fast, high-quality generator. If 1024 bits of state are too - much, try a xoroshiro128+ generator. - - Note that the two lowest bits of this generator are LFSRs of degree - 1024, and thus will fail binary rank tests. The other bits needs a much - higher degree to be represented as LFSRs. - - We suggest to use a sign test to extract a random Boolean value, and - right shifts to extract subsets of bits. - - The state must be seeded so that it is not everywhere zero. If you have - a 64-bit seed, we suggest to seed a splitmix64 generator and use its - output to fill s. */ - -uint64_t s[16]; -int p; - -uint64_t next(void) { - const uint64_t s0 = s[p]; - uint64_t s1 = s[p = (p + 1) & 15]; - s1 ^= s1 << 31; // a - s[p] = s1 ^ s0 ^ (s1 >> 11) ^ (s0 >> 30); // b,c - return s[p] * 0x9e3779b97f4a7c13; -} - -/* This is the jump function for the generator. It is equivalent - to 2^512 calls to next(); it can be used to generate 2^512 - non-overlapping subsequences for parallel computations. */ - -void jump(void) { - static const uint64_t JUMP[] = { - 0x84242f96eca9c41d, 0xa3c65b8776f96855, 0x5b34a39f070b5837, - 0x4489affce4f31a1e, 0x2ffeeb0a48316f40, 0xdc2d9891fe68c022, - 0x3659132bb12fea70, 0xaac17d8efa43cab8, 0xc4cb815590989b13, - 0x5ee975283d71c93b, 0x691548c86c1bd540, 0x7910c41d10a1e6a5, - 0x0b5fc64563b3e2a8, 0x047f7684e9fc949d, 0xb99181f2d8f685ca, - 0x284600e3f30e38c3}; - - uint64_t t[16] = {0}; - for (int i = 0; i < sizeof JUMP / sizeof *JUMP; i++) - for (int b = 0; b < 64; b++) { - if (JUMP[i] & UINT64_C(1) << b) - for (int j = 0; j < 16; j++) - t[j] ^= s[(j + p) & 15]; - next(); - } - - for (int j = 0; j < 16; j++) - s[(j + p) & 15] = t[j]; -} diff --git a/numpy/random/src/xorshift1024/xorshift1024.orig.h b/numpy/random/src/xorshift1024/xorshift1024.orig.h deleted file mode 100644 index 9b7597967..000000000 --- a/numpy/random/src/xorshift1024/xorshift1024.orig.h +++ /dev/null @@ -1,7 +0,0 @@ -#include <stdint.h> -#include <string.h> - -uint64_t s[16]; -int p; -uint64_t next(void); -void jump(void); |