The NumPy module consists of a matrix library. The numpy.matlib()is used in NumPy for matrix functions. These functions return matrix values as output. It uses the array elements as input. Let us learn about NumPy Matrix Library and various functions in it.
We use this function to return a new matrix. The entries of the matrix are uninitialized. This function takes three parameters.
Syntax- np.matlib.empty(shape,dtype,order)
parameters and description
Output
[[1.21713744e-316 1.01855798e-312 1.01855798e-312]
[9.54898106e-313 1.14587773e-312 1.01855798e-312]
[1.23075756e-312 1.10343781e-312 1.10343781e-312]
[9.76118064e-313 1.08221785e-312 1.10343781e-312]
[1.20953760e-312 5.73572782e+169 8.32980114e+151]]
We use this function to initialize a new matrix. All the matrix elements are set to be zero.
Output
[[0. 0. 0.]
[0. 0. 0.]]
We use this function to initialize a new matrix. All the matrix elements are filled with 1 as its value.
Output
[[1. 1. 1. 1.]
[1. 1. 1. 1.]]
An identity matrix is a matrix with all its diagonal elements as 1 and all the other elements as zero. This function returns an identity matrix of a given size.
Output
[[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]]
We use this function to initialize a matrix with 1 as the diagonal elements and 0 otherwise. It has the following parameters
Syntax- np.matlib.eye(n,m,k,dtype)
parameters and description
#numpy tutorials #function