summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/arraymethods.c3
-rw-r--r--numpy/core/src/arrayobject.c92
-rw-r--r--numpy/core/src/arrayobject.h137
-rw-r--r--numpy/core/src/arraytypes.c.src (renamed from numpy/core/src/arraytypes.inc.src)18
-rw-r--r--numpy/core/src/hashdescr.c3
-rw-r--r--numpy/core/src/hashdescr.h6
-rw-r--r--numpy/core/src/multiarraymodule.c15
-rw-r--r--numpy/core/src/scalartypes.c.src (renamed from numpy/core/src/scalartypes.inc.src)23
8 files changed, 212 insertions, 85 deletions
diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c
index a6ee270a0..794b4e761 100644
--- a/numpy/core/src/arraymethods.c
+++ b/numpy/core/src/arraymethods.c
@@ -1738,9 +1738,6 @@ array_all(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
-__New_PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject *out,
- int variance, int num);
-static PyObject *
array_stddev(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
int axis = MAX_DIMS;
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 04696bfdf..f3e053161 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -20,7 +20,17 @@ maintainer email: oliphant.travis@ieee.org
Space Science Telescope Institute
(J. Todd Miller, Perry Greenfield, Rick White)
*/
+#define PY_SSIZE_T_CLEAN
+#include <Python.h>
+#include "structmember.h"
+
/*#include <stdio.h>*/
+#define _MULTIARRAYMODULE
+#define NPY_NO_PREFIX
+#include "numpy/arrayobject.h"
+#include "numpy/arrayscalars.h"
+
+#include "arrayobject.h"
/*NUMPY_API
* Get Priority from object
@@ -422,7 +432,7 @@ _unaligned_strided_byte_move(char *dst, intp outstrides, char *src,
}
-static void
+NPY_NO_EXPORT void
_unaligned_strided_byte_copy(char *dst, intp outstrides, char *src,
intp instrides, intp N, int elsize)
{
@@ -456,7 +466,7 @@ _unaligned_strided_byte_copy(char *dst, intp outstrides, char *src,
}
-static void
+NPY_NO_EXPORT void
_strided_byte_swap(void *p, intp stride, intp n, int size)
{
char *a, *b, c = 0;
@@ -499,7 +509,7 @@ _strided_byte_swap(void *p, intp stride, intp n, int size)
}
}
-static void
+NPY_NO_EXPORT void
byte_swap_vector(void *p, intp n, int size)
{
_strided_byte_swap(p, (intp) size, n, size);
@@ -507,7 +517,7 @@ byte_swap_vector(void *p, intp n, int size)
}
/* If numitems > 1, then dst must be contiguous */
-static void
+NPY_NO_EXPORT void
copy_and_swap(void *dst, void *src, int itemsize, intp numitems,
intp srcstrides, int swap)
{
@@ -538,13 +548,7 @@ copy_and_swap(void *dst, void *src, int itemsize, intp numitems,
#endif
-static PyArray_Descr **userdescrs=NULL;
-#define error_converting(x) (((x) == -1) && PyErr_Occurred())
-
-
-/* Computer-generated arraytype and scalartype code */
-#include "scalartypes.inc"
-#include "arraytypes.inc"
+NPY_NO_EXPORT PyArray_Descr **userdescrs=NULL;
/* Helper functions */
@@ -735,7 +739,7 @@ PyArray_PyIntAsInt(PyObject *o)
return (int) long_value;
}
-static char *
+NPY_NO_EXPORT char *
index2ptr(PyArrayObject *mp, intp i)
{
intp dim0;
@@ -877,7 +881,7 @@ finish:
* PyArray_CopyInto requires broadcastable arrays while
* this one is a flattening operation...
*/
-int
+NPY_NO_EXPORT int
_flat_copyinto(PyObject *dst, PyObject *src, NPY_ORDER order)
{
PyArrayIterObject *it;
@@ -1398,8 +1402,6 @@ PyArray_NewCopy(PyArrayObject *m1, NPY_ORDER fortran)
return (PyObject *)ret;
}
-static PyObject *array_big_item(PyArrayObject *, intp);
-
/* Does nothing with descr (cannot be NULL) */
/*NUMPY_API
Get scalar-equivalent to a region of memory described by a descriptor.
@@ -2155,7 +2157,7 @@ array_length(PyArrayObject *self)
}
}
-static PyObject *
+NPY_NO_EXPORT PyObject *
array_big_item(PyArrayObject *self, intp i)
{
char *item;
@@ -2732,7 +2734,7 @@ PyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)
return 0;
}
-static int
+NPY_NO_EXPORT int
count_new_axes_0d(PyObject *tuple)
{
int i, argument_count;
@@ -2766,7 +2768,7 @@ count_new_axes_0d(PyObject *tuple)
return newaxis_count;
}
-static PyObject *
+NPY_NO_EXPORT PyObject *
add_new_axes_0d(PyArrayObject *arr, int newaxis_count)
{
PyArrayObject *other;
@@ -3482,45 +3484,7 @@ static PyBufferProcs array_as_buffer = {
**************** Implement Number Protocol ****************************
*************************************************************************/
-
-typedef struct {
- PyObject *add;
- PyObject *subtract;
- PyObject *multiply;
- PyObject *divide;
- PyObject *remainder;
- PyObject *power;
- PyObject *square;
- PyObject *reciprocal;
- PyObject *ones_like;
- PyObject *sqrt;
- PyObject *negative;
- PyObject *absolute;
- PyObject *invert;
- PyObject *left_shift;
- PyObject *right_shift;
- PyObject *bitwise_and;
- PyObject *bitwise_xor;
- PyObject *bitwise_or;
- PyObject *less;
- PyObject *less_equal;
- PyObject *equal;
- PyObject *not_equal;
- PyObject *greater;
- PyObject *greater_equal;
- PyObject *floor_divide;
- PyObject *true_divide;
- PyObject *logical_or;
- PyObject *logical_and;
- PyObject *floor;
- PyObject *ceil;
- PyObject *maximum;
- PyObject *minimum;
- PyObject *rint;
- PyObject *conjugate;
-} NumericOps;
-
-static NumericOps n_ops; /* NB: static objects initialized to zero */
+NPY_NO_EXPORT NumericOps n_ops; /* NB: static objects initialized to zero */
/* Dictionary can contain any of the numeric operations, by name.
Those not present will not be changed
@@ -3653,7 +3617,7 @@ _get_keywords(int rtype, PyArrayObject *out)
return kwds;
}
-static PyObject *
+NPY_NO_EXPORT PyObject *
PyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,
int rtype, PyArrayObject *out)
{
@@ -3676,7 +3640,7 @@ PyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,
}
-static PyObject *
+NPY_NO_EXPORT PyObject *
PyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,
int rtype, PyArrayObject *out)
{
@@ -3699,7 +3663,7 @@ PyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,
}
-static PyObject *
+NPY_NO_EXPORT PyObject *
PyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op)
{
if (op == NULL) {
@@ -3709,7 +3673,7 @@ PyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op)
return PyObject_CallFunction(op, "OO", m1, m2);
}
-static PyObject *
+NPY_NO_EXPORT PyObject *
PyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op)
{
if (op == NULL) {
@@ -4935,7 +4899,7 @@ _compare_strings(PyObject *result, PyArrayMultiIterObject *multi,
#undef _rstrip_loop
#undef SMALL_STRING
-static PyObject *
+NPY_NO_EXPORT PyObject *
_strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op,
int rstrip)
{
@@ -7095,7 +7059,7 @@ array_base_get(PyArrayObject *self)
}
-static int
+NPY_NO_EXPORT int
_zerofill(PyArrayObject *ret)
{
if (PyDataType_REFCHK(ret->descr)) {
@@ -7664,7 +7628,7 @@ discover_dimensions(PyObject *s, int nd, intp *d, int check_it)
* doesn't alter refcount of chktype or mintype ---
* unless one of them is returned
*/
-static PyArray_Descr *
+NPY_NO_EXPORT PyArray_Descr *
_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)
{
PyArray_Descr *outtype;
diff --git a/numpy/core/src/arrayobject.h b/numpy/core/src/arrayobject.h
new file mode 100644
index 000000000..b4fd76490
--- /dev/null
+++ b/numpy/core/src/arrayobject.h
@@ -0,0 +1,137 @@
+#ifndef _NPY_INTERNAL_ARRAYOBJECT_H_
+#define _NPY_INTERNAL_ARRAYOBJECT_H_
+
+#ifndef _MULTIARRAYMODULE
+#error You should not include this
+#endif
+
+typedef struct {
+ PyObject *add;
+ PyObject *subtract;
+ PyObject *multiply;
+ PyObject *divide;
+ PyObject *remainder;
+ PyObject *power;
+ PyObject *square;
+ PyObject *reciprocal;
+ PyObject *ones_like;
+ PyObject *sqrt;
+ PyObject *negative;
+ PyObject *absolute;
+ PyObject *invert;
+ PyObject *left_shift;
+ PyObject *right_shift;
+ PyObject *bitwise_and;
+ PyObject *bitwise_xor;
+ PyObject *bitwise_or;
+ PyObject *less;
+ PyObject *less_equal;
+ PyObject *equal;
+ PyObject *not_equal;
+ PyObject *greater;
+ PyObject *greater_equal;
+ PyObject *floor_divide;
+ PyObject *true_divide;
+ PyObject *logical_or;
+ PyObject *logical_and;
+ PyObject *floor;
+ PyObject *ceil;
+ PyObject *maximum;
+ PyObject *minimum;
+ PyObject *rint;
+ PyObject *conjugate;
+} NumericOps;
+
+extern NPY_NO_EXPORT NumericOps n_ops;
+extern NPY_NO_EXPORT PyArray_Descr **userdescrs;
+
+
+#define error_converting(x) (((x) == -1) && PyErr_Occurred())
+
+NPY_NO_EXPORT int
+_flat_copyinto(PyObject *dst, PyObject *src, NPY_ORDER order);
+
+NPY_NO_EXPORT PyArray_Descr *
+_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype);
+
+NPY_NO_EXPORT PyObject *
+array_big_item(PyArrayObject *, intp);
+
+NPY_NO_EXPORT void
+_unaligned_strided_byte_copy(char *dst, intp outstrides, char *src,
+ intp instrides, intp N, int elsize);
+
+NPY_NO_EXPORT void
+_strided_byte_swap(void *p, intp stride, intp n, int size);
+
+NPY_NO_EXPORT int
+_zerofill(PyArrayObject *ret);
+
+NPY_NO_EXPORT char *
+index2ptr(PyArrayObject *mp, intp i);
+
+NPY_NO_EXPORT PyObject *
+_strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op,
+ int rstrip);
+
+NPY_NO_EXPORT void
+copy_and_swap(void *dst, void *src, int itemsize, intp numitems,
+ intp srcstrides, int swap);
+
+NPY_NO_EXPORT void
+byte_swap_vector(void *p, intp n, int size);
+/* FIXME: just remove _check_axis ? */
+#define _check_axis PyArray_CheckAxis
+
+NPY_NO_EXPORT PyObject *
+PyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,
+ int rtype, PyArrayObject *out);
+
+NPY_NO_EXPORT PyObject *
+PyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,
+ int rtype, PyArrayObject *out);
+
+NPY_NO_EXPORT PyObject *
+PyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op);
+
+NPY_NO_EXPORT PyObject *
+PyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op);
+
+NPY_NO_EXPORT PyObject *
+add_new_axes_0d(PyArrayObject *, int);
+
+NPY_NO_EXPORT int
+count_new_axes_0d(PyObject *tuple);
+
+/* FIXME: this is defined in multiarraymodule.c ... */
+NPY_NO_EXPORT PyObject *
+__New_PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject *out,
+ int variance, int num);
+
+NPY_NO_EXPORT PyArray_Descr *
+_arraydescr_fromobj(PyObject *obj);
+
+/* FIXME: this is in scalartypes.inc.src */
+NPY_NO_EXPORT void
+initialize_numeric_types(void);
+
+NPY_NO_EXPORT void
+format_longdouble(char *buf, size_t buflen, longdouble val, unsigned int prec);
+
+NPY_NO_EXPORT void
+gentype_struct_free(void *ptr, void *arg);
+
+NPY_NO_EXPORT int
+_typenum_fromtypeobj(PyObject *type, int user);
+
+NPY_NO_EXPORT void *
+scalar_value(PyObject *scalar, PyArray_Descr *descr);
+
+/* FIXME: this is defined in arratypes.inc.src */
+NPY_NO_EXPORT int
+set_typeinfo(PyObject *dict);
+
+extern NPY_NO_EXPORT PyArray_Descr LONG_Descr;
+extern NPY_NO_EXPORT PyArray_Descr INT_Descr;
+
+#endif
diff --git a/numpy/core/src/arraytypes.inc.src b/numpy/core/src/arraytypes.c.src
index bf8715aec..d96f48eee 100644
--- a/numpy/core/src/arraytypes.inc.src
+++ b/numpy/core/src/arraytypes.c.src
@@ -1,6 +1,20 @@
/* -*- c -*- */
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
+
+#define _MULTIARRAYMODULE
+#define NPY_NO_PREFIX
+#include "numpy/arrayobject.h"
+#include "numpy/arrayscalars.h"
+
+#include "numpy/npy_math.h"
+#include "arrayobject.h"
#include "config.h"
+/* FIXME: this should be built separately */
+#include "numpyos.c"
+
static double
MyPyFloat_AsDouble(PyObject *obj)
{
@@ -2528,7 +2542,7 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {
(PyArray_FastTakeFunc*)@from@_fasttake
};
-static PyArray_Descr @from@_Descr = {
+NPY_NO_EXPORT PyArray_Descr @from@_Descr = {
PyObject_HEAD_INIT(&PyArrayDescr_Type)
&Py@NAME@ArrType_Type,
PyArray_@kind@LTR,
@@ -2627,7 +2641,7 @@ PyArray_DescrFromType(int type)
}
-static int
+NPY_NO_EXPORT int
set_typeinfo(PyObject *dict)
{
PyObject *infodict, *s;
diff --git a/numpy/core/src/hashdescr.c b/numpy/core/src/hashdescr.c
index b1f2bc01e..401fb0453 100644
--- a/numpy/core/src/hashdescr.c
+++ b/numpy/core/src/hashdescr.c
@@ -1,7 +1,10 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
+#define _MULTIARRAYMODULE
#include <numpy/ndarrayobject.h>
+#include "hashdescr.h"
+
/*
* How does this work ? The hash is computed from a list which contains all the
* information specific to a type. The hard work is to build the list
diff --git a/numpy/core/src/hashdescr.h b/numpy/core/src/hashdescr.h
new file mode 100644
index 000000000..b62b47ede
--- /dev/null
+++ b/numpy/core/src/hashdescr.h
@@ -0,0 +1,6 @@
+#ifndef _NPY_HASHDESCR_H_
+#define _NPY_HASHDESCR_H_
+
+long PyArray_DescrHash(PyObject* odescr);
+
+#endif
diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c
index fa62dbcc2..e284ad5e8 100644
--- a/numpy/core/src/multiarraymodule.c
+++ b/numpy/core/src/multiarraymodule.c
@@ -21,14 +21,21 @@
#define _MULTIARRAYMODULE
#define NPY_NO_PREFIX
#include "numpy/arrayobject.h"
+#include "numpy/arrayscalars.h"
+
+#include "numpy/npy_math.h"
#define PyAO PyArrayObject
-#include "hashdescr.c"
+/* Internal APIs */
+#include "arrayobject.h"
+#include "hashdescr.h"
+
+NPY_NO_EXPORT int NPY_NUMUSERTYPES = 0;
static PyObject *typeDict = NULL; /* Must be explicitly loaded */
-static PyArray_Descr *
+NPY_NO_EXPORT PyArray_Descr *
_arraydescr_fromobj(PyObject *obj)
{
PyObject *dtypedescr;
@@ -102,7 +109,7 @@ _arraydescr_fromobj(PyObject *obj)
* This file would just be the module calls.
*/
-#include "arrayobject.c"
+//#include "arrayobject.c"
/* An Error object -- rarely used? */
@@ -965,7 +972,7 @@ PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject *out,
return __New_PyArray_Std(self, axis, rtype, out, variance, 0);
}
-static PyObject *
+NPY_NO_EXPORT PyObject *
__New_PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject *out,
int variance, int num)
{
diff --git a/numpy/core/src/scalartypes.inc.src b/numpy/core/src/scalartypes.c.src
index f9081f19d..17060062f 100644
--- a/numpy/core/src/scalartypes.inc.src
+++ b/numpy/core/src/scalartypes.c.src
@@ -1,11 +1,17 @@
/* -*- c -*- */
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
#ifndef _MULTIARRAYMODULE
#define _MULTIARRAYMODULE
#endif
+#define NPY_NO_PREFIX
+#include "numpy/arrayobject.h"
#include "numpy/arrayscalars.h"
#include "config.h"
+#include "arrayobject.h"
#include "numpyos.c"
NPY_NO_EXPORT PyBoolScalarObject _PyArrayScalar_BoolValues[2] = {
@@ -85,7 +91,7 @@ NPY_NO_EXPORT PyTypeObject Py@NAME@ArrType_Type = {
};
/**end repeat**/
-static void *
+NPY_NO_EXPORT void *
scalar_value(PyObject *scalar, PyArray_Descr *descr)
{
int type_num;
@@ -684,7 +690,7 @@ gentype_repr(PyObject *self)
#define _FMT1 "%%.%i" NPY_@NAME@_FMT
#define _FMT2 "%%+.%i" NPY_@NAME@_FMT
-static void
+NPY_NO_EXPORT void
format_@name@(char *buf, size_t buflen, @name@ val, unsigned int prec)
{
/* XXX: Find a correct size here for format string */
@@ -1071,7 +1077,7 @@ gentype_size_get(PyObject *NPY_UNUSED(self))
return PyInt_FromLong(1);
}
-static void
+NPY_NO_EXPORT void
gentype_struct_free(void *ptr, void *arg)
{
PyArrayInterface *arrif = (PyArrayInterface *)ptr;
@@ -2974,13 +2980,6 @@ NPY_NO_EXPORT PyTypeObject PyObjectArrType_Type = {
#endif
};
-
-static PyObject *
-add_new_axes_0d(PyArrayObject *, int);
-
-static int
-count_new_axes_0d(PyObject *);
-
static PyObject *
gen_arrtype_subscript(PyObject *self, PyObject *key)
{
@@ -3276,7 +3275,7 @@ static PyNumberMethods longdoubletype_as_number;
static PyNumberMethods clongdoubletype_as_number;
-static void
+NPY_NO_EXPORT void
initialize_numeric_types(void)
{
PyGenericArrType_Type.tp_dealloc = (destructor)gentype_dealloc;
@@ -3431,7 +3430,7 @@ static PyTypeObject *typeobjects[] = {
&PyVoidArrType_Type
};
-static int
+NPY_NO_EXPORT int
_typenum_fromtypeobj(PyObject *type, int user)
{
int typenum, i;