我看到一些示例代码使用vDSP_fft_zrip调用的复杂结果来调用vDSP_zvmags,以获得量级^2。zrip的输出显示它是打包的拆分复杂格式,但在vDSP_zvmags的文档中,它只是显示拆分复杂。
vDSP_zvmags的输入是否也是压缩格式,或者在传递之前需要进行一些操作?
非常感谢,雷
发布于 2012-04-09 06:07:51
您需要解压vDSP_fft_zrip()的结果。其他函数都不希望数据以这种方式打包。Some info on the actual unpacking here
发布于 2016-03-11 02:06:45
在N点数据上使用vDSP_fft_zrip执行快速傅立叶变换得到N/2点压缩分裂复数,其中在索引0中,实部显示DC量(快速傅立叶变换的索引0),虚数部分显示奈奎斯特量(快速傅立叶变换的索引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 squaredhttps://stackoverflow.com/questions/10066503
复制相似问题