# The NumPy Fortran-ordering quiz

Travis Oliphant oliphant.travis at ieee.org
Tue Oct 17 20:53:11 CDT 2006

```Stefan van der Walt wrote:
> Hi all,
>
> Some of you may have seen the interesting thread on Fortran-ordering
> earlier.  I thought it might be fun to set up a short quiz which tests
> your knowledge on the topic.
>
> If you're up for the challenge, take a look at
>
> http://mentat.za.net/numpy/quiz
>
> I won't be held liable for any emotional trauma caused, self-inflicted
> wounds or brain-core meltdowns.
>

Cute (especially the comment if you get them all right).   I'm not sure
if this quiz is a veiled complaint about the rules for Fortran ordering
or not ;-)

In my mind the Fortran ordering rules are consistent (if not completely
bug-free).   You just have to get the right idea of what is meant by the
order argument when you use it.   If you think you are having trouble
figuring out the rules, think of the trouble it was to figure out what
they should be and then to code them up.

Two rules help you pass the quiz with a perfect score:

1) On array construction, the order argument allows you to specify how
the array will be organized in memory.  This has no effect on what is
printed as the user doesn't usually care how the array is stored in
memory.   So, you can ignore all order=  expressions in the array
construct for the quiz

2) On reshaping, the order argument specifies how you think the array is
organized.  Whenever you make a significant reshape you are telling the
computer to re-interpret the chunk of data in a different way, it makes
a big difference as to how you think about that chunk of data.  Do you
think of it as organized rows-first (C-order) or columns-first
(Fortran-order).   The order argument allows you to specify how you
think about it and indicates the 1-d indexing order of the array.  It
also fills in the newly-shaped array in exactly that same order.
Semantically, one could technically separate those two concepts and have
one order argument that specifies how you think about the input and
another that specifies how you think about the output.   But, I really
didn't want to go there and couldn't see a real advantage to that.  So,
the single order argument specifies how you think about both.

-Travis

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

```

More information about the Numpy-discussion mailing list