[Numpy-svn] r3246 - trunk/numpy/core/include/numpy

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Oct 2 20:44:51 CDT 2006


Author: oliphant
Date: 2006-10-02 20:44:48 -0500 (Mon, 02 Oct 2006)
New Revision: 3246

Modified:
   trunk/numpy/core/include/numpy/ndarrayobject.h
Log:
experiment with iterator speed up.

Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2006-10-02 22:51:07 UTC (rev 3245)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2006-10-03 01:44:48 UTC (rev 3246)
@@ -1070,14 +1070,35 @@
                 }                                                       \
         }
 
-#define PyArray_ITER_NEXT(it) {                                         \
-        (it)->index++;                                          \
-        if ((it)->nd_m1 == 0) {                                         \
-                _PyArray_ITER_NEXT1(it);                                \
+#define _PyArray_ITER_NEXT3(it) {                                       \
+                if ((it)->coordinates[2] < (it)->dims_m1[2]) {          \
+                        (it)->coordinates[2]++;                         \
+                        (it)->dataptr += (it)->strides[2];              \
+                }                                                       \
+                else {                                                  \
+                        (it)->coordinates[2] = 0;                       \
+                        (it)->dataptr -= (it)->backstrides[2];          \
+                        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) {                                   \
+                _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 if ((it)->nd_m1 == 1) {                              \
+                _PyArray_ITER_NEXT2(it);                          \
         }                                                               \
         else {                                                          \
                 int __npy_i;                                            \



More information about the Numpy-svn mailing list