numpy.asmatrix的用法

学习的过程中,遇到了asmatrix的用法,看了一下官方文档,明白了。

numpy.asmatrix

numpy.asmatrix(datadtype=None)[source]

Interpret the input as a matrix.

Unlike matrixasmatrix 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]])
原文地址:https://www.cnblogs.com/tianqianlan/p/10427552.html