SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Public Attributes | Private Attributes | List of all members
leansdr::cfft_engine< T > Struct Template Reference

#include <dsp.h>

Public Member Functions

 cfft_engine (int _n)
 
void inplace (complex< T > *data, bool reverse=false)
 

Public Attributes

const int n
 

Private Attributes

int logn
 
int * bitrev
 
complex< T > * omega
 
complex< T > * omega_rev
 
float invsqrtn
 

Detailed Description

template<typename T>
struct leansdr::cfft_engine< T >

Definition at line 62 of file dsp.h.

Constructor & Destructor Documentation

◆ cfft_engine()

template<typename T>
leansdr::cfft_engine< T >::cfft_engine ( int  _n)
inline

Definition at line 65 of file dsp.h.

65  : n(_n), invsqrtn(1.0 / sqrt(n))
66  {
67  // Compute log2(n)
68  logn = 0;
69  for (int t = n; t > 1; t >>= 1)
70  ++logn;
71  // Bit reversal
72  bitrev = new int[n];
73  for (int i = 0; i < n; ++i)
74  {
75  bitrev[i] = 0;
76  for (int b = 0; b < logn; ++b)
77  bitrev[i] = (bitrev[i] << 1) | ((i >> b) & 1);
78  }
79  // Float constants
80  omega = new complex<T>[n];
81  omega_rev = new complex<T>[n];
82  for (int i = 0; i < n; ++i)
83  {
84  float a = 2.0 * M_PI * i / n;
85  omega_rev[i].re = (omega[i].re = cosf(a));
86  omega_rev[i].im = -(omega[i].im = sinf(a));
87  }
88  }
float invsqrtn
Definition: dsp.h:139
complex< T > * omega
Definition: dsp.h:138
#define M_PI
Definition: rdsdemod.cpp:27
complex< T > * omega_rev
Definition: dsp.h:138
int32_t i
Definition: decimators.h:244
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2283
const int n
Definition: dsp.h:64

Member Function Documentation

◆ inplace()

template<typename T>
void leansdr::cfft_engine< T >::inplace ( complex< T > *  data,
bool  reverse = false 
)
inline

Definition at line 89 of file dsp.h.

Referenced by leansdr::auto_notch< leansdr::f32 >::detect(), leansdr::cnr_fft< leansdr::f32 >::do_cnr(), and leansdr::spectrum< T, NFFT >::do_spectrum().

90  {
91  // Bit-reversal permutation
92  for (int i = 0; i < n; ++i)
93  {
94  int r = bitrev[i];
95  if (r < i)
96  {
97  complex<T> tmp = data[i];
98  data[i] = data[r];
99  data[r] = tmp;
100  }
101  }
102  complex<T> *om = reverse ? omega_rev : omega;
103  // Danielson-Lanczos
104  for (int i = 0; i < logn; ++i)
105  {
106  int hbs = 1 << i;
107  int dom = 1 << (logn - 1 - i);
108  for (int j = 0; j < dom; ++j)
109  {
110  int p = j * hbs * 2, q = p + hbs;
111  for (int k = 0; k < hbs; ++k)
112  {
113  complex<T> &w = om[k * dom];
114  complex<T> &dqk = data[q + k];
115  complex<T> x(w.re * dqk.re - w.im * dqk.im,
116  w.re * dqk.im + w.im * dqk.re);
117  data[q + k].re = data[p + k].re - x.re;
118  data[q + k].im = data[p + k].im - x.im;
119  data[p + k].re = data[p + k].re + x.re;
120  data[p + k].im = data[p + k].im + x.im;
121  }
122  }
123  }
124  if (reverse)
125  {
126  float invn = 1.0 / n;
127  for (int i = 0; i < n; ++i)
128  {
129  data[i].re *= invn;
130  data[i].im *= invn;
131  }
132  }
133  }
complex< T > * omega
Definition: dsp.h:138
complex< T > * omega_rev
Definition: dsp.h:138
int32_t i
Definition: decimators.h:244
const int n
Definition: dsp.h:64
+ Here is the caller graph for this function:

Member Data Documentation

◆ bitrev

template<typename T>
int* leansdr::cfft_engine< T >::bitrev
private

Definition at line 137 of file dsp.h.

◆ invsqrtn

template<typename T>
float leansdr::cfft_engine< T >::invsqrtn
private

Definition at line 139 of file dsp.h.

◆ logn

template<typename T>
int leansdr::cfft_engine< T >::logn
private

Definition at line 136 of file dsp.h.

◆ n

template<typename T>
const int leansdr::cfft_engine< T >::n

◆ omega

template<typename T>
complex<T>* leansdr::cfft_engine< T >::omega
private

Definition at line 138 of file dsp.h.

◆ omega_rev

template<typename T>
complex<T> * leansdr::cfft_engine< T >::omega_rev
private

Definition at line 138 of file dsp.h.


The documentation for this struct was generated from the following file: