<br><br><div><span class="gmail_quote">On 1/12/07, <b class="gmail_sendername">Charles R Harris</b> <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br><div><span class="q"><span class="gmail_quote">On 1/11/07, <b class="gmail_sendername">David Cournapeau</b> <<a href="mailto:david@ar.media.kyoto-u.ac.jp" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
david@ar.media.kyoto-u.ac.jp</a>> wrote:</span></span><span class="q"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Travis Oliphant wrote:<br>><br>> This is one thing I've exposed (and made use of in more than one place)<br>> with NumPy.  In Numeric, the magic was in a few lines of the ufuncobject<br>> file).  Now, it is exposed in the concept of an array iterator.  Anybody
<br>> can take advantage of it as it there is a C-API call to get an array<br>> iterator from the array (it's actually the object returned by the .flat<br>> method).   You can even get an iterator that iterates over one-less
<br>> dimension than the array has (with the dimension using the smallest<br>> strides left "un-iterated" so that you can call an inner loop with it).<br>The thing which confuses me is whether this is useful when you only one
<br>item of one array at a time. When I was implementing some functions for<br>LPC, I took a look at your examples for array iterators and explanations<br>in the numpy ebook, and it looked really helpful, indeed. For this kind
<br>of code, I needed to operate on several contiguous elements at a time.<br><br>But here, for cliping with scalar min and max, I only need to access to<br>one item at a time from the input array, and that's it; in particular, I
<br>don't care about the order of iteration. So the question really boils<br>down to:<br><br>"for a numpy array a of eg float32, am I guaranteed that<br>a->data[sizeof(float32) * i] for 0 <= i < a.size gives me all the items
<br>of a, even for non contiguous arrays ?"</blockquote></span><div><br>No. That is what the array iterator is for.</div></div></blockquote><div><br>Although it is pretty common to make a copy of the array that *is* contiguous and pass that down. Doing so keeps life simple for the programmer and is pretty much required when interfacing to third party c and fortran routines. 
</div><br>Chuck <br></div><br>