torch.bartlett_window#
- torch.bartlett_window(window_length, periodic=True, *, dtype=None, layout=torch.strided, device=None, requires_grad=False) Tensor #
Bartlett window function.
w[n]=1−N−12n−1={N−12n2−N−12nif 0≤n≤2N−1if 2N−1<n<N,where N 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 liketorch.stft()
. Therefore, ifperiodic
is true, the N in above formula is in fact window_length+1. Also, we always havetorch.bartlett_window(L, periodic=True)
equal totorch.bartlett_window(L + 1, periodic=False)[:-1])
.Note
If
window_length
=1, the returned window contains a single value 1.- Parameters
- Keyword Arguments
dtype (
torch.dtype
, optional) – the desired data type of returned tensor. Default: ifNone
, uses a global default (seetorch.set_default_dtype()
). Only floating point types are supported.layout (
torch.layout
, optional) – the desired layout of returned window tensor. Onlytorch.strided
(dense layout) is supported.device (
torch.device
, optional) – the desired device of returned tensor. Default: ifNone
, uses the current device for the default tensor type (seetorch.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,) containing the window
- Return type