Python numpy.matlib.empty()函数
numpy.matlib.empty()函数返回一个给定形状和类型的新矩阵,无需初始化条目。
语法: numpy.matlib.empty(shape, dtype = None, order = ‘C’)
参数 :
shape : [int or tuple of int] 空矩阵的形状。
dtype : [data-type, optional] 希望输出的数据类型。
order : [{‘C’, ‘F’}, optional] 是否在内存中以行为主(C风格)或列为主(Fortran风格)的顺序存储多维数据。
返回: [矩阵] 一个具有给定形状和类型的新矩阵,没有初始化条目。
代码#1:
# Python program explaining
# numpy.matlib.empty() function
# importing numpy as geek
# and importing matlib module
import numpy as geek
import numpy.matlib
# filled with random data
gfg = geek.matlib.empty((2, 2))
# output will be random
print (gfg)
输出 :
[[ 6.91957648e-310 1.90383493e-316]
[ 6.91957669e-310 5.30409905e-317]]
代码#2:
# Python program explaining
# numpy.matlib.empty() function
# importing numpy as geek
# and importing matlib module
import numpy as geek
import numpy.matlib
# filled with random data
gfg = geek.matlib.empty((2, 2), dtype = int)
# output will be random
print (gfg)
输出 :
[[139855860099992 40294208]
[139855825297024 10730496]]