0

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

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

非常感谢雷

4

2 回答 2

0

您需要解压 vDSP_fft_zrip() 的结果。其他函数都不希望以这种方式打包数据。有关实际拆包的一些信息here

于 2012-04-08T22:07:51.207 回答
0

在 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
于 2016-03-10T18:06:45.400 回答