diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-07-18 12:47:39 -0500 |
---|---|---|
committer | Mark Wiebe <mwiebe@enthought.com> | 2011-07-19 14:00:28 -0500 |
commit | 57d6b5bebb039dc6b2b3c5a2cc7bfc8e2cc3fb98 (patch) | |
tree | cfaf79ee9fc6130486bbf4d820ed4ac0027f4012 /numpy/numarray/include | |
parent | db90bf507279dffa23e6546414b82dd28ecaf984 (diff) | |
download | numpy-57d6b5bebb039dc6b2b3c5a2cc7bfc8e2cc3fb98.tar.gz |
ENH: core: More cleanups removing direct PyArrayObject field access
Diffstat (limited to 'numpy/numarray/include')
-rw-r--r-- | numpy/numarray/include/numpy/nummacro.h | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/numpy/numarray/include/numpy/nummacro.h b/numpy/numarray/include/numpy/nummacro.h index e9acd6e31..6eb98ddd0 100644 --- a/numpy/numarray/include/numpy/nummacro.h +++ b/numpy/numarray/include/numpy/nummacro.h @@ -87,15 +87,15 @@ typedef enum /* from here down, type("ai") is NDInfo* */ #define NA_PTR(ai) ((char *) NA_OFFSETDATA((ai))) -#define NA_PTR1(ai, i) (NA_PTR(ai) + \ - (i)*(ai)->strides[0]) -#define NA_PTR2(ai, i, j) (NA_PTR(ai) + \ - (i)*(ai)->strides[0] + \ - (j)*(ai)->strides[1]) -#define NA_PTR3(ai, i, j, k) (NA_PTR(ai) + \ - (i)*(ai)->strides[0] + \ - (j)*(ai)->strides[1] + \ - (k)*(ai)->strides[2]) +#define NA_PTR1(ai, i) (NA_PTR(ai) + \ + (i)*PyArray_STRIDES(ai)[0]) +#define NA_PTR2(ai, i, j) (NA_PTR(ai) + \ + (i)*PyArray_STRIDES(ai)[0] + \ + (j)*PyArray_STRIDES(ai)[1]) +#define NA_PTR3(ai, i, j, k) (NA_PTR(ai) + \ + (i)*PyArray_STRIDES(ai)[0] + \ + (j)*PyArray_STRIDES(ai)[1] + \ + (k)*PyArray_STRIDES(ai)[2]) #define NA_SET_TEMP(ai, type, v) (((type *) &__temp__)[0] = v) @@ -238,10 +238,10 @@ _makeSetPa(Bool) /* fast (aligned, !byteswapped) */ #define NA_GETPf(ai, type, ptr) (*((type *) (ptr))) -#define NA_GETP(ai, type, ptr) \ - (PyArray_ISCARRAY(ai) ? NA_GETPf(ai, type, ptr) \ - : (PyArray_ISBYTESWAPPED(ai) ? \ - NA_GETPb(ai, type, ptr) \ +#define NA_GETP(ai, type, ptr) \ + (PyArray_ISCARRAY(ai) ? NA_GETPf(ai, type, ptr) \ + : (PyArray_ISBYTESWAPPED(ai) ? \ + NA_GETPb(ai, type, ptr) \ : NA_GETPa(ai, type, ptr))) /* NOTE: NA_SET* macros cannot be used as values. */ @@ -255,12 +255,12 @@ _makeSetPa(Bool) /* fast (aligned, !byteswapped) */ #define NA_SETPf(ai, type, ptr, v) ((*((type *) ptr)) = (v)) -#define NA_SETP(ai, type, ptr, v) \ - if (PyArray_ISCARRAY(ai)) { \ - NA_SETPf((ai), type, (ptr), (v)); \ - } else if (PyArray_ISBYTESWAPPED(ai)) { \ - NA_SETPb((ai), type, (ptr), (v)); \ - } else \ +#define NA_SETP(ai, type, ptr, v) \ + if (PyArray_ISCARRAY(ai)) { \ + NA_SETPf((ai), type, (ptr), (v)); \ + } else if (PyArray_ISBYTESWAPPED(ai)) { \ + NA_SETPb((ai), type, (ptr), (v)); \ + } else \ NA_SETPa((ai), type, (ptr), (v)) /* ========================== 1 index get/set ============================ */ @@ -315,29 +315,29 @@ _makeSetPa(Bool) #define NA_GET3(ai, type, i, j, k) NA_GETP(ai, type, NA_PTR3(ai, i, j, k)) /* byteswapping */ -#define NA_SET3b(ai, type, i, j, k, v) \ +#define NA_SET3b(ai, type, i, j, k, v) \ NA_SETPb(ai, type, NA_PTR3(ai, i, j, k), v) /* aligning */ -#define NA_SET3a(ai, type, i, j, k, v) \ +#define NA_SET3a(ai, type, i, j, k, v) \ NA_SETPa(ai, type, NA_PTR3(ai, i, j, k), v) /* fast (aligned, !byteswapped) */ -#define NA_SET3f(ai, type, i, j, k, v) \ +#define NA_SET3f(ai, type, i, j, k, v) \ NA_SETPf(ai, type, NA_PTR3(ai, i, j, k), v) -#define NA_SET3(ai, type, i, j, k, v) \ +#define NA_SET3(ai, type, i, j, k, v) \ NA_SETP(ai, type, NA_PTR3(ai, i, j, k), v) /* ========================== 1D get/set ================================== */ -#define NA_GET1Db(ai, type, base, cnt, out) \ - { int i, stride = ai->strides[ai->nd-1]; \ - for(i=0; i<cnt; i++) { \ - out[i] = NA_GETPb(ai, type, base); \ - base += stride; \ - } \ +#define NA_GET1Db(ai, type, base, cnt, out) \ + { int i, stride = PyArray_STRIDES(ai)[PyArray_NDIM(ai)-1]; \ + for(i=0; i<cnt; i++) { \ + out[i] = NA_GETPb(ai, type, base); \ + base += stride; \ + } \ } #define NA_GET1Da(ai, type, base, cnt, out) \ - { int i, stride = ai->strides[ai->nd-1]; \ + { int i, stride = PyArray_STRIDES(ai)[PyArray_NDIM(ai)-1]; \ for(i=0; i<cnt; i++) { \ out[i] = NA_GETPa(ai, type, base); \ base += stride; \ @@ -345,7 +345,7 @@ _makeSetPa(Bool) } #define NA_GET1Df(ai, type, base, cnt, out) \ - { int i, stride = ai->strides[ai->nd-1]; \ + { int i, stride = PyArray_STRIDES(ai)[PyArray_NDIM(ai)-1]; \ for(i=0; i<cnt; i++) { \ out[i] = NA_GETPf(ai, type, base); \ base += stride; \ @@ -362,7 +362,7 @@ _makeSetPa(Bool) } #define NA_SET1Db(ai, type, base, cnt, in) \ - { int i, stride = ai->strides[ai->nd-1]; \ + { int i, stride = PyArray_STRIDES(ai)[PyArray_NDIM(ai)-1]; \ for(i=0; i<cnt; i++) { \ NA_SETPb(ai, type, base, in[i]); \ base += stride; \ @@ -370,7 +370,7 @@ _makeSetPa(Bool) } #define NA_SET1Da(ai, type, base, cnt, in) \ - { int i, stride = ai->strides[ai->nd-1]; \ + { int i, stride = PyArray_STRIDES(ai)[PyArray_NDIM(ai)-1]; \ for(i=0; i<cnt; i++) { \ NA_SETPa(ai, type, base, in[i]); \ base += stride; \ @@ -378,7 +378,7 @@ _makeSetPa(Bool) } #define NA_SET1Df(ai, type, base, cnt, in) \ - { int i, stride = ai->strides[ai->nd-1]; \ + { int i, stride = PyArray_STRIDES(ai)[PyArray_NDIM(ai)-1]; \ for(i=0; i<cnt; i++) { \ NA_SETPf(ai, type, base, in[i]); \ base += stride; \ @@ -412,7 +412,7 @@ _makeSetPa(Bool) #define BOOLEAN_BITWISE_NOT(x) ((x) ^ 1) -#define NA_NBYTES(a) (a->descr->elsize * NA_elements(a)) +#define NA_NBYTES(a) (PyArray_DESCR(a)->elsize * NA_elements(a)) #if defined(NA_SMP) #define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS |