Discrete Fourier Transform Functions#

oneMath provides a DPC++ interface to d-dimensional (dZ>0) Discrete Fourier Transforms (DFTs).

Definitions#

Let w be a set of M finite d-dimensional discrete sequences wm of length(s) n1×n2××nd (dZ>0, MZ>0, nZ>0 {1,2,,d}, and m{0,1,,M1}). Let wk1,k2,,kdm be the entry of multi-index (k1,k2,,kd) in wm wherein integer indices k are such that 0k<n, {1,2,,d}.

For every m{0,1,,M1}, the DFT of sequence wm is the d-dimensional discrete sequence zm of length(s) n1×n2××nd whose entries are defined as

(1)#zk1,k2,,kdm=σδjd=0nd1j2=0n21j1=0n11wj1,j2,,jdmexp[δ2πı(=1djkn)],

where ı2=1. In (1), δ determines one of the two “directions” of the DFT: δ=1 defines the “forward DFT” while δ=+1 defines the “backward DFT”. σδ 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”.

oneMath 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 (k1,,kd) such that 0k<n,{1,,d} 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, (zk1,k2,,kdm)=zj1,j2,,jdm where j=(nk)(modn), {1,,d} and λ represents the conjugate of complex number λ. 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 is limited to the range 0kn2. In oneMath, the index kd, 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, oneMath expects and produces a set of M d-dimensional data sequences ()k1,k2,,kdm with integer indices m and k ({1,,d}) in the elementary range

  • 0m<M;

  • 0kj<nj, j{1,,d1}, if d>1;

  • 0kd<nd, except for backward domain’s data sequences of real DFTs;

  • 0kdnd2, 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 (k1,k2,,kd) such that k(nk)(modn),{1,,d}, e.g., entry of multi-index (0,0,,0);

  • pairs of entries of multi-indices (k1,k2,,kd) and (j1,j2,,jd) such that k(nj)(modn),{1,,d} must be complex conjugates of one another, e.g., entries of multi-indices (1,0,,0) and (n11,0,,0) must be complex conjugates (note that this case falls back to the above constraint if n1=2).

Note

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