numpy.matrix() in Python Last Updated : 09 Mar, 2022 Comments Improve Suggest changes Like Article Like Report This class returns a matrix from a string of data or array-like object. Matrix obtained is a specialised 2D array. Syntax : numpy.matrix(data, dtype = None) : Parameters : data : data needs to be array-like or string dtype : Data type of returned array. Returns : data interpreted as a matrix Python # Python Program illustrating # numpy.matrix class import numpy as geek # string input a = geek.matrix('1 2; 3 4') print("Via string input : \n", a, "\n\n") # array-like input b = geek.matrix([[5, 6, 7], [4, 6]]) print("Via array-like input : \n", b) Output : Via string input : [[1 2] [3 4]] Via array-like input : [[[5, 6, 7] [4, 6]]] References : https://docs.scipy.org/doc/numpy/reference/generated/numpy.mat.html#numpy.mat Note : These codes won't run on online IDE's. Please run them on your systems to explore the working . Comment More infoAdvertise with us Next Article numpy.matrix() in Python M Mohit Gupta_OMG Improve Article Tags : Misc Python Python-numpy Python numpy-Matrix Function Practice Tags : Miscpython Similar Reads numpy.matrix.A() function - Python numpy.matrix.A() function return self as an ndarray object. Syntax : numpy.matrix.A() Parameters : None Return : [ndarray] Return self as an ndarray. Code #1 : Python3 # Python program explaining # numpy.matrix.A() function # importing numpy as geek import numpy as geek mat = geek.matrix(geek.arange 1 min read Numpy matrix.I function | Python With the help ofnumpy.matrix.I() function we can get the multiplicative inverse of the same size as of our given matrix. Syntax : numpy.matrix.I() Return : [matrix object] If self is non-singular, ret is such that ret * self == self * ret == np.matrix(np.eye(self[0, :].size) all return True. Return 1 min read numpy.asmatrix() in Python numpy.asmatrix(data, dtype = None) Returns a matrix by interpreting the input as a matrix. Parameters : data : array-like input data dtype : Data type of returned array Returns : Interprets the input as a matrix Python # Python Programming illustrating # numpy.asmatrix import numpy as geek # array-l 1 min read numpy.multiply() in Python The numpy.multiply() is a numpy function in Python which is used to find element-wise multiplication of two arrays or scalar (single value). It returns the product of two input array element by element.Syntax:numpy.multiply(arr1, arr2, out=None, where=True, casting='same_kind', order='K', dtype=None 3 min read Python | Numpy numpy.matrix.A() With the help of Numpy numpy.matrix.A() method, we can get the same matrix as self. It means through this method we can get the identical matrix. Syntax : numpy.matrix.A() Return : Return self matrix Example #1 : In this example we can see that with the help of matrix.A() method, we are able to get 1 min read Like