Contents

vDSP.DiscreteFourierTransform

An object that provides forward and inverse discrete Fourier transforms on single- or double-precision collections of interleaved or split-complex data.

Declaration

class DiscreteFourierTransform<T> where T : vDSP_DiscreteFourierTransformable

Overview

Use a vDSP.DiscreteFourierTransform to perform discrete Fourier transforms (DFTs) on split-complex or interleaved data. To learn more about working with split-complex and interleaved data, see Performing Fourier transforms on interleaved-complex data.

To create a vDSP.DiscreteFourierTransform instance to work with interleaved data, pass either DSPComplex or DSPDoubleComplex to init(previous:count:direction:transformType:ofType:). The following code shows how to perform a forward complex-to-complex DFT on the interleaved single-precision values in the interleavedInput array:

// The `interleavedInput` array contains `complexValuesCount` `DSPComplex` elements.
let interleavedInput: [DSPComplex] = [ ... ]

let interleavedDFT = try? vDSP.DiscreteFourierTransform(previous: nil,
                                                        count: complexValuesCount,
                                                        direction: .forward,
                                                        transformType: .complexComplex,
                                                        ofType: DSPComplex.self)

// On return, the `interleavedOutput` array contains an array of `DSPComplex`
// structures.
let interleavedOutput = interleavedDFT?.transform(input: interleavedInput)

To create a vDSP.DiscreteFourierTransform instance to work with split-complex data, pass either Float or Double to init(previous:count:direction:transformType:ofType:). Split-complex data stores the real and imaginary parts of each complex value in separate arrays. The following code shows how to perform forward complex-to-complex DFT on the split-complex single-precision values in the splitComplexRealInput and splitComplexImaginaryInput arrays:

var splitComplexRealInput: [Float] = [ ... ]
var splitComplexImaginaryInput: [Float] = [ ... ]

let splitComplexDFT = try? vDSP.DiscreteFourierTransform(previous: nil,
                                                         count: complexValuesCount,
                                                         direction: .forward,
                                                         transformType: .complexComplex,
                                                         ofType: Float.self)

// The `splitComplexOutput` tuple contains two arrays that represent the
// real and imaginary parts of the output.
let splitComplexOutput = splitComplexDFT?.transform(real: splitComplexRealInput,
                                                    imaginary: splitComplexImaginaryInput)

If the underlying data in both the interleavedInput array and the split-complex input arrays is the same, for each i in 0 ..< complexValuesCount, the following is true:

interleavedOutput[i].real ≈ splitComplexOutput.real[i]
interleavedOutput[i].imag ≈ splitComplexOutput.imaginary[i]

``

Topics

Creating a Discrete Fourier Transform Instance

Performing Split-Complex Discrete Fourier Transforms

Performing Interleaved Discrete Fourier Transforms

Initializers

See Also

Objects that simplify discrete Fourier transforms