numpy
  1. numpy-numpymatlibempty

numpy.matlib.empty() - ( Matrix Operations with NumPy )

Heading h2

Syntax

numpy.matlib.empty(shape, dtype=float, order='C')

Example

import numpy.matlib
import numpy as np

# create an empty 3x3 matrix
empty_matrix = np.matlib.empty((3,3))
print(empty_matrix)

Output

[[1.20773878e-311 1.20773878e-311 1.20953760e-311]
 [1.20953760e-311 1.20773902e-311 1.20773940e-311]
 [1.20773928e-311 1.19733675e-311 3.95252517e-323]]

Explanation

The numpy.matlib.empty() function returns a new matrix with the specified shape and data type, but the elements of the matrix are not initialized. This function is similar to the built-in numpy.empty(), but it returns a matrix instead of an array.

Use

The numpy.matlib.empty() function can be used to create a matrix with a specific shape and data type. Initially, the matrix will not contain any values and may contain random values from memory. This function is useful for quickly creating a matrix of a specific size without filling in any values.

Important Points

  • numpy.matlib.empty() returns a new matrix with specified shape and data type, but the elements of the matrix are not initialized
  • This function is similar to the built-in numpy.empty(), but it returns a matrix instead of an array
  • Initially, the matrix will not contain any values and may contain random values from memory

Summary

In conclusion, the numpy.matlib.empty() function is a useful tool for creating a matrix of a specific shape and data type. However, the matrix returned by this function will not contain any values and may contain random values from memory. For a matrix with initialized values, consider using other functions such as numpy.zeros() or numpy.ones().

Published on: