Redo rader
This commit is contained in:
@ -26,10 +26,11 @@ impl DFT for Radix2FFT {
|
||||
}
|
||||
}
|
||||
|
||||
fn execute(&mut self) {
|
||||
fn execute(&mut self, window: fn(f32) -> f32) {
|
||||
// Reorder samples
|
||||
for (i, x) in self.output_buffer.iter_mut().enumerate() {
|
||||
*x = self.input_buffer[reverse_bits(i, self.size as u32)];
|
||||
let k = reverse_bits(i, self.size as u32);
|
||||
*x = self.input_buffer[k] * window(k as f32 / self.size as f32);
|
||||
}
|
||||
|
||||
for step in 1..(self.size + 1) {
|
||||
@ -40,7 +41,7 @@ impl DFT for Radix2FFT {
|
||||
// Compute current polynomial at each unit root
|
||||
let a = self.output_buffer[s + i];
|
||||
let b = self.output_buffer[s + i + mid_point];
|
||||
let angle = - 2. * PI * (i as f32) / (pol_length as f32);
|
||||
let angle = -2. * PI * (i as f32) / (pol_length as f32);
|
||||
let phasor = Complex32::cexp(angle);
|
||||
self.output_buffer[i + s] = a + phasor * b;
|
||||
self.output_buffer[i + s + mid_point] = a - phasor * b;
|
||||
|
||||
Reference in New Issue
Block a user