dpnp.hanning¶
- dpnp.hanning(M, *, device=None, usm_type=None, sycl_queue=None)[source]¶
Return the Hanning window.
The Hanning window is a taper formed by using a weighted cosine.
For full documentation refer to
numpy.hanning.- Parameters:
- Mint
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 ofdpctl.SyclDevicecorresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue, or adpnp.tensor.Deviceobject returned bydpnp.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:
- outdpnp.ndarray of shape (M,)
The window, with the maximum value normalized to one (the value one appears only if the number of samples is odd).
See also
dpnp.bartlettReturn the Bartlett window.
dpnp.blackmanReturn the Blackman window.
dpnp.hammingReturn the Hamming window.
dpnp.kaiserReturn the Kaiser window.
Notes
The Hanning window is defined as
\[w(n) = 0.5 - 0.5\cos\left(\frac{2\pi{n}}{M-1}\right) \qquad 0 \leq n \leq M-1\]Examples
>>> import dpnp as np >>> np.hanning(12) array([0. , 0.07937323, 0.29229249, 0.57115742, 0.82743037, 0.97974649, 0.97974649, 0.82743037, 0.57115742, 0.29229249, 0.07937323, 0. ])
Creating the output array on a different device or with a specified usm_type:
>>> x = np.hanning(4) # default case >>> x, x.device, x.usm_type (array([0. , 0.75, 0.75, 0. ]), Device(level_zero:gpu:0), 'device')
>>> y = np.hanning(4, device="cpu") >>> y, y.device, y.usm_type (array([0. , 0.75, 0.75, 0. ]), Device(opencl:cpu:0), 'device')
>>> z = np.hanning(4, usm_type="host") >>> z, z.device, z.usm_type (array([0. , 0.75, 0.75, 0. ]), Device(level_zero:gpu:0), 'host')