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