title: python column major and row major matrix
body: <p>how do i get the 1-D index of an element of a matrix?</p>
  
  <p>for example:</p>
  
  <pre><code>b=np.array([1, 2, 3, 4, 5, 6])
  c = b.reshape(2,3,order='F')#colmaj
  d = b.reshape(2,3)#rowmaj
  </code></pre>
  
  <p>this is c:</p>
  
  <pre><code>([[1, 3, 5],
   [2, 4, 6]])
  </code></pre>
  
  <p>this is d: </p>
  
  <pre><code>([[1, 2, 3],
   [4, 5, 6]])
  </code></pre>
  
  <p>if i do c[1,2] i get the element 6, and i need to get the index of the 1-D array which would be 5.  i can do this mentally but if i have a large matrix and need to select an element at random i won't be able to. i need to write functions to do this for both colmajor and rowmajor matrices.</p>
  
  <pre><code>def linearize_colmajor(i, j, m, n):        
          """
          Returns the linear index for the `(i, j)` entry of
          an `m`-by-`n` matrix stored in column-major order.
          """
  </code></pre>