No project description provided
Project description
How to use
This program performs a 2048 point integer FFT on 32 bit integer data in numpy serialized arrays, files with the .npy
extention. If you'd like to add flexibility, feel free to play with the code, I did my best to make it easy to adapt.
Clone this repository
git clone https://github.com/dcxSt/dft_algos.git
Change directory
cd dft_algos/fftrs
Build the binaries with cargo (install instructions for cargo here)
cargo build --release
Copy the binary program that you just compiled into, wherever you want it to be (perhaps the same place as your simulated data)
cp target/release/fftrs /any/directory/you/want/
Go into the directory you just copied the binary into. Run the program, supplying three arguments
./fftrs <name of npy file.npy> <nbitshift> <number of bits for data> <number of sine bits>
The number of bits to shift the input (so that the inter-butterfly stage scaling doesn't kill the signal) is the first input <nbitshift>
after the name of the npy file. The number of sine bits <number of sine bits>
can be at most 16, and the number of bits used for the real and imaginary parts, each. Since we are doing 64bit integers, this number must be at most 23, because 23 + 23 + 16 + 2 = 64, (the plus two is because we add things together and it's to prevent overflow).
For instance
./fftrs dc100.npy 8 18 16
It will output the DFT info files <input_file_basename>_out_real.npy
and <output_file_basename>_out_imag.npy
. Have fun.
Dev Notes
Reminder: The optimal STD to select for the FT of an 8-bit quantized input is 35. I.e. when generating simulated data scale your gaussian noise by 35 before throwing converting to int and throwing it into the integer FFT.
Remark: if you'd like to display trace, debug or info logging statements, run RUST_LOG=trace cargo run
pyo3
breaks if on Apple's ARM machines if you don't have the following in your ~/cargo/config
, as pointed out by Dennis in StackOverflow
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
TODO
-
python bindings
-
Refactor naming convention, put thought into this
-
variable sized power-of-two FFTs
- Switch to vector instead of static sized array?
-
increase capacity (sine way up to 1<<16 instead of 1<<11)
-
Change twiddle factors to 32i to expand range
-
Change how it's coded so that rounding of twiddle factors is done well not just with the bitshift operator >> will induce bias, make sine smaller than it should be
-
Write python script to generate bunch of
.npy
gaussian random noise -
Write python script to load all input and output data and make some plots comparing integer fft and true ffts
-
extend bash script to generate random noise (by executing python file), execute integer fft with all the knobs and bells, then execute another python file to plot the output and save the plots.
Debugging
(previous) output of cargo run
before fft8: 0 + i 0
idx=0, bfi=0
idx=1, bfi=4
idx=2, bfi=2
idx=3, bfi=6
idx=4, bfi=1
idx=5, bfi=5
idx=6, bfi=3
idx=7, bfi=7
DEBUG: bit-switch complete, result:
[1000+i0, 1000+i0, 1000+i0, 1000+i0, 1000+i0, 1000+i0, 1000+i0, 1000+i0, ]
----------------------
DEBUG: stage 1
DEBUG: chunk=0
[1999+i0, -1+i0, 1000+i0, 1000+i0, 1000+i0, 1000+i0, 1000+i0, 1000+i0, ]
DEBUG: chunk=1
[1999+i0, -1+i0, 1999+i0, -1+i0, 1000+i0, 1000+i0, 1000+i0, 1000+i0, ]
DEBUG: chunk=2
[1999+i0, -1+i0, 1999+i0, -1+i0, 1999+i0, -1+i0, 1000+i0, 1000+i0, ]
DEBUG: chunk=3
[1999+i0, -1+i0, 1999+i0, -1+i0, 1999+i0, -1+i0, 1999+i0, -1+i0, ]
----------------------
DEBUG: stage 2
DEBUG: chunk=0
[3997+i0, -1+i-1, -1+i0, 1+i-1, 1999+i0, -1+i0, 1999+i0, -1+i0, ]
DEBUG: chunk=1
[3997+i0, -1+i-1, -1+i0, 1+i-1, 3997+i0, -1+i-1, -1+i0, 1+i-1, ]
----------------------
DEBUG: stage 3
DEBUG: chunk=0
[7993+i0, -1+i-3, -1+i-1, 1+i0, -1+i0, 1+i-1, 1+i-1, -1+i2, ]
DEBUG: #2
After fft8: 7993 + i 0
7u16 in bits: 0000000000000111
one 00000001
n_one 11111111
Out:
[7993+i0, -1+i-3, -1+i-1, 1+i0, -1+i0, 1+i-1, 1+i-1, -1+i2, ]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for integer_fft-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7035b97bb44bd7e7f399c06f7108dbe2ad20351de9551d074b518bdd1d60511 |
|
MD5 | 9b37cf2e5e0d82b152b8883887d0efef |
|
BLAKE2b-256 | 6f0386b2218d1c04d67c8daf5135ac09c6c61ded824d538ecebf1ffb9f552b04 |
Hashes for integer_fft-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72a02560321f437ecce3dae52e2b799f234b6e3c98680fcb8c1574a6d0f19104 |
|
MD5 | f6f41aecb007a8a5f8707911a8e33f78 |
|
BLAKE2b-256 | 8ef32928eebb03c6a53039c80ea96af1eba10b23ef06c223cb03d51ba092823d |