TensorPlay
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-08

tensorplay.signal.windows.bartlett

tensorplay.signal.windows.bartlett(M: int, *, sym: bool = True, dtype: dtype | None = None, layout: Layout = tensorplay.strided, device: device | None = None, requires_grad: bool = False) → Tensor[source]

Computes the Bartlett window.

The samples form a triangle:

wn=1−∣2nM−1−1∣={2nM−1if 0≤n≤M−122−2nM−1if M−12<n<Mw_n = 1 - \left| \frac{2n}{M - 1} - 1 \right| = \begin{cases} \frac{2n}{M - 1} & \text{if } 0 \leq n \leq \frac{M - 1}{2} \\ 2 - \frac{2n}{M - 1} & \text{if } \frac{M - 1}{2} < n < M \\ \end{cases}

The window is scaled so that its largest value is 1. The value 1 itself does not occur when M is even and sym is 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: if None, uses the global default (see tensorplay.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: if None, uses the current default tensor device (see tensorplay.set_default_device()).

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

Examples:

>>> # Symmetric Bartlett window.
>>> tensorplay.signal.windows.bartlett(10)
tensor([0., 0.2222, 0.4444, 0.6667, 0.8889, 0.8889, 0.6667, 0.4444, 0.2222, 0.])

>>> # Periodic Bartlett window.
>>> tensorplay.signal.windows.bartlett(10, sym=False)
tensor([0., 0.2, 0.4, 0.6, 0.8, 1., 0.8, 0.6, 0.4, 0.2])

On this page

Ask DeepWiki