fixed-fft

Crates.iofixed-fft
lib.rsfixed-fft
version0.1.0
sourcesrc
created_at2020-12-27 14:07:50.74942
updated_at2020-12-27 14:07:50.74942
descriptionFixed-point Fast Fourier Transform
homepage
repositoryhttps://github.com/kiffie/fixed-fft-rs
max_upload_size
id327844
size25,346
Stephan (kiffie)

documentation

README

Fixed-point Fast Fourier Transform

This "no-std" crate is intended for use with cores without an FPU and that can perform a fixed point FFT more quickly. The FFT code uses a signed 16 bit number format, which is interpreted as a Q15 format (i.e. one sign bit, 15 fractional bits).

The code was written under the assumption that a Count Leading Zeros (CLZ) instruction is available on the target architecture and that leading_zeros()uses this instruction.

This code was inspired by fix_fft.c, which is a very simple fixed-point FFT function written in C. The idea is to provide a simple, straightforward and target-independent FFT implementation.

Example with complex input data

use fixed_fft::{fft_radix2_q15, Direction};
use num_complex::Complex;

fn main() {
    let mut samples = [Complex::new(1000, 0); 8];

    println!("input data: {:?}", samples);
    fft_radix2_q15(&mut samples, Direction::Forward).unwrap();
    println!("output data: {:?}", samples);
}

Example with real input data

use fixed_fft::fft_radix2_real_q15;
use num_complex::Complex;

fn main() {
    let mut samples = [1000; 8];
    let mut result = [Complex::new(0, 0); 5];

    println!("input data: {:?}", samples);
    fft_radix2_real_q15(&mut samples, &mut result, false).unwrap();
    println!("output data: {:?}", result);
}
Commit count: 4

cargo fmt