nlcpy.zeros_like

nlcpy.zeros_like(a, dtype=None, order='K', subok=False, shape=None)[source]

Returns an array of zeros with the same shape and type as a given array.

Parameters
aarray_like

The shape and dtype of a define these same attributes of the returned array.

dtypedtype, optional

Overrides the data type of the result.

order{‘C’, ‘F’, ‘A’, or ‘K’}, optional

Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.

subokbool, optional

Not implemented.

shapeint or sequence of ints, optional

Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.

Returns
outndarray

Array of zeros with the same shape and type as a.

See also

empty_like

Returns a new array with the same shape and type as a given array.

ones_like

Returns an array of ones with the same shape and type as a given array.

full_like

Returns a full array with the same shape and type as a given array.

zeros

Returns a new array of given shape and type, filled with zeros.

Examples

>>> import nlcpy as vp
>>> x = vp.arange(6)
>>> x = x.reshape((2, 3))
>>> x
array([[0, 1, 2],
       [3, 4, 5]])
>>> vp.zeros_like(x)
array([[0, 0, 0],
       [0, 0, 0]])
>>> y = vp.arange(3, dtype=float)
>>> y
array([0., 1., 2.])
>>> vp.zeros_like(y)
array([0., 0., 0.])