bundles / numpy latest / numpy / matrix
staticmethod
numpy:matrix
source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/__init__.py
Signature
staticmethod
def matrix ( data , dtype = None , copy = True ) Summary
Returns a matrix from an array-like object, or from a string of data.
Extended Summary
A matrix is a specialized 2-D array that retains its 2-D nature through operations. It has certain special operators, such as * (matrix multiplication) and ** (matrix power).
Parameters
data: array_like or stringIf
datais a string, it is interpreted as a matrix with commas or spaces separating columns, and semicolons separating rows.dtype: data-typeData-type of the output matrix.
copy: boolIf
datais already anndarray, then this flag determines whether the data is copied (the default), or whether a view is constructed.
Examples
import numpy as np a = np.matrix('1 2; 3 4') a✓
np.matrix([[1, 2], [3, 4]])
✓See also
- array
Aliases
-
numpy.matrix -
numpy.lib._index_tricks_impl.AxisConcatenator.makemat