⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dif_niso.cpp

📁 Digital filter designer s handbook C++ code source
💻 CPP
字号:
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//  File = dif_niso.cpp
//
//  Decimation-In-Frequency FFT
//
//  Naturally-ordered Input / Scrambled Output
//

#include <math.h>
#include "d_cmplx.h"
#include "log2.h"
#include "misdefs.h"
#include "cbitrev.h"
#include "dif_niso.h"

void FftDifNiso( double_complex *array,
                 int fft_size)
{
double trig_arg;
int log2_size;
double_complex twiddle, w_fact;
double_complex temp;
int pts_in_left_dft, pts_in_right_dft;
int stage, bfly_pos;
int top_node, bot_node;

log2_size = ilog2(fft_size);

 pts_in_right_dft = fft_size;
 for( stage=1; stage <=log2_size; stage++)
   { 
    pts_in_left_dft = pts_in_right_dft;  // set pts_in_left_dft = N/(2**(stage-1))
    pts_in_right_dft /= 2;               // set pts_in_right_dft = N/(2**stage)
   
    twiddle = double_complex(1.0, 0.0);
    trig_arg = PI/pts_in_right_dft;  
    w_fact = double_complex(cos(trig_arg), -sin(trig_arg));
   
    for( bfly_pos =0; bfly_pos < pts_in_right_dft; bfly_pos++)
      {                             
       for( top_node = bfly_pos; top_node<fft_size; top_node += pts_in_left_dft)
         {                              
          bot_node = top_node + pts_in_right_dft;
          temp = array[top_node] + array[bot_node];
          array[bot_node] = (array[top_node] - array[bot_node]) * twiddle;
          array[top_node] = temp;
         }  // end of loop over top_node
        
       twiddle *= w_fact;
      
      } // end of loop over bfly_pos
   } // end of loop over stage

 ComplexBitReverse(array, fft_size);  

 return;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -