title: numpy array row major and column major
body: <p>I'm having trouble understanding how <code>numpy</code> stores its data. Consider the following:</p>
  
  <pre><code>&gt;&gt;&gt; import numpy as np
  &gt;&gt;&gt; a = np.ndarray(shape=(2,3), order='F')
  &gt;&gt;&gt; for i in xrange(6): a.itemset(i, i+1)
  ... 
  &gt;&gt;&gt; a
  array([[ 1.,  2.,  3.],
         [ 4.,  5.,  6.]])
  &gt;&gt;&gt; a.flags
    C_CONTIGUOUS : False
    F_CONTIGUOUS : True
    OWNDATA : True
    WRITEABLE : True
    ALIGNED : True
    UPDATEIFCOPY : False
  </code></pre>
  
  <p>This says that <code>a</code> is column major (<code>F_CONTIGUOUS</code>) thus, internally, <code>a</code> should look like the following:</p>
  
  <pre><code>[1, 4, 2, 5, 3, 6]
  </code></pre>
  
  <p>This is just what it is stated in in this <a href="http://docs.scipy.org/doc/numpy/glossary.html#term-column-major" rel="noreferrer">glossary</a>. What is confusing me is that if I try to to access the data of <code>a</code> in a linear fashion instead I get:</p>
  
  <pre><code>&gt;&gt;&gt; for i in xrange(6): print a.item(i)
  ... 
  1.0
  2.0
  3.0
  4.0
  5.0
  6.0
  </code></pre>
  
  <p>At this point I'm not sure what the <code>F_CONTIGUOUS</code> flag tells us since it does not honor the ordering. Apparently everything in python is row major and when we want to iterate in a linear fashion we can use the iterator <a href="http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#flat-iterator-indexing" rel="noreferrer"><code>flat</code></a>. </p>
  
  <p><strong>The question is the following:</strong> given that we have a list of numbers, say: <code>1, 2, 3, 4, 5, 6</code>, how can we create a <code>numpy</code> array of shape <code>(2, 3)</code> in column major order? That is how can I get a matrix that looks like this</p>
  
  <pre><code>array([[ 1.,  3.,  5.],
         [ 2.,  4.,  6.]])
  </code></pre>
  
  <p>I would really like to be able to iterate linearly over the list and place them into the newly created <code>ndarray</code>. The reason for this is because I will be reading files of multidimensional arrays set in column major order. </p>