Skip to content

Instantly share code, notes, and snippets.

Created Nov 8, 2018
What would you like to do?
Numpy Elementwise Iterator
/*********************** Element-wise Array Iterator ***********************/
/* Aided by Peter J. Verveer's nd_image package and numpy's arraymap ****/
/* and Python's array iterator ***/
/* get the dataptr from its current coordinates for simple iterator */
static char*
get_ptr_simple(PyArrayIterObject* iter, npy_intp *coordinates)
npy_intp i;
char *ret;
ret = PyArray_DATA(iter->ao);
for(i = 0; i < PyArray_NDIM(iter->ao); ++i) {
ret += coordinates[i] * iter->strides[i];
return ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment