【问题标题】:Apple Accelerate Framework vDSP_zvmags PACKED format?Apple Accelerate Framework vDSP_zvmags PACKED 格式?
【发布时间】:2012-04-08 21:04:58
【问题描述】:

我看到一些示例代码使用调用 vDSP_fft_zrip 的复杂结果调用 vDSP_zvmags 以获得幅度^2。 zrip 的输出显示它是 PACKED split complex 格式,但在 vDSP_zvmags 的文档中它只是说 split complex。

vDSP_zvmags 的输入也是 PACKED 格式,还是在通过之前需要做一些操作?

非常感谢 雷

【问题讨论】:

    标签: iphone signal-processing fft


    【解决方案1】:

    您需要解压 vDSP_fft_zrip() 的结果。其他函数都不希望以这种方式打包数据。 Some info on the actual unpacking here

    【讨论】:

      【解决方案2】:

      在 N 点数据上使用 vDSP_fft_zrip 执行 fft 会给您 N/2 点 PACKED 分裂复数,其中在索引 0 中,实部显示 DC 量(fft 的索引 0),虚部显示奈奎斯特量(fft 的索引 N )。 更多详情:https://developer.apple.com/library/ios/documentation/Performance/Conceptual/vDSP_Programming_Guide/UsingFourierTransforms/UsingFourierTransforms.html#//apple_ref/doc/uid/TP40005147-CH3-SW1

      您可以使用 vDSP_zvmags 并获得正确结果的一个技巧是这样的:

      const int LOG2_N = 10 ; // (say N=1024)
      const int N = 1 << LOG2_N ;
      
      FFTSetup fftSetup;
      DSPSplitComplex tempSplitComplex;
      
      x = new float[N] ;    // N point data you can put your data 
      X = new float[N/2+1] ; // magnitude of fft of signal from index 0 (dc) to N/2 (Nyquist)
      
      tempSplitComplex.realp = new float[N/2];
      tempSplitComplex.imagp = new float[N/2];
      
      fftSetup = vDSP_create_fftsetup(LOG_N, kFFTRadix2);
      vDSP_ctoz((DSPComplex *) x, 2, &tempSplitComplex, 1, N/2 ) ;
      // perform fft
      vDSP_fft_zrip(fftSetup, &tempSplitComplex, 1, LOG_N, kFFTDirection_Forward) ;
      // calculating square of magnitude for each value
      vDSP_zvmags(&tempSplitComplex, 1, X, 1, N/2); 
      // after this line X[0] is incorrect and X[N] is not calculated,
      // but others are correct, so we need to fix those two (X[0], and X[N])
      // DC and Nyquist ffts' imaginary parts are zero, 
      // so Nyquist fft is stored in imaginary part of DC fft
      X[0] = tempSplitComplex.realp[0] * tempSplitComplex.realp[0];  // DC squared
      X[N/2] = tempSplitComplex.imagp[0] * tempSplitComplex.imagp[0]; // Nyquist squared
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-06
        • 1970-01-01
        • 2011-05-29
        • 2011-03-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多