Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.matrix.squeeze

matrix.squeeze(axis=None)[source]

Return a possibly reshaped matrix.

Refer tonumpy.squeeze for more documentation.

Parameters:

axis : None or int or tuple of ints, optional

Selects a subset of the single-dimensional entries in the shape.If an axis is selected with shape entry greater than one,an error is raised.

Returns:

squeezed : matrix

The matrix, but as a (1, N) matrix if it had shape (N, 1).

See also

numpy.squeeze
related function

Notes

Ifm has a single column then that column is returnedas the single row of a matrix. Otherwisem is returned.The returned matrix is always eitherm itself or a view intom.Supplying an axis keyword argument will not affect the returned matrixbut it may cause an error to be raised.

Examples

>>>c=np.matrix([[1],[2]])>>>cmatrix([[1],        [2]])>>>c.squeeze()matrix([[1, 2]])>>>r=c.T>>>rmatrix([[1, 2]])>>>r.squeeze()matrix([[1, 2]])>>>m=np.matrix([[1,2],[3,4]])>>>m.squeeze()matrix([[1, 2],        [3, 4]])

Previous topic

numpy.matrix.sort

Next topic

numpy.matrix.std

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp