summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2009-07-21 05:37:21 +0000
committerDavid Cournapeau <cournape@gmail.com>2009-07-21 05:37:21 +0000
commitbf58af82ac685fc62cdf8f51308806db85f25563 (patch)
tree520ff73e265676d0cd9429291a34a7a6e8dd5120
parent97da6e6fa99ec5696d966ede7be2da7bf4d96d80 (diff)
downloadnumpy-bf58af82ac685fc62cdf8f51308806db85f25563.tar.gz
Add cicular mode-specific public API to advance/reset pointers.
-rw-r--r--numpy/core/include/numpy/_neighborhood_iterator_imp.h28
-rw-r--r--numpy/core/include/numpy/ndarrayobject.h5
2 files changed, 33 insertions, 0 deletions
diff --git a/numpy/core/include/numpy/_neighborhood_iterator_imp.h b/numpy/core/include/numpy/_neighborhood_iterator_imp.h
index 533208229..809598caa 100644
--- a/numpy/core/include/numpy/_neighborhood_iterator_imp.h
+++ b/numpy/core/include/numpy/_neighborhood_iterator_imp.h
@@ -10,6 +10,8 @@ static NPY_INLINE int
_PyArrayNeighborhoodIter_SetPtrConstant(PyArrayNeighborhoodIterObject* iter);
static NPY_INLINE int
_PyArrayNeighborhoodIter_SetPtrMirror(PyArrayNeighborhoodIterObject* iter);
+static NPY_INLINE int
+_PyArrayNeighborhoodIter_SetPtrCircular(PyArrayNeighborhoodIterObject* iter);
/*
* Update to next item of the iterator
@@ -237,6 +239,17 @@ int PyArrayNeighborhoodIter_NextMirror(PyArrayNeighborhoodIterObject* iter)
return 0;
}
+static NPY_INLINE
+int PyArrayNeighborhoodIter_NextCircular(PyArrayNeighborhoodIterObject* iter)
+{
+ assert(iter->mode == NPY_NEIGHBORHOOD_ITER_CIRCULAR_PADDING);
+
+ _PyArrayNeighborhoodIter_IncrCoord(iter);
+ _PyArrayNeighborhoodIter_SetPtrCircular(iter);
+
+ return 0;
+}
+
static NPY_INLINE int PyArrayNeighborhoodIter_Next(PyArrayNeighborhoodIterObject* iter)
{
_PyArrayNeighborhoodIter_IncrCoord (iter);
@@ -293,6 +306,21 @@ PyArrayNeighborhoodIter_ResetMirror(PyArrayNeighborhoodIterObject* iter)
}
static NPY_INLINE int
+PyArrayNeighborhoodIter_ResetCircular(PyArrayNeighborhoodIterObject* iter)
+{
+ int i;
+
+ assert(iter->mode == NPY_NEIGHBORHOOD_ITER_CIRCULAR_PADDING);
+
+ for (i = 0; i < iter->nd; ++i) {
+ iter->coordinates[i] = iter->bounds[i][0];
+ }
+ _PyArrayNeighborhoodIter_SetPtrCircular(iter);
+
+ return 0;
+}
+
+static NPY_INLINE int
PyArrayNeighborhoodIter_Reset(PyArrayNeighborhoodIterObject* iter)
{
int i;
diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h
index 2a4e21495..5d50ad87f 100644
--- a/numpy/core/include/numpy/ndarrayobject.h
+++ b/numpy/core/include/numpy/ndarrayobject.h
@@ -983,6 +983,11 @@ PyArrayNeighborhoodIter_ResetMirror(PyArrayNeighborhoodIterObject* iter);
static NPY_INLINE int
PyArrayNeighborhoodIter_NextMirror(PyArrayNeighborhoodIterObject* iter);
+static NPY_INLINE int
+PyArrayNeighborhoodIter_ResetCircular(PyArrayNeighborhoodIterObject* iter);
+static NPY_INLINE int
+PyArrayNeighborhoodIter_NextCircular(PyArrayNeighborhoodIterObject* iter);
+
/* Include inline implementations - functions defined there are not considered
* public API */
#define _NPY_INCLUDE_NEIGHBORHOOD_IMP