首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >苹果加速框架vDSP_zvmags压缩格式?

苹果加速框架vDSP_zvmags压缩格式?
EN

Stack Overflow用户
提问于 2012-04-09 05:04:58
回答 2查看 758关注 0票数 0

我看到一些示例代码使用vDSP_fft_zrip调用的复杂结果来调用vDSP_zvmags,以获得量级^2。zrip的输出显示它是打包的拆分复杂格式,但在vDSP_zvmags的文档中,它只是显示拆分复杂。

vDSP_zvmags的输入是否也是压缩格式,或者在传递之前需要进行一些操作?

非常感谢,雷

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-04-09 06:07:51

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

票数 0
EN

Stack Overflow用户

发布于 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并获得正确结果的一个技巧如下:

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10066503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档