Matrix Library

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.

1. empty()

This function has 3 parameters

  1. Shape -> shape of the matrix
  2. dtype -> data type of values
  3. order -> col major or row major

2. zeros()

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.

3. eye()

Here parameters are -:

  1. n -> no. of rows, not optional
  2. M -> by default M=n, optional
  3. k -> 0=> main diagonal, positive no=> upper diagonal, negative no=> lower diagonal
  4. dtype -> data type.

4. rand()

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.

Close Menu