vDSP.FFT Swift enum vs. vDSP_fft_zrip

241 Views Asked by At

Apple has provided a Swift vDSP enum for more intuitively doing operations.

With this you can convert less readable code like

vDSP_vmul(arrayA, 1, arrayB, 1, arrayC, 1, vDSP_length(arrayA.count))

to

let arrayC = vDSP.multiply(arrayA, arrayB)

However, the nested FFT class seems to only support complex --> complex FFTs. In order to do a real --> complex FFT, taking advantage of conjugate complex symmetry, it seems you still need to use vDSP_fft_zrip which is not very intuitive (classic old Apple docs issues).

Am I missing some way of doing a real --> complex FFT using the Swift enum? Thanks in advance!

Here's some example code using it:

let fft = vDSP.FFT(log2n: vDSP_Length(log2n),
                          radix: .radix2,
                          ofType: DSPSplitComplex.self)

/// create DSPSplitComplex, splitComplex, with array for real component,
/// zero array for imaginary component

fft?.forward(input: splitComplex, output: &splitComplex)

1

There are 1 best solutions below

0
Flex Monkey On

Take a look at vDSP.DiscreteFourierTransform. It supports complex-complex and complex-real. Accelerate's DFT will use FFT where it can. It also supports interleaved and split-complex data