matrix.flatten()
numpy.matrix.flatten
-
matrix.flatten(order='C')
[source] -
Return a flattened copy of the matrix.
All
N
elements of the matrix are placed into a single row.Parameters: order : {‘C’, ‘F’, ‘A’}, optional
Whether to flatten in C (row-major), Fortran (column-major) order, or preserve the C/Fortran ordering from
m
. The default is ‘C’.Returns: y : matrix
A copy of the matrix, flattened to a
(1, N)
matrix whereN
is the number of elements in the original matrix.Examples
>>> m = np.matrix([[1,2], [3,4]]) >>> m.flatten() matrix([[1, 2, 3, 4]]) >>> m.flatten('F') matrix([[1, 3, 2, 4]])
© 2008–2016 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.matrix.flatten.html