latest (dev)
Copy
Latest development documentation · Updated 2026-10-08
tensorplay.signal.windows.cosine
- tensorplay.signal.windows.cosine(M: int, *, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) Tensor[source]
Computes a window with a simple cosine waveform, also known as the sine window.
The samples follow
The 0.5 in the numerator shifts the sample positions by half a step, so the window starts and ends at non-zero values (for a symmetric window the first and last samples equal sin(pi / (2M))).
The window is scaled so that its largest value is 1. The value 1 itself does not occur when
Mis even andsymis True.- Parameters:
M (int) – number of points of the returned window.
- Keyword Arguments:
sym (bool, optional) – if False, returns a periodic window, which is the usual choice for spectral analysis. If True, returns a symmetric window, which is the usual choice for filter design. Default: True.
dtype (
tensorplay.dtype, optional) – the desired data type of the returned tensor. Default: ifNone, uses the global default (seetensorplay.set_default_dtype()).layout (
tensorplay.Layout, optional) – the desired layout of the returned tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of the returned tensor. Default: ifNone, uses the current default tensor device (seetensorplay.set_default_device()).requires_grad (bool, optional) – whether autograd should record operations on the returned tensor. Default:
False.
Examples:
>>> # Symmetric cosine window. >>> tensorplay.signal.windows.cosine(10) tensor([0.1564, 0.454, 0.7071, 0.891, 0.9877, 0.9877, 0.891, 0.7071, 0.454, 0.1564]) >>> # Periodic cosine window. >>> tensorplay.signal.windows.cosine(10, sym=False) tensor([0.1423, 0.4154, 0.6549, 0.8413, 0.9595, 1., 0.9595, 0.8413, 0.6549, 0.4154])
Help improve this page
Found an error, an unclear step, or a missing example?

