Pure Clojure radix-2 Cooley-Tukey FFT implementation.
Provides O(n log n) Fast Fourier Transform for autocorrelation computation. Uses interleaved complex representation [re0 im0 re1 im1 ...] for cache efficiency. All operations use primitive double arrays with zero garbage allocation during transform execution.
Main functions:
fft! / fft - Forward FFT (in-place / copying)ifft! / ifft - Inverse FFT (in-place / copying)next-power-of-2 - Find smallest power of 2 >= nzero-pad-real - Zero-pad real signal to power-of-2 lengthComplex arrays use interleaved format: [re0 im0 re1 im1 ...] Array length is 2*n where n is the number of complex samples.
Pure Clojure radix-2 Cooley-Tukey FFT implementation. Provides O(n log n) Fast Fourier Transform for autocorrelation computation. Uses interleaved complex representation [re0 im0 re1 im1 ...] for cache efficiency. All operations use primitive double arrays with zero garbage allocation during transform execution. Main functions: - `fft!` / `fft` - Forward FFT (in-place / copying) - `ifft!` / `ifft` - Inverse FFT (in-place / copying) - `next-power-of-2` - Find smallest power of 2 >= n - `zero-pad-real` - Zero-pad real signal to power-of-2 length Complex arrays use interleaved format: [re0 im0 re1 im1 ...] Array length is 2*n where n is the number of complex samples.
(complex->real complex-arr)Extracts real parts from interleaved complex array. Output length is half the input length.
Extracts real parts from interleaved complex array. Output length is half the input length.
(complex-magnitude complex-arr)Computes magnitude of each complex sample. Output length is half the input length.
Computes magnitude of each complex sample. Output length is half the input length.
(fft arr)Forward FFT on interleaved complex array. Returns a new array with the FFT result; input is not modified. The array must have length 2*n where n is a power of 2.
Input/output format: [re0 im0 re1 im1 ... re_{n-1} im_{n-1}]
Forward FFT on interleaved complex array.
Returns a new array with the FFT result; input is not modified.
The array must have length 2*n where n is a power of 2.
Input/output format: [re0 im0 re1 im1 ... re_{n-1} im_{n-1}](fft! arr)In-place forward FFT on interleaved complex array. The array must have length 2*n where n is a power of 2. Modifies arr in place and returns it.
Input/output format: [re0 im0 re1 im1 ... re_{n-1} im_{n-1}]
Uses standard DFT sign convention: X[k] = Σ x[n] * e^{-i 2π k n / N}
In-place forward FFT on interleaved complex array.
The array must have length 2*n where n is a power of 2.
Modifies arr in place and returns it.
Input/output format: [re0 im0 re1 im1 ... re_{n-1} im_{n-1}]
Uses standard DFT sign convention: X[k] = Σ x[n] * e^{-i 2π k n / N}(ifft arr)Inverse FFT on interleaved complex array. Returns a new array with the IFFT result; input is not modified. The array must have length 2*n where n is a power of 2. Result is scaled by 1/n.
Input/output format: [re0 im0 re1 im1 ... re_{n-1} im_{n-1}]
Inverse FFT on interleaved complex array.
Returns a new array with the IFFT result; input is not modified.
The array must have length 2*n where n is a power of 2.
Result is scaled by 1/n.
Input/output format: [re0 im0 re1 im1 ... re_{n-1} im_{n-1}](ifft! arr)In-place inverse FFT on interleaved complex array. The array must have length 2*n where n is a power of 2. Modifies arr in place and returns it. Result is scaled by 1/n.
Input/output format: [re0 im0 re1 im1 ... re_{n-1} im_{n-1}]
Uses standard IDFT sign convention: x[n] = (1/N) Σ X[k] * e^{+i 2π k n / N}
In-place inverse FFT on interleaved complex array.
The array must have length 2*n where n is a power of 2.
Modifies arr in place and returns it.
Result is scaled by 1/n.
Input/output format: [re0 im0 re1 im1 ... re_{n-1} im_{n-1}]
Uses standard IDFT sign convention: x[n] = (1/N) Σ X[k] * e^{+i 2π k n / N}(next-power-of-2 n)Returns the smallest power of 2 greater than or equal to n. For n <= 0, returns 1.
Returns the smallest power of 2 greater than or equal to n. For n <= 0, returns 1.
(power-of-2? n)Returns true if n is a positive power of 2.
Returns true if n is a positive power of 2.
(real->complex real-arr)Converts a real signal to interleaved complex format. Imaginary parts are set to zero. Output length is 2 * (length of input).
Converts a real signal to interleaved complex format. Imaginary parts are set to zero. Output length is 2 * (length of input).
(zero-pad-for-autocorrelation real-arr)Zero-pads a real signal to 2*next-power-of-2(n) for autocorrelation. This provides sufficient padding to compute circular correlation equivalent to linear correlation.
Zero-pads a real signal to 2*next-power-of-2(n) for autocorrelation. This provides sufficient padding to compute circular correlation equivalent to linear correlation.
(zero-pad-real real-arr)(zero-pad-real real-arr target-n)Zero-pads a real signal to the specified power-of-2 length. Returns interleaved complex array with zero imaginary parts. If target-n is not specified, pads to next power of 2 >= (length input). If target-n is specified, it must be a power of 2 >= (length input).
Zero-pads a real signal to the specified power-of-2 length. Returns interleaved complex array with zero imaginary parts. If target-n is not specified, pads to next power of 2 >= (length input). If target-n is specified, it must be a power of 2 >= (length input).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |