numpy.matlib.zeros

matlib.zeros(shape, dtype=None, order='C')[源代码]

返回给定形状和类型的矩阵,用零填充。

参数
shapeint或int序列

矩阵的形状

dtype数据类型,可选

矩阵所需的数据类型,默认为float。

order'C'、'F',可选

无论是以C或Fortran连续顺序存储结果,默认值都是“C”。

返回
out矩阵

给定形状、数据类型和顺序的零矩阵。

参见

numpy.zeros

等效数组函数。

matlib.ones

返回1的矩阵。

笔记

如果 shape 长度为1,即 (N,) ,或是一个标量 Nout 成为单行形状矩阵 (1,N) .

实例

>>> import numpy.matlib
>>> np.matlib.zeros((2, 3))
matrix([[0.,  0.,  0.],
        [0.,  0.,  0.]])
>>> np.matlib.zeros(2)
matrix([[0.,  0.]])