[Numpy-discussion] C vs. Fortran order -- misleading documentation?

David Goldsmith d.l.goldsmith@gmail....
Tue Jun 8 10:39:52 CDT 2010


On Tue, Jun 8, 2010 at 8:27 AM, Pavel Bazant <MaxPlanck@seznam.cz> wrote:

>
> > > Correct me if I am wrong, but the paragraph
> > >
> > > Note to those used to IDL or Fortran memory order as it relates to
> > > indexing. Numpy uses C-order indexing. That means that the last index
> > > usually (see xxx for exceptions) represents the most rapidly changing
> memory
> > > location, unlike Fortran or IDL, where the first index represents the
> most
> > > rapidly changing location in memory. This difference represents a great
> > > potential for confusion.
> > >
> > > in
> > >
> > > http://docs.scipy.org/doc/numpy/user/basics.indexing.html
> > >
> > > is quite misleading, as C-order means that the last index changes
> rapidly,
> > > not the
> > > memory location.
> > >
> > >
> > Any index can change rapidly, depending on whether is in an inner loop or
> > not. The important distinction between C and Fortran order is how indices
> > translate to memory locations. The documentation seems correct to me,
> > although it might make more sense to say the last index addresses a
> > contiguous range of memory. Of course, with modern processors, actual
> > physical memory can be mapped all over the place.
> >
> > Chuck
>
> To me, saying that the last index represents the most rapidly changing
> memory
> location means that if I change the last index, the memory location changes
> a lot, which is not true for C-order. So for C-order, supposed one scans
> the memory
> linearly (the desired scenario),  it is the last *index* that changes most
> rapidly.
>
> The inverted picture looks like this: For C-order,  changing the first
> index
> leads to the most rapid jump in *memory*.
>
> Still have the feeling the doc is very misleading at this important issue.
>
> Pavel
>

The distinction between your two perspectives is that one is using for-loop
traversal of indices, the other is using pointer-increment traversal of
memory; from each of your perspectives, your conclusions are "correct," but
my inclination is that the pointer-increment traversal of memory perspective
is closer to the "spirit" of the docstring, no?

DG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100608/25fff319/attachment.html 


More information about the NumPy-Discussion mailing list