Discrete Fourier Transform Functions#

oneMKL provides a DPC++ interface to \(d\)-dimensional \(\left(d \in \mathbb{Z}_{>0}\right)\) Discrete Fourier Transforms (DFTs).

Definitions#

Let \(w\) be a set of \(M\) finite \(d\)-dimensional discrete sequences \(w^{m}\) of length(s) \(n_1 \times n_2 \times \dots \times n_d\) (\(d \in \mathbb{Z}_{>0}\), \(M \in \mathbb{Z}_{>0}\), \(n_{\ell} \in \mathbb{Z}_{>0}\ \forall \ell \in \lbrace 1, 2, \ldots, d \rbrace\), and \(m \in \lbrace 0, 1, \ldots, M-1\rbrace\)). Let \(w^{m}_{k_1, k_2, \ldots, k_d}\) be the entry of multi-index \(\left(k_1, k_2, \ldots, k_d\right)\) in \(w^{m}\) wherein integer indices \(k_{\ell}\) are such that \(0 \leq k_{\ell} < n_{\ell},\ \forall \ell \in \lbrace 1, 2, \ldots, d \rbrace\).

For every \(m \in \lbrace 0, 1, \ldots, M - 1 \rbrace\), the DFT of sequence \(w^{m}\) is the \(d\)-dimensional discrete sequence \(z^{m}\) of length(s) \(n_1 \times n_2 \times \dots \times n_d\) whose entries are defined as

(1)#\[z^{m}_{k_1, k_2,\ldots, k_d} = \sigma_{\delta} \displaystyle\sum_{j_d=0}^{n_d-1}\dots\displaystyle\sum_{j_2=0}^{n_2-1}\displaystyle\sum_{j_1=0}^{n_1-1} w^{m}_{j_1, j_2,\dots,j_d} \exp \left[ \delta 2\pi \imath \left( \sum_{\ell=1}^{d} \frac{j_{\ell}k_{\ell}}{n_{\ell}} \right) \right],\]

where \(\imath^2 = -1\). In (1), \(\delta\) determines one of the two “directions” of the DFT: \(\delta=-1\) defines the “forward DFT” while \(\delta=+1\) defines the “backward DFT”. \(\sigma_{\delta}\) is a (real) scaling factor associated with either operation.

The domain of input (resp. output) discrete sequences for a forward (resp. backward) DFT is referred to as “forward domain”. Conversely, the domain of output (resp. input) discrete sequences for forward (resp. backward) DFT is referred to as “backward domain”.

oneMKL supports single-precision (fp32) and double-precision (fp64) floating-point arithmetic for the calculation of DFTs, using two kinds of forward domains:

  • the set of complex \(d\)-dimensional discrete sequences, referred to as “complex forward domain”;

  • the set of real \(d\)-dimensional discrete sequences, referred to as “real forward domain”.

Similarly, we refer to DFTs of complex (resp. real) forward domain as “complex DFTs” (resp. “real DFTs”). Regardless of the kind of forward domain, the backward domain’s data sequences are always complex.

The calculation of the same DFT for several, i.e., \(M > 1\), data sets of the same kind of forward domain, using the same precision is referred to as a “batched DFT”.

Elementary range of indices#

In general, all entries of multi-indices \(\left(k_1, \ldots, k_d\right)\) such that \(0\leq k_{\ell} < n_{\ell}, \forall \ell \in \lbrace 1, \ldots, d \rbrace\) unambiguously determine any relevant \(d\)-dimensional sequence unambiguously (for any valid \(m\)). In case of real DFTs, the data sequences in backward domain can be fully determined from a smaller range of indices. Indeed, if all entries of \(w\) are real in (1), then the entries of \(z\) are complex and, for any valid \(m\), \(\left(z^{m}_{k_1, k_2, \dots, k_d}\right)^{*} = z^{m}_{j_{1}, j_{2}, \dots, j_{d}}\) where \(j_{\ell} = \left(n_{\ell} - k_{\ell}\right) \pmod {n_{\ell}}, \ \forall \ell \in \lbrace 1, \ldots, d \rbrace\) and \(\lambda^{*}\) represents the conjugate of complex number \(\lambda\). This conjugate symmetry relation makes roughly half the data redundant in backward domain: in case of real DFTs, the data sequences in backward domain can be fully determined even if one of the \(d\) indices \(k_{\ell}\) is limited to the range \(0\leq k_{\ell} \leq \lfloor \frac{n_{\ell}}{2}\rfloor\). In oneMKL, the index \(k_d\), i.e., the last dimension’s index, is restricted as such to capture an elementary set of non-redundant entries for data sequences belonging to the backward domain of real DFTs.

In other words, oneMKL expects and produces a set of \(M\) \(d\)-dimensional data sequences \(\left(\cdot \right)^{m}_{k_1, k_2,\ldots, k_d}\) with integer indices \(m\) and \(k_{\ell}\ \left(\ell \in \lbrace 1, \ldots, d \rbrace\right)\) in the elementary range

  • \(0 \leq m < M\);

  • \(0 \leq k_j < n_j,\ \forall j \in \lbrace1, \ldots, d - 1\rbrace\), if \(d > 1\);

  • \(0 \leq k_d < n_d\), except for backward domain’s data sequences of real DFTs;

  • \(0 \leq k_d \leq \lfloor\frac{n_d}{2}\rfloor\), for backward domain’s data sequences of real DFTs.

Additional constraints for data in backward domain of real DFTs#

Finally, note that the conjugate symmetry relation further constrains some of the entries (or pairs thereof) in the backward domain’s data sequences for real DFTs. Specifically, for any of the \(M\) sequences,

  • the imaginary part must be \(0\) for any entry of multi-index \(\left(k_1, k_2, \ldots, k_d\right)\) such that \(k_{\ell} \equiv \left(n_{\ell} - k_{\ell}\right) \pmod {n_{\ell}}, \forall \ell \in \lbrace{1, \ldots, d\rbrace}\), e.g., entry of multi-index \(\left(0, 0, \ldots, 0\right)\);

  • pairs of entries of multi-indices \(\left(k_1, k_2, \ldots, k_d\right)\) and \(\left(j_1, j_2, \ldots, j_d\right)\) such that \(k_{\ell} \equiv \left(n_{\ell} - j_{\ell}\right) \pmod {n_{\ell}}, \forall \ell \in \lbrace{1, \ldots, d\rbrace}\) must be complex conjugates of one another, e.g., entries of multi-indices \(\left(1, 0, \ldots, 0\right)\) and \(\left(n_1 - 1, 0, \ldots, 0\right)\) must be complex conjugates (note that this case falls back to the above constraint if \(n_1 = 2\)).

Note

The behavior of oneMKL is undefined for real backward DFT if the input data does not satisfy those constraints. oneMKL considers it the user’s responsibility to guarantee that these constraints are satisfied by the input data for real backward DFTs.