Accelerate Framework FFT vDSPztoc split real form to split real vector

别来无恙 提交于 2019-12-12 18:29:36

问题


I am implementing an accelerometer-based FFT in iOS using the Accelerate Framework, but the one thing that I'm still a bit confused about is this part:

/* The output signal is now in a split real form.  Use the  function
 * vDSP_ztoc to get a split real vector. */
 vDSP_ztoc(&A, 1, (COMPLEX *) obtainedReal, 2, nOver2);

What does the final array look like? I'm confused as to the distinction between "split real form" and "split real vector". I might have some understanding of what it means, but I want to be sure I have the right idea.

The starting data, an array of doubles, representing input data such as acceleration is put into even-odd form via vDSP_ctoz. Then the result is in this form (copied from Apple's vDSP Guide):

{[DC,0],C[1],C[2],...,C[n/2],[NY,0],Cc[n/2],...,Cc[2],Cc[1]}

 where
 1. DC and NY are the dc and nyquist components (real valued),
 2. C is complex in a split representation,
 3. Cc is the complex conjugate of C in a split representation.

For an n size real array A, the complex results require 2n
 spaces.  In order to fit the 2n size result into an n size  input and
 since the complex conjugates are duplicate information, the  real
 FFT produces its results as follows:
   {[DC,NY],C[1],C[2],...,C[n/2]}

In my implementation (which works, I'm just confused about the output), I also have a call to vDSP_ztoc. Should it have this call, or is that only done in the example because they want to restore the array to match the original one (as they did a reverse transform)?

If you are supposed to call that, what's the final form after vDSP_ztoc? Is it:

   {[DC,NY],C[1],C[2],...,C[n/2]}

Or is the first element in the output array is DC, the second is the first bin's real part the third is the first bin's imaginary part, and so on? Or is the second element the Nyquist frequency like in that setup, making the third and fourth element the real and imaginary components of the first bin?

It's a bit unclear, but I imagine that this question is very straightforward, and all I need is a quick confirmation / correction.

Thanks!


回答1:


So the final form {C[0],C[1],C[2],...,C[n/2]} is correct.

And the frequency of each bin is, as described in other similar threads is F = Fs/N Where Fs is the sampling frequency, N is the total number of elements in the input array. You end up with N/2 complex numbers (with half real half imaginary).



来源:https://stackoverflow.com/questions/10508692/accelerate-framework-fft-vdspztoc-split-real-form-to-split-real-vector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!