Using std :: complex with iPhone vDSP features

I was working on some vDSP code and I ran into an annoying problem. My code is cross-platform and therefore uses std :: complex to store its complex values.

Now I assumed that I could configure the FFT as follows:

DSPSplitComplex dspsc;
dspsc.realp = &complexVector.front().real();
dspsc.imagp = &complexVector.front().imag();

And then use step 2 in the corresponding vDSP_fft_ * call.

However, this simply does not work. I can solve the problem by running vDSP_ztoc, but this requires temporary buffers that I really don't want to hang out with. Is there a way to use vDSP_fft_ * functions directly on alternating complex data? Also can someone explain why I cannot do what I am doing above with step 2?

thank

Edit: As Bo Persson noted, the real function and imag functions do not actually return a link.

However, it still does not work if I do the following instead

DSPSplitComplex dspsc;
dspsc.realp = ((float*)&complexVector.front()) + 0;
dspsc.imagp = ((float*)&complexVector.front()) + 1;

So my original question is still standing :(

+1
source share
2 answers

The std :: complex functions are real()also imag()returned by value; they do not return a reference to the members of the complex.

This means that you cannot get their addresses in this way.

+4
source

This is how you do it.

const COMPLEX *in = reinterpret_cast<const COMPLEX*>(std::complex);

Source: http://www.fftw.org/doc/Complex-numbers.html

EDIT: ; COMPLEX fftw_complex ( fftw_complex double COMPLEX float)

-1

All Articles