summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/code_generators/generate_array_api.py6
-rw-r--r--numpy/core/include/numpy/arrayobject.h40
-rw-r--r--numpy/core/src/arraytypes.inc.src8
3 files changed, 37 insertions, 17 deletions
diff --git a/numpy/core/code_generators/generate_array_api.py b/numpy/core/code_generators/generate_array_api.py
index e60920eb1..8c76d3539 100644
--- a/numpy/core/code_generators/generate_array_api.py
+++ b/numpy/core/code_generators/generate_array_api.py
@@ -64,9 +64,9 @@ import_array(void)
if (PyArray_API == NULL) return -1;
/* Perform runtime check of C API version */
if (NDARRAY_VERSION != PyArray_GetNDArrayCVersion()) {
- PyErr_Format(PyExc_RuntimeError, "numpy C-API mismatch: module "\
- "compiled against version %%X but this version of numpy is %%X", \
- (uint) PyArray_GetNDArrayCVersion(), (uint) NDARRAY_VERSION);
+ PyErr_Format(PyExc_RuntimeError, "module compiled against "\
+ "version %%x of C-API but this version of numpy is %%x", \
+ (int) PyArray_GetNDArrayCVersion(), (int) NDARRAY_VERSION);
return -1;
}
return 0;
diff --git a/numpy/core/include/numpy/arrayobject.h b/numpy/core/include/numpy/arrayobject.h
index 9d2ebab4b..0330e5842 100644
--- a/numpy/core/include/numpy/arrayobject.h
+++ b/numpy/core/include/numpy/arrayobject.h
@@ -74,7 +74,7 @@ extern "C" {
#define PY_SUCCEED 1
/* Helpful to distinguish what is installed */
-#define NDARRAY_VERSION 0x000904
+#define NDARRAY_VERSION 0x00090401
/* Some platforms don't define bool, long long, or long double.
Handle that here.
@@ -803,6 +803,11 @@ typedef struct {
PyArray_GetItemFunc *getitem;
PyArray_SetItemFunc *setitem;
+ /* Copy and/or swap data. Memory areas may not overlap */
+ /* Use memmove first if they might */
+ PyArray_CopySwapNFunc *copyswapn;
+ PyArray_CopySwapFunc *copyswap;
+
/* Function to compare items */
PyArray_CompareFunc *compare;
@@ -816,10 +821,6 @@ typedef struct {
place a single value plus possible separator */
PyArray_ScanFunc *scanfunc;
- /* Copy and/or swap data. Memory areas may not overlap */
- /* Use memmove first if they might */
- PyArray_CopySwapNFunc *copyswapn;
- PyArray_CopySwapFunc *copyswap;
/* Function to determine if data is zero or not */
PyArray_NonzeroFunc *nonzero;
@@ -1010,14 +1011,33 @@ typedef struct {
memset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp)); \
}
-
+#define _PyArray_ITER_NEXT1(it) { \
+ it->dataptr += it->strides[0]; \
+ it->coordinates[0]++; \
+ }
+
+#define _PyArray_ITER_NEXT2(it) { \
+ if (it->coordinates[1] < it->dims_m1[1]) { \
+ it->coordinates[1]++; \
+ it->dataptr += it->strides[1]; \
+ } \
+ else { \
+ it->coordinates[1] = 0; \
+ it->coordinates[0]++; \
+ it->dataptr += it->strides[0] - \
+ it->backstrides[1]; \
+ } \
+ }
+
#define PyArray_ITER_NEXT(it) { \
it->index++; \
- if (it->nd_m1 == 0) { \
- it->dataptr += it->strides[0]; \
- it->coordinates[0]++; \
- } \
+ if (it->nd_m1 == 0) { \
+ _PyArray_ITER_NEXT1(it); \
+ } \
else if (it->contiguous) it->dataptr += it->ao->descr->elsize; \
+ else if (it->nd_m1 == 1) { \
+ _PyArray_ITER_NEXT2(it); \
+ } \
else { \
int _i_; \
for (_i_ = it->nd_m1; _i_ >= 0; _i_--) { \
diff --git a/numpy/core/src/arraytypes.inc.src b/numpy/core/src/arraytypes.inc.src
index 869f7113d..3632c7f6b 100644
--- a/numpy/core/src/arraytypes.inc.src
+++ b/numpy/core/src/arraytypes.inc.src
@@ -1616,12 +1616,12 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {
},
(PyArray_GetItemFunc*)@from@_getitem,
(PyArray_SetItemFunc*)@from@_setitem,
+ (PyArray_CopySwapNFunc*)@from@_copyswapn,
+ (PyArray_CopySwapFunc*)@from@_copyswap,
(PyArray_CompareFunc*)@from@_compare,
(PyArray_ArgFunc*)@from@_argmax,
(PyArray_DotFunc*)NULL,
(PyArray_ScanFunc*)@from@_scan,
- (PyArray_CopySwapNFunc*)@from@_copyswapn,
- (PyArray_CopySwapFunc*)@from@_copyswap,
(PyArray_NonzeroFunc*)@from@_nonzero,
(PyArray_FillFunc*)NULL,
{
@@ -1684,12 +1684,12 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {
},
(PyArray_GetItemFunc*)@from@_getitem,
(PyArray_SetItemFunc*)@from@_setitem,
+ (PyArray_CopySwapNFunc*)@from@_copyswapn,
+ (PyArray_CopySwapFunc*)@from@_copyswap,
(PyArray_CompareFunc*)@from@_compare,
(PyArray_ArgFunc*)@from@_argmax,
(PyArray_DotFunc*)@from@_dot,
(PyArray_ScanFunc*)@from@_scan,
- (PyArray_CopySwapNFunc*)@from@_copyswapn,
- (PyArray_CopySwapFunc*)@from@_copyswap,
(PyArray_NonzeroFunc*)@from@_nonzero,
(PyArray_FillFunc*)@from@_fill,
{