bundles / numpy 2.4.4 / numpy / asmatrix
function
numpy:asmatrix
source: /numpy/matrixlib/defmatrix.py:36
Signature
def asmatrix(data, dtype = None)Summary
Interpret the input as a matrix.
Extended Summary
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_likeInput data.
dtype: data-typeData-type of the output matrix.
Returns
mat: matrixdatainterpreted as a matrix.
Examples
import numpy as np x = np.array([[1, 2], [3, 4]])✓
m = np.asmatrix(x)
✓x[0,0] = 5
✓m
✓matrix([[5, 2],
[3, 4]])
Aliases
numpy.asmatrix