[ Web Proxy ]
URL:
Viewing: https://numpy.org/doc/stable/reference/generated/../generated/../generated/numpy.asmatrix.html [Back]  [Original]

numpy.asmatrix — NumPy v2.5 Manual
Back to top
Search the docs ...:

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:
dataarray_like

Input data.

dtypedata-type

Data-type of the output matrix.

Returns:
matmatrix

data interpreted as a matrix.

Examples

Try it in your browser!
>>> 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]])

Web Proxy Viewer  |  New URL  |  Original Page