Accelerate Framework FFT vDSPztoc split real form

2019-07-19 02:26发布

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条回答
混吃等死
2楼-- · 2019-07-19 03:16

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).

查看更多
登录 后发表回答