Liking cljdoc? Tell your friends :D

criterium.stats.fft

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.

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.
raw docstring

complex->realclj

(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.
sourceraw docstring

complex-magnitudeclj

(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.
sourceraw docstring

fftclj

(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}]
sourceraw docstring

fft!clj

(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}
sourceraw docstring

ifftclj

(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}]
sourceraw docstring

ifft!clj

(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}
sourceraw docstring

next-power-of-2clj

(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.
sourceraw docstring

power-of-2?clj

(power-of-2? n)

Returns true if n is a positive power of 2.

Returns true if n is a positive power of 2.
sourceraw docstring

real->complexclj

(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).
sourceraw docstring

zero-pad-for-autocorrelationclj

(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.
sourceraw docstring

zero-pad-realclj

(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).
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close