numpy.asmatrix()

numpy.asmatrix

numpy.asmatrix(data, dtype=None) [source]

Interpret the input as a matrix.

Unlike matrix, asmatrix does not make a copy if the input is already a matrix or an ndarray. Equivalent to matrix(data, copy=False).

Parameters:

data : array_like

Input data.

dtype : data-type

Data-type of the output matrix.

Returns:

mat : matrix

data interpreted as a matrix.

Examples

>>> x = np.array([[1, 2], [3, 4]])
>>> m = np.asmatrix(x)
>>> x[0,0] = 5
>>> m
matrix([[5, 2],
        [3, 4]])

© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.asmatrix.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部