title: Most Elegant Implementation of MATLAB's "vec" Function in NumPy
body: <p>In MATLAB there is a function referred to as <code>vec</code> that takes a matrix and stacks the columns into a single vector. For example if we call the following matrix "X":</p>
  
  <pre><code>[1 2]
  [3 4]
  </code></pre>
  
  <p>then <code>vec(X)</code> would return the vector:</p>
  
  <pre><code>[1]
  [3]
  [2]
  [4]
  </code></pre>
  
  <p>There doesn't seem to be any direct implementation of this, and the "<a href="http://mathesaurus.sourceforge.net/matlab-numpy.html" rel="noreferrer">NumPy for MATLAB users</a>" doesn't have a direct equivalent. </p>
  
  <p>So, if one is given a numpy array (representing the matrix), what would a very elegant line of NumPy be to reproduce this result? Just curious to see how concise / elegant this can be made. Thanks!</p>