def vec(x):
    """Vectorizes a matrix by stacking the columns.
    
    NumPy arrays use row major ordering, while MATLAB uses column major
    ordering. Therefore in NumPy `reshape((-1, 1))` stacks the rows instead of
    columns.
    
    This function is just a shorthand for `reshape((-1, 1), order='F')`.

    Args:
        x: An ndarray to be vectorized.
    """
    return x.reshape((-1, 1), order='F')