Numpy has a matrix library which has all the function in numpy subspace. It will return matrices instead of nd-arrays.
Some functions are like empty, zeros, ones, eyes. Some of them we have already seen but they return nd-arrays. This library will return matrices.
Let’s see some example with the function of this library.
This function has 3 parameters
- Shape -> shape of the matrix
- dtype -> data type of values
- order -> col major or row major
This function has also 3 parameters
You can’t remember all parameters, some are optional some are necessary like shape here. You can refer to the document for the parameters or One will be used to if using more.
Here parameters are -:
- n -> no. of rows, not optional
- M -> by default M=n, optional
- k -> 0=> main diagonal, positive no=> upper diagonal, negative no=> lower diagonal
- dtype -> data type.
Let’s discuss these methods
There are many other functions in this matrix library. You can go to the documentation for other functions. Hope you are ready, how to use these functions.
Stay tuned! Keep learning with us.