constfft

A Rust library crate providing an [FFT] API for arrays. This crate wraps the [rustfft] and [realfft] crates that does the heavy lifting behind the scenes. Use constfft if you're working with [arrays], i.e. you know the size of the signal at compile time.

Advantages

Current limitations

Complex Signal Example:

```rust use approx::assertulpseq; use constfft::Complex; use constfft::Fft; use constfft::Ifft;

// Define a real-valued signal let realsignal = [1.0f64; 10];

// Call .fft on the signal to obtain it's discrete fourier transform let realsignaldft: [Complex; 10] = real_signal.fft();

// Call .ifft on the frequency domain signal to obtain it's inverse let realsignaldftidft: [Complex; 10] = realsignal_dft.ifft();

// Verify the resulting signal is a scaled value of the original signal for (original, manipulated) in realsignal.iter().zip(realsignaldftidft) { assertulpseq!(manipulated.re, original * realsignal.len() as f64); assertulps_eq!(manipulated.im, 0.0); }

// Define a complex-valued signal let complexsignal = [Complex::new(1.0f64, 0.0); 10];

// Call .fft on the signal to obtain it's discrete fourier transform let complexsignaldft: [Complex; 10] = complex_signal.fft();

// Call .ifft on the frequency domain signal to obtain it's inverse let complexsignaldftidft: [Complex; 10] = complexsignal_dft.ifft();

// Verify the resulting signal is a scaled value of the original signal for (original, manipulated) in complexsignal.iter().zip(complexsignaldftidft) { assertulpseq!(manipulated.re, original.re * complexsignal.len() as f64); assertulpseq!(manipulated.im, original.im * complexsignal.len() as f64); } ```

Real Signal Example:

See [crate::realfft] level documentation.

Possible future plans

Currently I don't see any reason why the same API (minus the compile time size checks) cannot be implementable on slices. This seems like a much nicer API to work with and AFAICT does not depend on the types to be arrays. If this is the case I'd implement the same API on slices and rename this crate to easyfft.

Footnotes

Currently you can create a RealDft struct and mutate it using the DerefMut trait in a way that the real_ifft method will cause a panic. This should be fixable in a future patch release currently pending implementation details. There could be other bugs in this crate or it's dependencies that may cause a panic, but in theory all the runtime panics have been moved to compile time errors.