Function

# vDSP_DFT_Execute(_:_:_:_:_:)

Calculates the discrete single-precision Fourier transform for a vector.

## Parameters

`__Setup`
`__Ir`

A single-precision vector containing the real parts of the input values.

`__Ii`

A single-precision vector containing the imaginary parts of the input values.

`__Or`

A single-precision vector where the real parts of the results are stored on return.

`__Oi`

A single-precision vector where the imaginary parts of the results are stored on return.

## Discussion

This function calculates either a real or complex discrete Fourier transform, depending on whether the setup object was created with a call to `vDSP_DFT_zrop_CreateSetup(_:_:_:)``vDSP_DFT_zrop_CreateSetup(_:_:_:)` or `vDSP_DFT_zop_CreateSetup(_:_:_:)`.

For a complex DFT, the way the `vDSP_DFT_Execute(_:_:_:_:_:)` function works is fairly straightforward: it works on real/imaginary inputs specified by `Ir` and `Ii`, and leaves real/imaginary outputs specified by `Or` and `Oi`; the transform is either forward or inverse according to the `Direction` flag specified in the setup. Given `Length` as the length specified in the setup, each array should contain `Length` elements

For a real-to-complex DFT, there are some complications: forward means real-to-complex, inverse is complex-to-real. In either direction, the data for the real side of the transform is stored alternately in the real and imaginary arrays (even-indexed elements in the real array, odd-indexed in the imaginary array). Given `Length` as the length specified in the setup, each array should contain `Length`/2 elements

When the `vDSP_DFT_Execute(_:_:_:_:_:)` function is called with a setup returned from the `vDSP_DFT_zop_CreateSetup(_:_:_:)` function, it performs a complex-to-complex transform on inputs specified by `Ir` and `Ii` and stores results in `Or` and `Oi`. The transform is forward or inverse according to the `Direction` flag specified in the setup. Given `Length` as the length specified in the setup, each array should contain `Length` elements:

where:

• `Length` is the length given in the setup.

• `h` is the input array of complex numbers specified by `Ir` and `Ii` when the `vDSP_DFT_Execute` function is called:

• `H` is the output array of complex numbers specified by `Or` and `Oi` when the `vDSP_DFT_Execute` function returns:

• S is -1 for a forward transform and +1 for an inverse transform.

When the `vDSP_DFT_Execute` function is called with a setup returned from the `vDSP_DFT_zrop_CreateSetup(_:_:_:)` function, it performs a real-to-complex transform if the direction specified in the setup is forward and a complex-to-real transform if the direction is inverse. In either direction, the data for the real side is stored alternately in the real and imaginary arrays (even-indexed elements in the real array, odd-indexed elements in the imaginary array). Given `Length` as the length specified in the setup, each array should contain `Length`/2 elements:

where:

• `Length` is the length given in the setup.

• h is the input array of numbers specified by `Ir` and `Ii` when the `vDSP_DFT_Execute(_:_:_:_:_:)` is called (see "Data Layout" below).

• H is the output array of numbers specified by `Or` and `Oi` when the `vDSP_DFT_Execute(_:_:_:_:_:)` function returns (see "Data Layout", below.)

• S is -1 for a forward transform and +1 for an inverse transform.

Data Layout for Real-to-Complex and Complex-to-Real Transforms:

For a forward transform:

• h is an array of real numbers, with its even-index elements stored in `Ir` and its odd-index elements stored in `Ii`:

• H is an array of complex numbers, stored in `Or` and `Oi`:

For `Length`/2 < k < `Length`, H[k] is not explicitly stored in memory but is known because it necessarily equals the conjugate of H[`Length`-k], which is stored as described above.

For an inverse transformation, the layouts of the input and output arrays are swapped. `Ir` and `Ii` describe an input array with complex elements laid out as for `Or` and `Oi`. When the `vDSP_DFT_Execute` function returns, `Or` and `Oi` contain a pure real array, with its even-indexed elements stored in `Or` and its odd-indexed elements in `Oi`.

### Discrete Fourier Transforms

`func vDSP_DFT_zop_CreateSetupD(vDSP_DFT_SetupD?, vDSP_Length, vDSP_DFT_Direction) -> vDSP_DFT_SetupD?`

Creates a data structure for use with `vDSP_DFT_ExecuteD(_:_:_:_:_:)` to perform a double-precision, complex-to-complex discrete Fourier transform, forward or inverse.

`func vDSP_DFT_zrop_CreateSetup(vDSP_DFT_Setup?, vDSP_Length, vDSP_DFT_Direction) -> vDSP_DFT_Setup?`

Creates a data structure for use with `vDSP_DFT_Execute(_:_:_:_:_:)` to perform a single-precision discrete Fourier transform, forward (real to complex) or inverse (complex to real).

`func vDSP_DFT_zrop_CreateSetupD(vDSP_DFT_SetupD?, vDSP_Length, vDSP_DFT_Direction) -> vDSP_DFT_SetupD?`

Creates a data structure for use with `vDSP_DFT_ExecuteD(_:_:_:_:_:)` to perform a double-precision discrete Fourier transform, forward (real to complex) or inverse (complex to real).

`func vDSP_DFT_DestroySetup(vDSP_DFT_Setup?)`

Releases a single-precision setup object.

`func vDSP_DFT_DestroySetupD(vDSP_DFT_SetupD?)`

Releases a double-precision setup object.