general_cosine(M: int, a: list[float] | tuple[float, ...], sym: bool = True, dtype: DTypeLike = None, device: DeviceLike = None)Generic weighted sum of cosines.
Builds a window of the form , the parent family from which Hann, Hamming, Blackman, Nuttall, and the flat-top window all derive. Allows custom coefficient designs for bespoke side-lobe characteristics.
Parameters
MintNumber of samples in the output window; must be
>= 0.alist of float or tuple of floatCoefficients . The -th
coefficient multiplies .
symbool= TrueSymmetric (
True, default) or periodic (False) variant.dtypeDTypeLike= NoneDesired dtype of the output tensor.
deviceDeviceLike= NoneTarget device for the output tensor.
Returns
Tensor1-D tensor of length M.
Notes
Sample formula:
Common special cases:
- Hann:
[0.5, 0.5]. - Hamming:
[0.54, 0.46]. - Blackman:
[0.42, 0.50, 0.08]. - Nuttall:
[0.3635819, 0.4891775, 0.1365995, 0.0106411].
Examples
>>> from lucid.signal.windows import general_cosine
>>> general_cosine(5, [0.54, 0.46]) # Hamming, as a two-term cosine sum
tensor([0.08, 0.54, 1., 0.54, 0.08])Used by 1
- lucid._ops.composite.spectral