summaryrefslogtreecommitdiff
path: root/numpy/random/src
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/random/src')
-rw-r--r--numpy/random/src/aligned_malloc/aligned_malloc.c9
-rw-r--r--numpy/random/src/aligned_malloc/aligned_malloc.h54
-rw-r--r--numpy/random/src/bitgen.h20
-rw-r--r--numpy/random/src/distributions/distributions.c2
-rw-r--r--numpy/random/src/distributions/distributions.h214
-rw-r--r--numpy/random/src/distributions/random_hypergeometric.c2
-rw-r--r--numpy/random/src/legacy/legacy-distributions.c2
-rw-r--r--numpy/random/src/legacy/legacy-distributions.h49
8 files changed, 3 insertions, 349 deletions
diff --git a/numpy/random/src/aligned_malloc/aligned_malloc.c b/numpy/random/src/aligned_malloc/aligned_malloc.c
deleted file mode 100644
index 6e8192cfb..000000000
--- a/numpy/random/src/aligned_malloc/aligned_malloc.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "aligned_malloc.h"
-
-static NPY_INLINE void *PyArray_realloc_aligned(void *p, size_t n);
-
-static NPY_INLINE void *PyArray_malloc_aligned(size_t n);
-
-static NPY_INLINE void *PyArray_calloc_aligned(size_t n, size_t s);
-
-static NPY_INLINE void PyArray_free_aligned(void *p); \ No newline at end of file
diff --git a/numpy/random/src/aligned_malloc/aligned_malloc.h b/numpy/random/src/aligned_malloc/aligned_malloc.h
deleted file mode 100644
index ea24f6d23..000000000
--- a/numpy/random/src/aligned_malloc/aligned_malloc.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef _RANDOMDGEN__ALIGNED_MALLOC_H_
-#define _RANDOMDGEN__ALIGNED_MALLOC_H_
-
-#include "Python.h"
-#include "numpy/npy_common.h"
-
-#define NPY_MEMALIGN 16 /* 16 for SSE2, 32 for AVX, 64 for Xeon Phi */
-
-static NPY_INLINE void *PyArray_realloc_aligned(void *p, size_t n)
-{
- void *p1, **p2, *base;
- size_t old_offs, offs = NPY_MEMALIGN - 1 + sizeof(void *);
- if (NPY_UNLIKELY(p != NULL))
- {
- base = *(((void **)p) - 1);
- if (NPY_UNLIKELY((p1 = PyMem_Realloc(base, n + offs)) == NULL))
- return NULL;
- if (NPY_LIKELY(p1 == base))
- return p;
- p2 = (void **)(((Py_uintptr_t)(p1) + offs) & ~(NPY_MEMALIGN - 1));
- old_offs = (size_t)((Py_uintptr_t)p - (Py_uintptr_t)base);
- memmove((void *)p2, ((char *)p1) + old_offs, n);
- }
- else
- {
- if (NPY_UNLIKELY((p1 = PyMem_Malloc(n + offs)) == NULL))
- return NULL;
- p2 = (void **)(((Py_uintptr_t)(p1) + offs) & ~(NPY_MEMALIGN - 1));
- }
- *(p2 - 1) = p1;
- return (void *)p2;
-}
-
-static NPY_INLINE void *PyArray_malloc_aligned(size_t n)
-{
- return PyArray_realloc_aligned(NULL, n);
-}
-
-static NPY_INLINE void *PyArray_calloc_aligned(size_t n, size_t s)
-{
- void *p;
- if (NPY_UNLIKELY((p = PyArray_realloc_aligned(NULL, n * s)) == NULL))
- return NULL;
- memset(p, 0, n * s);
- return p;
-}
-
-static NPY_INLINE void PyArray_free_aligned(void *p)
-{
- void *base = *(((void **)p) - 1);
- PyMem_Free(base);
-}
-
-#endif
diff --git a/numpy/random/src/bitgen.h b/numpy/random/src/bitgen.h
deleted file mode 100644
index 0adaaf2ee..000000000
--- a/numpy/random/src/bitgen.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _RANDOM_BITGEN_H
-#define _RANDOM_BITGEN_H
-
-#pragma once
-#include <stddef.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-/* Must match the declaration in numpy/random/common.pxd */
-
-typedef struct bitgen {
- void *state;
- uint64_t (*next_uint64)(void *st);
- uint32_t (*next_uint32)(void *st);
- double (*next_double)(void *st);
- uint64_t (*next_raw)(void *st);
-} bitgen_t;
-
-
-#endif
diff --git a/numpy/random/src/distributions/distributions.c b/numpy/random/src/distributions/distributions.c
index 1244ffe65..5cde14218 100644
--- a/numpy/random/src/distributions/distributions.c
+++ b/numpy/random/src/distributions/distributions.c
@@ -1,4 +1,4 @@
-#include "distributions.h"
+#include "include/distributions.h"
#include "ziggurat_constants.h"
#include "logfactorial.h"
diff --git a/numpy/random/src/distributions/distributions.h b/numpy/random/src/distributions/distributions.h
deleted file mode 100644
index 2a6b2a045..000000000
--- a/numpy/random/src/distributions/distributions.h
+++ /dev/null
@@ -1,214 +0,0 @@
-#ifndef _RANDOMDGEN__DISTRIBUTIONS_H_
-#define _RANDOMDGEN__DISTRIBUTIONS_H_
-
-#include "Python.h"
-#include "numpy/npy_common.h"
-#include <stddef.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "numpy/npy_math.h"
-#include "src/bitgen.h"
-
-/*
- * RAND_INT_TYPE is used to share integer generators with RandomState which
- * used long in place of int64_t. If changing a distribution that uses
- * RAND_INT_TYPE, then the original unmodified copy must be retained for
- * use in RandomState by copying to the legacy distributions source file.
- */
-#ifdef NP_RANDOM_LEGACY
-#define RAND_INT_TYPE long
-#define RAND_INT_MAX LONG_MAX
-#else
-#define RAND_INT_TYPE int64_t
-#define RAND_INT_MAX INT64_MAX
-#endif
-
-#ifdef DLL_EXPORT
-#define DECLDIR __declspec(dllexport)
-#else
-#define DECLDIR extern
-#endif
-
-#ifndef MIN
-#define MIN(x, y) (((x) < (y)) ? x : y)
-#define MAX(x, y) (((x) > (y)) ? x : y)
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846264338328
-#endif
-
-typedef struct s_binomial_t {
- int has_binomial; /* !=0: following parameters initialized for binomial */
- double psave;
- RAND_INT_TYPE nsave;
- double r;
- double q;
- double fm;
- RAND_INT_TYPE m;
- double p1;
- double xm;
- double xl;
- double xr;
- double c;
- double laml;
- double lamr;
- double p2;
- double p3;
- double p4;
-} binomial_t;
-
-/* Inline generators for internal use */
-static NPY_INLINE uint32_t next_uint32(bitgen_t *bitgen_state) {
- return bitgen_state->next_uint32(bitgen_state->state);
-}
-
-static NPY_INLINE uint64_t next_uint64(bitgen_t *bitgen_state) {
- return bitgen_state->next_uint64(bitgen_state->state);
-}
-
-static NPY_INLINE float next_float(bitgen_t *bitgen_state) {
- return (next_uint32(bitgen_state) >> 9) * (1.0f / 8388608.0f);
-}
-
-static NPY_INLINE double next_double(bitgen_t *bitgen_state) {
- return bitgen_state->next_double(bitgen_state->state);
-}
-
-DECLDIR double loggam(double x);
-
-DECLDIR float random_float(bitgen_t *bitgen_state);
-DECLDIR double random_double(bitgen_t *bitgen_state);
-DECLDIR void random_double_fill(bitgen_t *bitgen_state, npy_intp cnt, double *out);
-
-DECLDIR int64_t random_positive_int64(bitgen_t *bitgen_state);
-DECLDIR int32_t random_positive_int32(bitgen_t *bitgen_state);
-DECLDIR int64_t random_positive_int(bitgen_t *bitgen_state);
-DECLDIR uint64_t random_uint(bitgen_t *bitgen_state);
-
-DECLDIR double random_standard_exponential(bitgen_t *bitgen_state);
-DECLDIR void random_standard_exponential_fill(bitgen_t *bitgen_state, npy_intp cnt,
- double *out);
-DECLDIR float random_standard_exponential_f(bitgen_t *bitgen_state);
-DECLDIR double random_standard_exponential_zig(bitgen_t *bitgen_state);
-DECLDIR void random_standard_exponential_zig_fill(bitgen_t *bitgen_state,
- npy_intp cnt, double *out);
-DECLDIR float random_standard_exponential_zig_f(bitgen_t *bitgen_state);
-
-/*
-DECLDIR double random_gauss(bitgen_t *bitgen_state);
-DECLDIR float random_gauss_f(bitgen_t *bitgen_state);
-*/
-DECLDIR double random_gauss_zig(bitgen_t *bitgen_state);
-DECLDIR float random_gauss_zig_f(bitgen_t *bitgen_state);
-DECLDIR void random_gauss_zig_fill(bitgen_t *bitgen_state, npy_intp cnt,
- double *out);
-
-/*
-DECLDIR double random_standard_gamma(bitgen_t *bitgen_state, double shape);
-DECLDIR float random_standard_gamma_f(bitgen_t *bitgen_state, float shape);
-*/
-DECLDIR double random_standard_gamma_zig(bitgen_t *bitgen_state, double shape);
-DECLDIR float random_standard_gamma_zig_f(bitgen_t *bitgen_state, float shape);
-
-/*
-DECLDIR double random_normal(bitgen_t *bitgen_state, double loc, double scale);
-*/
-DECLDIR double random_normal_zig(bitgen_t *bitgen_state, double loc, double scale);
-
-DECLDIR double random_gamma(bitgen_t *bitgen_state, double shape, double scale);
-DECLDIR float random_gamma_float(bitgen_t *bitgen_state, float shape, float scale);
-
-DECLDIR double random_exponential(bitgen_t *bitgen_state, double scale);
-DECLDIR double random_uniform(bitgen_t *bitgen_state, double lower, double range);
-DECLDIR double random_beta(bitgen_t *bitgen_state, double a, double b);
-DECLDIR double random_chisquare(bitgen_t *bitgen_state, double df);
-DECLDIR double random_f(bitgen_t *bitgen_state, double dfnum, double dfden);
-DECLDIR double random_standard_cauchy(bitgen_t *bitgen_state);
-DECLDIR double random_pareto(bitgen_t *bitgen_state, double a);
-DECLDIR double random_weibull(bitgen_t *bitgen_state, double a);
-DECLDIR double random_power(bitgen_t *bitgen_state, double a);
-DECLDIR double random_laplace(bitgen_t *bitgen_state, double loc, double scale);
-DECLDIR double random_gumbel(bitgen_t *bitgen_state, double loc, double scale);
-DECLDIR double random_logistic(bitgen_t *bitgen_state, double loc, double scale);
-DECLDIR double random_lognormal(bitgen_t *bitgen_state, double mean, double sigma);
-DECLDIR double random_rayleigh(bitgen_t *bitgen_state, double mode);
-DECLDIR double random_standard_t(bitgen_t *bitgen_state, double df);
-DECLDIR double random_noncentral_chisquare(bitgen_t *bitgen_state, double df,
- double nonc);
-DECLDIR double random_noncentral_f(bitgen_t *bitgen_state, double dfnum,
- double dfden, double nonc);
-DECLDIR double random_wald(bitgen_t *bitgen_state, double mean, double scale);
-DECLDIR double random_vonmises(bitgen_t *bitgen_state, double mu, double kappa);
-DECLDIR double random_triangular(bitgen_t *bitgen_state, double left, double mode,
- double right);
-
-DECLDIR RAND_INT_TYPE random_poisson(bitgen_t *bitgen_state, double lam);
-DECLDIR RAND_INT_TYPE random_negative_binomial(bitgen_t *bitgen_state, double n,
- double p);
-
-DECLDIR RAND_INT_TYPE random_binomial_btpe(bitgen_t *bitgen_state,
- RAND_INT_TYPE n,
- double p,
- binomial_t *binomial);
-DECLDIR RAND_INT_TYPE random_binomial_inversion(bitgen_t *bitgen_state,
- RAND_INT_TYPE n,
- double p,
- binomial_t *binomial);
-DECLDIR int64_t random_binomial(bitgen_t *bitgen_state, double p,
- int64_t n, binomial_t *binomial);
-
-DECLDIR RAND_INT_TYPE random_logseries(bitgen_t *bitgen_state, double p);
-DECLDIR RAND_INT_TYPE random_geometric_search(bitgen_t *bitgen_state, double p);
-DECLDIR RAND_INT_TYPE random_geometric_inversion(bitgen_t *bitgen_state, double p);
-DECLDIR RAND_INT_TYPE random_geometric(bitgen_t *bitgen_state, double p);
-DECLDIR RAND_INT_TYPE random_zipf(bitgen_t *bitgen_state, double a);
-DECLDIR int64_t random_hypergeometric(bitgen_t *bitgen_state,
- int64_t good, int64_t bad, int64_t sample);
-
-DECLDIR uint64_t random_interval(bitgen_t *bitgen_state, uint64_t max);
-
-/* Generate random uint64 numbers in closed interval [off, off + rng]. */
-DECLDIR uint64_t random_bounded_uint64(bitgen_t *bitgen_state, uint64_t off,
- uint64_t rng, uint64_t mask,
- bool use_masked);
-
-/* Generate random uint32 numbers in closed interval [off, off + rng]. */
-DECLDIR uint32_t random_buffered_bounded_uint32(bitgen_t *bitgen_state,
- uint32_t off, uint32_t rng,
- uint32_t mask, bool use_masked,
- int *bcnt, uint32_t *buf);
-DECLDIR uint16_t random_buffered_bounded_uint16(bitgen_t *bitgen_state,
- uint16_t off, uint16_t rng,
- uint16_t mask, bool use_masked,
- int *bcnt, uint32_t *buf);
-DECLDIR uint8_t random_buffered_bounded_uint8(bitgen_t *bitgen_state, uint8_t off,
- uint8_t rng, uint8_t mask,
- bool use_masked, int *bcnt,
- uint32_t *buf);
-DECLDIR npy_bool random_buffered_bounded_bool(bitgen_t *bitgen_state, npy_bool off,
- npy_bool rng, npy_bool mask,
- bool use_masked, int *bcnt,
- uint32_t *buf);
-
-DECLDIR void random_bounded_uint64_fill(bitgen_t *bitgen_state, uint64_t off,
- uint64_t rng, npy_intp cnt,
- bool use_masked, uint64_t *out);
-DECLDIR void random_bounded_uint32_fill(bitgen_t *bitgen_state, uint32_t off,
- uint32_t rng, npy_intp cnt,
- bool use_masked, uint32_t *out);
-DECLDIR void random_bounded_uint16_fill(bitgen_t *bitgen_state, uint16_t off,
- uint16_t rng, npy_intp cnt,
- bool use_masked, uint16_t *out);
-DECLDIR void random_bounded_uint8_fill(bitgen_t *bitgen_state, uint8_t off,
- uint8_t rng, npy_intp cnt,
- bool use_masked, uint8_t *out);
-DECLDIR void random_bounded_bool_fill(bitgen_t *bitgen_state, npy_bool off,
- npy_bool rng, npy_intp cnt,
- bool use_masked, npy_bool *out);
-
-DECLDIR void random_multinomial(bitgen_t *bitgen_state, RAND_INT_TYPE n, RAND_INT_TYPE *mnix,
- double *pix, npy_intp d, binomial_t *binomial);
-
-#endif
diff --git a/numpy/random/src/distributions/random_hypergeometric.c b/numpy/random/src/distributions/random_hypergeometric.c
index 94dc6380f..91fb707da 100644
--- a/numpy/random/src/distributions/random_hypergeometric.c
+++ b/numpy/random/src/distributions/random_hypergeometric.c
@@ -1,4 +1,4 @@
-#include "distributions.h"
+#include "include/distributions.h"
#include "logfactorial.h"
#include <stdint.h>
diff --git a/numpy/random/src/legacy/legacy-distributions.c b/numpy/random/src/legacy/legacy-distributions.c
index 684b3d762..404c3e301 100644
--- a/numpy/random/src/legacy/legacy-distributions.c
+++ b/numpy/random/src/legacy/legacy-distributions.c
@@ -1,4 +1,4 @@
-#include "legacy-distributions.h"
+#include "include/legacy-distributions.h"
static NPY_INLINE double legacy_double(aug_bitgen_t *aug_state) {
diff --git a/numpy/random/src/legacy/legacy-distributions.h b/numpy/random/src/legacy/legacy-distributions.h
deleted file mode 100644
index 4bc15d58e..000000000
--- a/numpy/random/src/legacy/legacy-distributions.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef _RANDOMDGEN__DISTRIBUTIONS_LEGACY_H_
-#define _RANDOMDGEN__DISTRIBUTIONS_LEGACY_H_
-
-
-#include "../distributions/distributions.h"
-
-typedef struct aug_bitgen {
- bitgen_t *bit_generator;
- int has_gauss;
- double gauss;
-} aug_bitgen_t;
-
-extern double legacy_gauss(aug_bitgen_t *aug_state);
-extern double legacy_standard_exponential(aug_bitgen_t *aug_state);
-extern double legacy_pareto(aug_bitgen_t *aug_state, double a);
-extern double legacy_weibull(aug_bitgen_t *aug_state, double a);
-extern double legacy_power(aug_bitgen_t *aug_state, double a);
-extern double legacy_gamma(aug_bitgen_t *aug_state, double shape, double scale);
-extern double legacy_chisquare(aug_bitgen_t *aug_state, double df);
-extern double legacy_noncentral_chisquare(aug_bitgen_t *aug_state, double df,
- double nonc);
-extern double legacy_noncentral_f(aug_bitgen_t *aug_state, double dfnum,
- double dfden, double nonc);
-extern double legacy_wald(aug_bitgen_t *aug_state, double mean, double scale);
-extern double legacy_lognormal(aug_bitgen_t *aug_state, double mean,
- double sigma);
-extern double legacy_standard_t(aug_bitgen_t *aug_state, double df);
-extern double legacy_standard_cauchy(aug_bitgen_t *state);
-extern double legacy_beta(aug_bitgen_t *aug_state, double a, double b);
-extern double legacy_f(aug_bitgen_t *aug_state, double dfnum, double dfden);
-extern double legacy_normal(aug_bitgen_t *aug_state, double loc, double scale);
-extern double legacy_standard_gamma(aug_bitgen_t *aug_state, double shape);
-extern double legacy_exponential(aug_bitgen_t *aug_state, double scale);
-extern int64_t legacy_random_binomial(bitgen_t *bitgen_state, double p,
- int64_t n, binomial_t *binomial);
-extern int64_t legacy_negative_binomial(aug_bitgen_t *aug_state, double n,
- double p);
-extern int64_t legacy_random_hypergeometric(bitgen_t *bitgen_state,
- int64_t good, int64_t bad,
- int64_t sample);
-extern int64_t legacy_random_logseries(bitgen_t *bitgen_state, double p);
-extern int64_t legacy_random_poisson(bitgen_t *bitgen_state, double lam);
-extern int64_t legacy_random_zipf(bitgen_t *bitgen_state, double a);
-extern int64_t legacy_random_geometric(bitgen_t *bitgen_state, double p);
-void legacy_random_multinomial(bitgen_t *bitgen_state, RAND_INT_TYPE n,
- RAND_INT_TYPE *mnix, double *pix, npy_intp d,
- binomial_t *binomial);
-
-#endif