On 1/11/07, David Cournapeau <[EMAIL PROTECTED]> wrote:
Travis Oliphant wrote: > > This is one thing I've exposed (and made use of in more than one place) > with NumPy. In Numeric, the magic was in a few lines of the ufuncobject > file). Now, it is exposed in the concept of an array iterator. Anybody > can take advantage of it as it there is a C-API call to get an array > iterator from the array (it's actually the object returned by the .flat > method). You can even get an iterator that iterates over one-less > dimension than the array has (with the dimension using the smallest > strides left "un-iterated" so that you can call an inner loop with it). The thing which confuses me is whether this is useful when you only one item of one array at a time. When I was implementing some functions for LPC, I took a look at your examples for array iterators and explanations in the numpy ebook, and it looked really helpful, indeed. For this kind of code, I needed to operate on several contiguous elements at a time. But here, for cliping with scalar min and max, I only need to access to one item at a time from the input array, and that's it; in particular, I don't care about the order of iteration. So the question really boils down to: "for a numpy array a of eg float32, am I guaranteed that a->data[sizeof(float32) * i] for 0 <= i < a.size gives me all the items of a, even for non contiguous arrays ?"
No. That is what the array iterator is for. Chuck
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion