[Numpy-discussion] Cython numerical syntax revisited

Dag Sverre Seljebotn dagss@student.matnat.uio...
Thu Mar 5 07:09:26 CST 2009

Francesc Alted wrote:
> A Thursday 05 March 2009, Dag Sverre Seljebotn escrigué:
>> No, one could do the same thing that NumPy does (I think, never
>> looked into it in detail), i.e:
>> decide on dimension to do innermost dynamically from strides and
>> sizes save the stride in that dimension for each array
>> for loop using n-dimensional iterator with larger per-loop overhead:
>>    save offsets
>>    for loop on the innermost dimension with lower per-loop overhead:
>>        component-wise operation using offsets and innermost strides
> I see.  Yes, it seems definitely doable.  However, I don't understand 
> very well when you say that you have to "decide on dimension to do 
> innermost dynamically".  For me, this dimension should always be the 
> trailing dimension, in order to maximize the locality of data.  Or I'm 
> missing something?
For a transposed array (or Fortran-ordered one) it will be the leading. 
Not sure whether it is possible with other kinds of views (where e.g. a 
middle dimension varies fastest), but the NumPy model doesn't preclude 
it and I suppose it would be possible with stride_tricks.

Dag Sverre

More information about the Numpy-discussion mailing list