RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dif_niso.cpp
Go to the documentation of this file.
1 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 //
3 // File = dif_niso.cpp
4 //
5 // Decimation-In-Frequency FFT
6 //
7 // Naturally-ordered Input / Scrambled Output
8 //
9 
10 #include "dif_niso.h"
11 #include "cbitrev.h"
12 #include "complex.h"
13 #include "log2.h"
14 #include "misdefs.h"
15 #include <math.h>
16 
17 void
18 FftDifNiso(complex* array, int fft_size)
19 {
20  double trig_arg;
21  int log2_size;
22  complex twiddle, w_fact;
23  complex temp;
24  int pts_in_left_dft, pts_in_right_dft;
25  int stage, bfly_pos;
26  int top_node, bot_node;
27 
28  log2_size = ilog2(fft_size);
29 
30  pts_in_right_dft = fft_size;
31  for (stage = 1; stage <= log2_size; stage++) {
32  pts_in_left_dft =
33  pts_in_right_dft; // set pts_in_left_dft = N/(2**(stage-1))
34  pts_in_right_dft /= 2; // set pts_in_right_dft = N/(2**stage)
35 
36  twiddle = complex(1.0, 0.0);
37  trig_arg = PI / pts_in_right_dft;
38  w_fact = complex(cos(trig_arg), -sin(trig_arg));
39 
40  for (bfly_pos = 0; bfly_pos < pts_in_right_dft; bfly_pos++) {
41  for (top_node = bfly_pos; top_node < fft_size;
42  top_node += pts_in_left_dft) {
43  bot_node = top_node + pts_in_right_dft;
44  temp = array[top_node] + array[bot_node];
45  array[bot_node] = (array[top_node] - array[bot_node]) * twiddle;
46  array[top_node] = temp;
47  } // end of loop over top_node
48 
49  twiddle *= w_fact;
50 
51  } // end of loop over bfly_pos
52  } // end of loop over stage
53 
54  ComplexBitReverse(array, fft_size);
55 
56  return;
57 }
58 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define PI
Definition: misdefs.h:9
void FftDifNiso(complex *array, int fft_size)
Definition: dif_niso.cpp:18
void ComplexBitReverse(complex *array, int size)
Definition: cbitrev.cpp:9
int ilog2(int value_inp)
Definition: log2.cpp:9