pyffs.czt¶
Methods for computing the chirp Z-transform.
-
czt(x, A, W, M, axis=-1)[source]¶ Chirp Z-Transform.
This implementation follows the semantics defined in The Chirp Z-Transform.
- Parameters
- Returns
X – (…, M, …) transformed input along the axis indicated by axis.
- Return type
Notes
Due to numerical instability when using large M, this implementation only supports transforms where A and W have unit norm.
Examples
Implementation of the DFT:
>>> N = M = 10 >>> x = np.random.randn(N, 3) + 1j * np.random.randn(N, 3) # multi-dim >>> dft_x = np.fft.fft(x, axis=0) >>> czt_x = czt(x, A=1, W=np.exp(-1j * 2 * np.pi / N), M=M, axis=0) >>> np.allclose(dft_x, czt_x) True
Implementation of the iDFT:
>>> N = M = 10 >>> x = np.random.randn(N) + 1j * np.random.randn(N) >>> idft_x = np.fft.ifft(x) >>> czt_x = czt(x, A=1, W=np.exp(1j * 2 * np.pi / N), M=M) >>> np.allclose(idft_x, czt_x / N) # czt() does not do the scaling. True
-
cztn(x, A, W, M, axes=None)[source]¶ Multi-dimensional Chirp Z-transform.
- Parameters
x (
ndarray) – (…, N_1, N_2, …, N_D, …) input values.A (list(float or complex)) – Circular offset from the positive real-axis, for each dimension.
W (list(float or complex)) – Circular spacing between transform points, for each dimension.
axes (tuple) – Dimensions of x along which transform should be applied.
- Returns
x_czt – (…, M_1, M_2, …, M_D, …) transformed input along the axes indicated by axes.
- Return type
Notes
Due to numerical instability when using large M, this implementation only supports transforms where each element of A and W has unit norm.
Examples
Implementation of N-dimensional DFT:
>>> N = M = 10 >>> W = np.exp(-1j * 2 * np.pi / N) >>> x = np.random.randn(N, N, N) + 1j * np.random.randn(N, N, N) # extra dimension >>> dft_x = np.fft.fftn(x, axes=(1, 2)) >>> czt_x = cztn(x, A=[1, 1], W=[W, W], M=[M, M], axes=(1, 2)) >>> np.allclose(dft_x, czt_x) True