diff options
author | mattip <matti.picus@gmail.com> | 2019-06-16 14:00:00 +0300 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2019-06-26 00:08:23 +0300 |
commit | 02f63e0f36d2f6c81b6720229b05518a573aa5cf (patch) | |
tree | 9e3c5f5a26fc1ae956975677f30a6b94f3aade5c /numpy/random/src | |
parent | 37a1ad069a800f5ef98286f25fb3fb632375168d (diff) | |
download | numpy-02f63e0f36d2f6c81b6720229b05518a573aa5cf.tar.gz |
MAINT: remove xoshiro* BitGenerators
Diffstat (limited to 'numpy/random/src')
-rw-r--r-- | numpy/random/src/xoshiro256/LICENSE.md | 9 | ||||
-rw-r--r-- | numpy/random/src/xoshiro256/xoshiro256-test-data-gen.c | 72 | ||||
-rw-r--r-- | numpy/random/src/xoshiro256/xoshiro256.c | 57 | ||||
-rw-r--r-- | numpy/random/src/xoshiro256/xoshiro256.h | 53 | ||||
-rw-r--r-- | numpy/random/src/xoshiro256/xoshiro256.orig.c | 103 | ||||
-rw-r--r-- | numpy/random/src/xoshiro256/xoshiro256.orig.h | 5 | ||||
-rw-r--r-- | numpy/random/src/xoshiro512/LICENSE.md | 9 | ||||
-rw-r--r-- | numpy/random/src/xoshiro512/xoshiro512-test-data-gen.c | 72 | ||||
-rw-r--r-- | numpy/random/src/xoshiro512/xoshiro512.c | 53 | ||||
-rw-r--r-- | numpy/random/src/xoshiro512/xoshiro512.h | 64 | ||||
-rw-r--r-- | numpy/random/src/xoshiro512/xoshiro512.orig.c | 67 | ||||
-rw-r--r-- | numpy/random/src/xoshiro512/xoshiro512.orig.h | 6 |
12 files changed, 0 insertions, 570 deletions
diff --git a/numpy/random/src/xoshiro256/LICENSE.md b/numpy/random/src/xoshiro256/LICENSE.md deleted file mode 100644 index d863f3b29..000000000 --- a/numpy/random/src/xoshiro256/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -# XOSHIRO256STARSTAR - -Written in 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/>.
\ No newline at end of file diff --git a/numpy/random/src/xoshiro256/xoshiro256-test-data-gen.c b/numpy/random/src/xoshiro256/xoshiro256-test-data-gen.c deleted file mode 100644 index b5351bf7a..000000000 --- a/numpy/random/src/xoshiro256/xoshiro256-test-data-gen.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Generate testing csv files - * - * cl xoshiro256-test-data-gen.c xoshiro256.orig.c / - * ../splitmix64/splitmix64.c /Ox - * xoshiro256-test-data-gen.exe * - * - * gcc xoshiro256-test-data-gen.c xoshiro256.orig.c / - * ../splitmix64/splitmix64.c -o xoshiro256-test-data-gen - * ./xoshiro256-test-data-gen - * - * Requires the Random123 directory containing header files to be located in the - * same directory (not included). - * - */ - -#include "../splitmix64/splitmix64.h" -#include "xoshiro256.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 < 4; i++) { - s[i] = splitmix64_next(&state); - } - uint64_t store[N]; - for (i = 0; i < N; i++) { - store[i] = next(); - } - - FILE *fp; - fp = fopen("xoshiro256-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 < 4; i++) { - s[i] = splitmix64_next(&state); - } - for (i = 0; i < N; i++) { - store[i] = next(); - } - fp = fopen("xoshiro256-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/xoshiro256/xoshiro256.c b/numpy/random/src/xoshiro256/xoshiro256.c deleted file mode 100644 index a9ac49aa6..000000000 --- a/numpy/random/src/xoshiro256/xoshiro256.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Written in 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 <stddef.h> -#include "xoshiro256.h" - -/* This is xoshiro256** 1.0, our all-purpose, rock-solid generator. It has - excellent (sub-ns) speed, a state (256 bits) that is large enough for - any parallel application, and it passes all tests we are aware of. - - For generating just floating-point numbers, xoshiro256+ is even faster. - - 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. */ - -extern NPY_INLINE uint64_t xoshiro256_next64(xoshiro256_state *state); - -extern NPY_INLINE uint32_t xoshiro256_next32(xoshiro256_state *state); - - -/* This is the jump function for the generator. It is equivalent - to 2^128 calls to next(); it can be used to generate 2^128 - non-overlapping subsequences for parallel computations. */ - -void xoshiro256_jump(xoshiro256_state *state) -{ - size_t i, b; - static const uint64_t JUMP[] = {0x180ec6d33cfd0aba, 0xd5a61266f0c9392c, 0xa9582618e03fc9aa, 0x39abdc4529b1661c}; - - uint64_t s0 = 0; - uint64_t s1 = 0; - uint64_t s2 = 0; - uint64_t s3 = 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]; - s2 ^= state->s[2]; - s3 ^= state->s[3]; - } - xoshiro256_next(&state->s[0]); - } - - state->s[0] = s0; - state->s[1] = s1; - state->s[2] = s2; - state->s[3] = s3; -} diff --git a/numpy/random/src/xoshiro256/xoshiro256.h b/numpy/random/src/xoshiro256/xoshiro256.h deleted file mode 100644 index 1908245a5..000000000 --- a/numpy/random/src/xoshiro256/xoshiro256.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _RANDOMDGEN__XOSHIRO256STARSTAR_H_ -#define _RANDOMDGEN__XOSHIRO256STARSTAR_H_ - -#include <inttypes.h> -#include "numpy/npy_common.h" - -typedef struct s_xoshiro256_state { - uint64_t s[4]; - int has_uint32; - uint32_t uinteger; -} xoshiro256_state; - -static NPY_INLINE uint64_t rotl(const uint64_t x, int k) { - return (x << k) | (x >> (64 - k)); -} - -static NPY_INLINE uint64_t xoshiro256_next(uint64_t *s) { - const uint64_t result_starstar = rotl(s[1] * 5, 7) * 9; - const uint64_t t = s[1] << 17; - - s[2] ^= s[0]; - s[3] ^= s[1]; - s[1] ^= s[2]; - s[0] ^= s[3]; - - s[2] ^= t; - - s[3] = rotl(s[3], 45); - - return result_starstar; -} - - -static NPY_INLINE uint64_t xoshiro256_next64(xoshiro256_state *state) { - return xoshiro256_next(&state->s[0]); -} - -static NPY_INLINE uint32_t xoshiro256_next32(xoshiro256_state *state) { - - uint64_t next; - if (state->has_uint32) { - state->has_uint32 = 0; - return state->uinteger; - } - next = xoshiro256_next(&state->s[0]); - state->has_uint32 = 1; - state->uinteger = (uint32_t)(next >> 32); - return (uint32_t)(next & 0xffffffff); -} - -void xoshiro256_jump(xoshiro256_state *state); - -#endif diff --git a/numpy/random/src/xoshiro256/xoshiro256.orig.c b/numpy/random/src/xoshiro256/xoshiro256.orig.c deleted file mode 100644 index ecf87bab9..000000000 --- a/numpy/random/src/xoshiro256/xoshiro256.orig.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Written in 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 xoshiro256** 1.0, our all-purpose, rock-solid generator. It has - excellent (sub-ns) speed, a state (256 bits) that is large enough for - any parallel application, and it passes all tests we are aware of. - - For generating just floating-point numbers, xoshiro256+ is even faster. - - 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. */ - -static inline uint64_t rotl(const uint64_t x, int k) { - return (x << k) | (x >> (64 - k)); -} - - -uint64_t s[4]; - -uint64_t next(void) { - const uint64_t result_starstar = rotl(s[1] * 5, 7) * 9; - - const uint64_t t = s[1] << 17; - - s[2] ^= s[0]; - s[3] ^= s[1]; - s[1] ^= s[2]; - s[0] ^= s[3]; - - s[2] ^= t; - - s[3] = rotl(s[3], 45); - - return result_starstar; -} - - -/* This is the jump function for the generator. It is equivalent - to 2^128 calls to next(); it can be used to generate 2^128 - non-overlapping subsequences for parallel computations. */ - -void jump(void) { - static const uint64_t JUMP[] = { 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c, 0xa9582618e03fc9aa, 0x39abdc4529b1661c }; - - uint64_t s0 = 0; - uint64_t s1 = 0; - uint64_t s2 = 0; - uint64_t s3 = 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]; - s2 ^= s[2]; - s3 ^= s[3]; - } - next(); - } - - s[0] = s0; - s[1] = s1; - s[2] = s2; - s[3] = s3; -} - - - -/* This is the long-jump function for the generator. It is equivalent to - 2^192 calls to next(); it can be used to generate 2^64 starting points, - from each of which jump() will generate 2^64 non-overlapping - subsequences for parallel distributed computations. */ - -void long_jump(void) { - static const uint64_t LONG_JUMP[] = { 0x76e15d3efefdcbbf, 0xc5004e441c522fb3, 0x77710069854ee241, 0x39109bb02acbe635 }; - - uint64_t s0 = 0; - uint64_t s1 = 0; - uint64_t s2 = 0; - uint64_t s3 = 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]; - s2 ^= s[2]; - s3 ^= s[3]; - } - next(); - } - - s[0] = s0; - s[1] = s1; - s[2] = s2; - s[3] = s3; -}
\ No newline at end of file diff --git a/numpy/random/src/xoshiro256/xoshiro256.orig.h b/numpy/random/src/xoshiro256/xoshiro256.orig.h deleted file mode 100644 index 3aa788ec9..000000000 --- a/numpy/random/src/xoshiro256/xoshiro256.orig.h +++ /dev/null @@ -1,5 +0,0 @@ -#include <stdint.h> - -uint64_t s[4]; -uint64_t next(void); -void jump(void); diff --git a/numpy/random/src/xoshiro512/LICENSE.md b/numpy/random/src/xoshiro512/LICENSE.md deleted file mode 100644 index aa34c1966..000000000 --- a/numpy/random/src/xoshiro512/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -# XOSHIRO512STARSTAR - -Written in 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/>. diff --git a/numpy/random/src/xoshiro512/xoshiro512-test-data-gen.c b/numpy/random/src/xoshiro512/xoshiro512-test-data-gen.c deleted file mode 100644 index 698923bda..000000000 --- a/numpy/random/src/xoshiro512/xoshiro512-test-data-gen.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Generate testing csv files - * - * cl xoshiro512-test-data-gen.c xoshiro512.orig.c / - * ../splitmix64/splitmix64.c /Ox - * xoshiro512-test-data-gen.exe * - * - * gcc xoshiro512-test-data-gen.c xoshiro512.orig.c / - * ../splitmix64/splitmix64.c -o xoshiro512-test-data-gen - * ./xoshiro512-test-data-gen - * - * Requires the Random123 directory containing header files to be located in the - * same directory (not included). - * - */ - -#include "../splitmix64/splitmix64.h" -#include "xoshiro512.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 < 8; i++) { - s[i] = splitmix64_next(&state); - } - uint64_t store[N]; - for (i = 0; i < N; i++) { - store[i] = next(); - } - - FILE *fp; - fp = fopen("xoshiro512-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 < 8; i++) { - s[i] = splitmix64_next(&state); - } - for (i = 0; i < N; i++) { - store[i] = next(); - } - fp = fopen("xoshiro512-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/xoshiro512/xoshiro512.c b/numpy/random/src/xoshiro512/xoshiro512.c deleted file mode 100644 index 4f4af86f0..000000000 --- a/numpy/random/src/xoshiro512/xoshiro512.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Written in 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 <stddef.h> -#include "xoshiro512.h" - -/* This is xoshiro512** 1.0, an all-purpose, rock-solid generator. It has - excellent (about 1ns) speed, an increased state (512 bits) that is - large enough for any parallel application, and it passes all tests we - are aware of. - - For generating just floating-point numbers, xoshiro512+ is even faster. - - 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. */ - -extern NPY_INLINE uint64_t xoshiro512_next64(xoshiro512_state *state); - -extern NPY_INLINE uint32_t xoshiro512_next32(xoshiro512_state *state); - - -/* This is the jump function for the generator. It is equivalent - to 2^256 calls to next(); it can be used to generate 2^256 - non-overlapping subsequences for parallel computations. */ - -static uint64_t s_placeholder[8]; - -void xoshiro512_jump(xoshiro512_state *state) { - - size_t i, b, w; - static const uint64_t JUMP[] = {0x33ed89b6e7a353f9, 0x760083d7955323be, - 0x2837f2fbb5f22fae, 0x4b8c5674d309511c, - 0xb11ac47a7ba28c25, 0xf1be7667092bcc1c, - 0x53851efdb6df0aaf, 0x1ebbc8b23eaf25db}; - - uint64_t t[sizeof s_placeholder / sizeof *s_placeholder]; - memset(t, 0, sizeof t); - for (i = 0; i < sizeof JUMP / sizeof *JUMP; i++) - for (b = 0; b < 64; b++) { - if (JUMP[i] & UINT64_C(1) << b) - for (w = 0; w < sizeof s_placeholder / sizeof *s_placeholder; w++) - t[w] ^= state->s[w]; - xoshiro512_next(&state->s[0]); - } - - memcpy(state->s, t, sizeof s_placeholder); -} diff --git a/numpy/random/src/xoshiro512/xoshiro512.h b/numpy/random/src/xoshiro512/xoshiro512.h deleted file mode 100644 index 6ce6c7db7..000000000 --- a/numpy/random/src/xoshiro512/xoshiro512.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef _RANDOMDGEN__XOSHIRO512STARSTAR_H_ -#define _RANDOMDGEN__XOSHIRO512STARSTAR_H_ - -#include <string.h> -#include <inttypes.h> -#include "numpy/npy_common.h" - -typedef struct s_xoshiro512_state -{ - uint64_t s[8]; - int has_uint32; - uint32_t uinteger; -} xoshiro512_state; - -static NPY_INLINE uint64_t rotl(const uint64_t x, int k) -{ - return (x << k) | (x >> (64 - k)); -} - -static NPY_INLINE uint64_t xoshiro512_next(uint64_t *s) -{ - const uint64_t result_starstar = rotl(s[1] * 5, 7) * 9; - - const uint64_t t = s[1] << 11; - - s[2] ^= s[0]; - s[5] ^= s[1]; - s[1] ^= s[2]; - s[7] ^= s[3]; - s[3] ^= s[4]; - s[4] ^= s[5]; - s[0] ^= s[6]; - s[6] ^= s[7]; - - s[6] ^= t; - - s[7] = rotl(s[7], 21); - - return result_starstar; -} - - -static NPY_INLINE uint64_t xoshiro512_next64(xoshiro512_state *state) -{ - return xoshiro512_next(&state->s[0]); -} - -static NPY_INLINE uint32_t xoshiro512_next32(xoshiro512_state *state) -{ - uint64_t next; - if (state->has_uint32) - { - state->has_uint32 = 0; - return state->uinteger; - } - next = xoshiro512_next(&state->s[0]); - state->has_uint32 = 1; - state->uinteger = (uint32_t)(next >> 32); - return (uint32_t)(next & 0xffffffff); -} - -void xoshiro512_jump(xoshiro512_state *state); - -#endif diff --git a/numpy/random/src/xoshiro512/xoshiro512.orig.c b/numpy/random/src/xoshiro512/xoshiro512.orig.c deleted file mode 100644 index ecdf81fc1..000000000 --- a/numpy/random/src/xoshiro512/xoshiro512.orig.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Written in 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 "xoshiro512.orig.h" - -/* This is xoshiro512** 1.0, an all-purpose, rock-solid generator. It has - excellent (about 1ns) speed, an increased state (512 bits) that is - large enough for any parallel application, and it passes all tests we - are aware of. - - For generating just floating-point numbers, xoshiro512+ is even faster. - - 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. */ - -static inline uint64_t rotl(const uint64_t x, int k) { - return (x << k) | (x >> (64 - k)); -} - - -uint64_t next(void) { - const uint64_t result_starstar = rotl(s[1] * 5, 7) * 9; - - const uint64_t t = s[1] << 11; - - s[2] ^= s[0]; - s[5] ^= s[1]; - s[1] ^= s[2]; - s[7] ^= s[3]; - s[3] ^= s[4]; - s[4] ^= s[5]; - s[0] ^= s[6]; - s[6] ^= s[7]; - - s[6] ^= t; - - s[7] = rotl(s[7], 21); - - return result_starstar; -} - - -/* This is the jump function for the generator. It is equivalent - to 2^256 calls to next(); it can be used to generate 2^256 - non-overlapping subsequences for parallel computations. */ - -void jump(void) { - static const uint64_t JUMP[] = { 0x33ed89b6e7a353f9, 0x760083d7955323be, 0x2837f2fbb5f22fae, 0x4b8c5674d309511c, 0xb11ac47a7ba28c25, 0xf1be7667092bcc1c, 0x53851efdb6df0aaf, 0x1ebbc8b23eaf25db }; - - uint64_t t[sizeof s / sizeof *s]; - memset(t, 0, sizeof t); - 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 w = 0; w < sizeof s / sizeof *s; w++) - t[w] ^= s[w]; - next(); - } - - memcpy(s, t, sizeof s); -}
\ No newline at end of file diff --git a/numpy/random/src/xoshiro512/xoshiro512.orig.h b/numpy/random/src/xoshiro512/xoshiro512.orig.h deleted file mode 100644 index 0b7892473..000000000 --- a/numpy/random/src/xoshiro512/xoshiro512.orig.h +++ /dev/null @@ -1,6 +0,0 @@ -#include <stdint.h> -#include <string.h> - -uint64_t s[8]; -uint64_t next(void); -void jump(void); |