RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dit_sino.cpp
Go to the documentation of this file.
1 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 //
3 // File = dit_sino.cpp
4 //
5 // Decimation-In-Time FFT
6 //
7 // Scrambled Input / Naturally-ordered Output
8 //
9 
10 #include "dit_sino.h"
11 #include "cbitrev.h"
12 #include "log2.h"
13 #include "misdefs.h"
14 #include <math.h>
15 
16 void
17 IfftDitSino(complex* array, int fft_size)
18 {
19  double trig_arg;
20  int log2_size;
21  complex twiddle, w_fact;
22  complex temp;
23  int pts_in_left_dft, pts_in_right_dft;
24  int stage, bfly_pos;
25  int top_node, bot_node;
26 
27  log2_size = ilog2(fft_size);
28 
29  ComplexBitReverse(array, fft_size);
30 
31  pts_in_right_dft = 1;
32  for (stage = 1; stage <= log2_size; stage++) {
33  pts_in_left_dft = pts_in_right_dft; // set pts_in_left_dft = 2**(stage-1)
34  pts_in_right_dft *= 2; // set pts_in_right_dft = 2**stage
35 
36  twiddle = complex(1.0, 0.0);
37  trig_arg = PI / pts_in_left_dft;
38  w_fact = complex(cos(trig_arg), sin(trig_arg));
39 
40  for (bfly_pos = 0; bfly_pos < pts_in_left_dft; bfly_pos++) {
41  for (top_node = bfly_pos; top_node < fft_size;
42  top_node += pts_in_right_dft) {
43  bot_node = top_node + pts_in_left_dft;
44  temp = array[bot_node] * twiddle;
45  array[bot_node] = array[top_node] - temp;
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  return;
55 }
56 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57 void
58 FftDitSino(complex* array, int fft_size)
59 {
60  double trig_arg;
61  int log2_size;
62  complex twiddle, w_fact;
63  complex temp;
64  int pts_in_left_dft, pts_in_right_dft;
65  int stage, bfly_pos;
66  int top_node, bot_node;
67 
68  log2_size = ilog2(fft_size);
69 
70  ComplexBitReverse(array, fft_size);
71 
72  pts_in_right_dft = 1;
73  for (stage = 1; stage <= log2_size; stage++) {
74  pts_in_left_dft = pts_in_right_dft; // set pts_in_left_dft = 2**(stage-1)
75  pts_in_right_dft *= 2; // set pts_in_right_dft = 2**stage
76 
77  twiddle = complex(1.0, 0.0);
78  trig_arg = PI / pts_in_left_dft;
79  w_fact = complex(cos(trig_arg), -sin(trig_arg));
80 
81  for (bfly_pos = 0; bfly_pos < pts_in_left_dft; bfly_pos++) {
82  for (top_node = bfly_pos; top_node < fft_size;
83  top_node += pts_in_right_dft) {
84  bot_node = top_node + pts_in_left_dft;
85  temp = array[bot_node] * twiddle;
86  array[bot_node] = array[top_node] - temp;
87  array[top_node] += temp;
88  } // end of loop over top_node
89 
90  twiddle *= w_fact;
91 
92  } // end of loop over bfly_pos
93  } // end of loop over stage
94 
95  return;
96 }
97 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void FftDitSino(complex *array, int fft_size)
Definition: dit_sino.cpp:58
#define PI
Definition: misdefs.h:9
void IfftDitSino(complex *array, int fft_size)
Definition: dit_sino.cpp:17
void ComplexBitReverse(complex *array, int size)
Definition: cbitrev.cpp:9
int ilog2(int value_inp)
Definition: log2.cpp:9