zeros_like

zeros_like(a)

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

Parameters:
a : ndarray

The shape and data-type of a define these same attributes of the returned array.

Returns:
out : ndarray

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

Examples

>>> x = np.arange(6)
>>> x = x.reshape((2, 3))
>>> x
array([[0., 1., 2.],
       [3., 4., 5.]])
>>> np.zeros_like(x)
array([[0., 0., 0.],
       [0., 0., 0.]])
>>> y = np.arange(3, dtype=float)
>>> y
array([0., 1., 2.], dtype=float64)
>>>
>>> np.zeros_like(y)
array([0., 0., 0.], dtype=float64)