TensorPlay
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-15

tensorplay.functional.bartlett_window

tensorplay.functional.bartlett_window(window_length, periodic=True, *, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False) → Tensor[source]

Bartlett window function.

w[n]=1−∣2nN−1−1∣={2nN−1if 0≤n≤N−122−2nN−1if N−12<n<N,w[n] = 1 - \left| \frac{2n}{N-1} - 1 \right| = \begin{cases} \frac{2n}{N - 1} & \text{if } 0 \leq n \leq \frac{N - 1}{2} \\ 2 - \frac{2n}{N - 1} & \text{if } \frac{N - 1}{2} < n < N \\ \end{cases},

where NN is the full window size.

The input window_length is a positive integer controlling the returned window size. periodic flag determines whether the returned window trims off the last duplicate value from the symmetric window and is ready to be used as a periodic window with functions like tensorplay.stft(). Therefore, if periodic is true, the NN in above formula is in fact window_length+1\text{window\_length} + 1. Also, we always have tensorplay.bartlett_window(L, periodic=True) equal to tensorplay.bartlett_window(L + 1, periodic=False)[:-1]).

Note

If window_length =1=1, the returned window contains a single value 1.

Parameters:
  • window_length (int) – the size of returned window

  • periodic (bool, optional) – If True, returns a window to be used as periodic function. If False, return a symmetric window.

Keyword Arguments:
  • dtype (tensorplay.dtype, optional) – the desired data type of returned tensor. Default: if None, uses a global default (see tensorplay.set_default_dtype()). Only floating point types are supported.

  • layout (tensorplay.layout, optional) – the desired layout of returned window tensor. Only tensorplay.strided (dense layout) is supported.

  • device (tensorplay.device, optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see tensorplay.set_default_device()). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

  • requires_grad (bool, optional) – If autograd should record operations on the returned tensor. Default: False.

Returns:

A 1-D tensor of size (window_length,)(\text{window\_length},) containing the window

Return type:

Tensor

On this page

Ask DeepWiki