RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dif_sino.cpp
Go to the documentation of this file.
1 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 //
3 // File = dif_sino.cpp
4 //
5 // Decimation-In-Frequency FFT
6 //
7 // Scrambled Input / Naturally-ordered Output
8 //
9 
10 #include "dif_sino.h"
11 #include "bitrev.h"
12 #include "cbitrev.h"
13 #include "log2.h"
14 #include "misdefs.h"
15 #include <math.h>
16 
17 void
18 FftDifSino(complex* array, int fft_size)
19 {
20  double trig_arg;
21  int log2_size;
22  complex twiddle;
23  complex temp;
24  int pts_in_lft_grp, pts_in_rgt_grp;
25  int stage, grp_pos, grp_cntr;
26  int top_node, bot_node;
27 
28  log2_size = ilog2(fft_size);
29 
30  ComplexBitReverse(array, fft_size);
31 
32  pts_in_rgt_grp = 1;
33  for (stage = 1; stage <= log2_size; stage++) {
34  pts_in_lft_grp = pts_in_rgt_grp; // set pts_in_lft_grp = 2**(stage-1)
35  pts_in_rgt_grp *= 2; // set pts_in_rgt_grp = 2**stage
36 
37  grp_cntr = -1;
38 
39  for (grp_pos = 0; grp_pos < fft_size; grp_pos += pts_in_rgt_grp) {
40  grp_cntr++;
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_lft_grp;
45  top_node++) {
46  bot_node = top_node + pts_in_lft_grp;
47  temp = array[top_node] + array[bot_node];
48  array[bot_node] = (array[top_node] - array[bot_node]) * twiddle;
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  return;
56 }
57 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void FftDifSino(complex *array, int fft_size)
Definition: dif_sino.cpp:18
int bitrev(int in_val, int num_bits)
Definition: bitrev.cpp:8
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