dpnp.hamming

dpnp.hamming(M, device=None, usm_type=None, sycl_queue=None)[source]

Return the Hamming window.

The Hamming window is a taper formed by using a weighted cosine.

For full documentation refer to numpy.hamming.

Parameters:
  • M (int) -- Number of points in the output window. If zero or less, an empty array is returned.

  • device ({None, string, SyclDevice, SyclQueue, Device}, optional) --

    An array API concept of device where the output array is created. device can be None, a oneAPI filter selector string, an instance of dpctl.SyclDevice corresponding to a non-partitioned SYCL device, an instance of dpctl.SyclQueue, or a dpctl.tensor.Device object returned by dpnp.ndarray.device.

    Default: None.

  • usm_type ({None, "device", "shared", "host"}, optional) --

    The type of SYCL USM allocation for the output array.

    Default: None.

  • sycl_queue ({None, SyclQueue}, optional) --

    A SYCL queue to use for output array allocation and copying. The sycl_queue can be passed as None (the default), which means to get the SYCL queue from device keyword if present or to use a default queue.

    Default: None.

Returns:

out -- The window, with the maximum value normalized to one (the value one appears only if the number of samples is odd).

Return type:

dpnp.ndarray of shape (M,)

See also

dpnp.bartlett

Return the Bartlett window.

dpnp.blackman

Return the Blackman window.

dpnp.hanning

Return the Hanning window.

dpnp.kaiser

Return the Kaiser window.

Notes

The Hamming window is defined as

\[w(n) = 0.54 - 0.46\cos\left(\frac{2\pi{n}}{M-1}\right) \qquad 0 \leq n \leq M-1\]

Examples

>>> import dpnp as np
>>> np.hamming(12)
array([0.08      , 0.15302337, 0.34890909, 0.60546483, 0.84123594,
       0.98136677, 0.98136677, 0.84123594, 0.60546483, 0.34890909,
       0.15302337, 0.08      ])  # may vary

Creating the output array on a different device or with a specified usm_type:

>>> x = np.hamming(4) # default case
>>> x, x.device, x.usm_type
(array([0.08, 0.77, 0.77, 0.08]), Device(level_zero:gpu:0), 'device')
>>> y = np.hamming(4, device="cpu")
>>> y, y.device, y.usm_type
(array([0.08, 0.77, 0.77, 0.08]), Device(opencl:cpu:0), 'device')
>>> z = np.hamming(4, usm_type="host")
>>> z, z.device, z.usm_type
(array([0.08, 0.77, 0.77, 0.08]), Device(level_zero:gpu:0), 'host')