torch.signal.windows.bartlett¶
- torch.signal.windows.bartlett(M, *, sym=True, dtype=None, layout=torch.strided, device=None, requires_grad=False)[source][source]¶
计算 Bartlett 窗函数。
Bartlett 窗函数定义如下:
该窗函数被归一化为 1(最大值为 1)。然而,如果
M
是偶数且sym
为 True,则最大值 1 不会出现在结果中。- 参数
M (int) – 窗函数的长度,换句话说,返回的窗函数的点数。
- 关键字参数
sym (bool, optional) – 如果为 False,返回适用于谱分析的周期窗函数。如果为 True,返回适用于滤波器设计的对称窗函数。默认值:True。
dtype (
torch.dtype
, optional) – 返回张量所需的数据类型。默认值:如果为None
,则使用全局默认设置(参见torch.set_default_dtype()
)。layout (
torch.layout
, optional) – 返回张量所需的内存布局。默认值:torch.strided
。device (
torch.device
, optional) – 返回张量所需的设备。默认值:如果为None
,则使用默认张量类型的当前设备(参见torch.set_default_device()
)。对于 CPU 张量类型,device
将是 CPU;对于 CUDA 张量类型,将是当前的 CUDA 设备。requires_grad (bool, optional) – 如果 autograd 应该记录返回张量上的操作,则为
True
。默认值:False
。
- 返回类型
示例
>>> # Generates a symmetric Bartlett window. >>> torch.signal.windows.bartlett(10) tensor([0.0000, 0.2222, 0.4444, 0.6667, 0.8889, 0.8889, 0.6667, 0.4444, 0.2222, 0.0000]) >>> # Generates a periodic Bartlett window. >>> torch.signal.windows.bartlett(10, sym=False) tensor([0.0000, 0.2000, 0.4000, 0.6000, 0.8000, 1.0000, 0.8000, 0.6000, 0.4000, 0.2000])