New Tutorials:

# NumPy empty() function

In this tutorial, we will cover numpy.matlib.empty() function of the Numpy library.

The numpy.matlib.empty() function is used to return a new matrix having uninitialized entries.

The numpy.matlib is a matrix library used to configure matrices instead of ndarray objects.

### Syntax of matlib.empty():

The required syntax to use this function is as follows:

numpy.matlib.empty(shape,dtype,order)

Parameters:

Let us now cover the parameters used with this function:

• shape
This parameter is in the form of a tuple that is used to define the shape of the matrix.

• dtype
This parameter is used to indicate the data type of the matrix. The default value of this parameter is float. This is an optional parameter.

• order
This is an optional parameter that is used to indicate the insertion order of the matrix. It mainly indicates whether to store the result in C- or Fortran-contiguous order, The default value is 'C'.

Returned Values:

This function mainly returns a new matrix having initialized entries.

Now it's time to cover a few examples of this function:

## Example 1:

Given below is a basic example for the understanding of this function:

import numpy as np
import numpy.matlib

print(numpy.matlib.empty((4,4)))

[[ 0.00000000e+000 0.00000000e+000 0.00000000e+000 0.00000000e+000]
[ 0.00000000e+000 0.00000000e+000 0.00000000e+000 0.00000000e+000]
[ 8.61381863e+043 -1.94898979e-046 9.88131292e-324 0.00000000e+000]
[ 1.13635099e-322 0.00000000e+000 0.00000000e+000 0.00000000e+000]]

## Example 2:

Now we will also use type parameter in the code snippet given below:

import numpy as np
import numpy.matlib

print(numpy.matlib.empty((2,3), int))

[[-1192611712 306 0]
[ 0 131074 0]]

## Example 3:

In the below code example, we will also specify the third parameter which is order with the empty() function:

import numpy as np
import numpy.matlib

print(numpy.matlib.empty((4), int, 'C'))

[[ 0 0 65793 1]]

## Summary

In this tutorial we learned about numpy.empty() mathematical function in the Numpy library. We also covered its syntax, parameters as well as the value returned by this function along with code examples for it.