Raders algorithm

This commit is contained in:
2025-09-21 19:42:51 +02:00
parent 79f03a071a
commit 01e3657b55
5 changed files with 4975 additions and 4968 deletions

View File

@ -12,11 +12,17 @@ mod nco;
use bfsk::BFSKMod;
use complex::Complex;
use fft::rader;
use complex::Complex32;
use fft::rader;
use nco::Nco;
use crate::fft::{dft::NaiveDFT, mixed_radix::MixedRadixFFT, rader::{compute_prime_primitive_root, RaderFFT}, radix2::Radix2FFT, DFT};
use crate::fft::{
DFT, create_fft,
dft::NaiveDFT,
mixed_radix::MixedRadixFFT,
rader::{RaderFFT, compute_prime_primitive_root, exp_mod},
radix2::Radix2FFT,
};
// Utilities
fn map<T>(input: T, in_min: T, in_max: T, out_min: T, out_max: T) -> T
@ -38,16 +44,18 @@ fn test() {
let freq1 = 2. * PI / 4.0;
let freq2 = 2. * PI / 8.0;
let sample_count = 4799;
let mut o1 = Nco::new(freq1);
let mut o2 = Nco::new(freq2);
let mut fft = RaderFFT::create(4799);
let mut dft = NaiveDFT::create(4799);
let mut fft = RaderFFT::create(sample_count);
//let mut dft = NaiveDFT::create(sample_count);
let vals = fft.get_input();
let vals_dft = dft.get_input();
for (x, y) in vals.iter_mut().zip(vals_dft.iter_mut()) {
//let vals_dft = dft.get_input();
for x in vals.iter_mut() {
*x = o1.cexp() + o2.cexp();
*y = *x;
//*y = *x;
//*x = o2.cexp(); //+ o2.cexp();
//*x = *x * (1. / x.mag());
o1.step();
@ -55,14 +63,20 @@ fn test() {
}
fft.execute();
//dft.execute();
let output = fft.get_output();
let mut f = File::create("out.csv").unwrap();
for (i, (v, v2)) in output.iter().zip(dft.get_output()).enumerate() {
for (i, v) in output.iter().enumerate() {
f.write_all(
format!("{},{},{},\n", i as f32 / 8192., v.mag(), v2.mag())
.to_string()
.as_bytes(),
format!(
"{},{},\n",
i as f32 / sample_count as f32,
v.mag(),
//v2.mag()
)
.to_string()
.as_bytes(),
)
.unwrap();
}