<

## Numpy Matrix Library

NumPy package contains a Matrix library numpy.matlib. This module has functions that return matrices instead of ndarray objects.

## matlib.empty() method

The matlib.empty() function returns a new matrix without initializing the entries.

```
import numpy as np

import numpy.matlib

print(numpy.matlib.empty((3,3)))  ```

output
```[[6.90262230e-310 6.90262230e-310 6.90262304e-310]
[6.90262304e-310 6.90261674e-310 6.90261552e-310]
[6.90261326e-310 6.90262311e-310 3.95252517e-322]]
```

## matlib.zeros() function

This function returns the matrix filled with zeros.

```
import numpy as np

import numpy.matlib

print(numpy.matlib.zeros((4,3)))
```

output
```
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
```

## matlib.ones() function

This function returns the matrix filled with 1s.

```import numpy as np

import numpy.matlib

print(numpy.matlib.ones((2,2)))

```

output
```[[1. 1.]
[1. 1.]]

```

## matlib.eye() function

This function returns a matrix with 1 along the diagonal elements and the zeros elsewhere.

```import numpy as np

import numpy.matlib

print(numpy.matlib.eye(n = 3, M = 3, k = 0, dtype = int))

```

output
```
[[1 0 0]
[0 1 0]
[0 0 1]]
```

## matlib.identity() function

The numpy.matlib.identity() function returns the Identity matrix of the given size. An identity matrix is a square matrix with all diagonal elements as 1.

```import numpy as np

import numpy.matlib

print(numpy.matlib.identity(5, dtype = int))

```

output
```
[[1 0 0 0 0]
[0 1 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 0 0 0 1]]
```

## matlib.rand() function

The numpy.matlib.rand() function returns a matrix of the given size filled with random values.

```
import numpy as np

import numpy.matlib

print(numpy.matlib.rand(3,3))
```

output
```
[[0.86201511 0.86980769 0.06704884]
[0.80531086 0.53814098 0.84394673]
[0.85653048 0.8146121  0.35744405]]

```