nlcpy.zeros
- nlcpy.zeros(shape, dtype=<class 'float'>, order='C')[ソース]
Returns a new array of given shape and type, filled with zeros.
- Parameters
- shapeint or sequence of ints
Shape of the new array, e.g.,
(2, 3)
or2
.- dtypedtype, optional
The desired dtype for the array, e.g,
nlcpy.int64
. Default isnlcpy.float64
.- order{'C', 'F'}, optional
Whether to store multi-dimensional data in row-major (C-style) or column-major (Fortran-style) order in memory.
- Returns
- outndarray
Array of zeros with the given shape, dtype, and order.
参考
zeros_like
Returns an array of zeros with the same shape and type as a given array.
empty
Returns a new array of given shape and type, without initializing entries.
ones
Returns a new array of given shape and type, filled with ones.
full
Returns a new array of given shape and type, filled with fill_value.
Examples
>>> import nlcpy as vp >>> vp.zeros(5) array([0., 0., 0., 0., 0.]) >>> vp.zeros((5,), dtype=int) array([0, 0, 0, 0, 0]) >>> vp.zeros((2, 1)) array([[0.], [0.]]) >>> s = (2,2) >>> vp.zeros(s) array([[0., 0.], [0., 0.]])