numpy.asmatrix(data, dtype=None)
Interpret the input as a matrix.
Unlike
,
does not make a copy if the input is already a matrix or an ndarray. Equivalent to matrix(data,copy=False).
Parameters:dataarray_likeInput data.
dtypedata-typeData-type of the output matrix.
Returns:matmatrixdata interpreted as a matrix.
Examples
>>> importnumpyasnp>>> x=np.array([[1,2],[3,4]])>>> m=np.asmatrix(x)>>> x[0,0]=5>>> mmatrix([[5, 2], [3, 4]])