def vec(X, order='F'):
    """Returns the vectorization of X.  Columns of X are stacked.  (The opposite of X.flatten()).""" 
    assert X.ndim == 2, 'vec operator requires a matrix.'
    
    return X.flatten(order=order)