# Strides

In addition to supporting transforms of multiple number of datasets, FFT interface supports non-unit stride distribution of data within each data set. The parameter is an array of values of Integer data type in Fortran and MKL_LONG data type in C. Consider the following situation where a 32-length FFT is to be computed on the sequence `xj, 0≤j<32`. The actual location of these values are in `X(5), X(7), ..., X(67)` of an array `X(1:68)`. The stride accommodated by FFT interface consists of a displacement from the first element of the data array `L0`, (4 in this case), and a constant distance of consecutive elements `L1` (2 in this case). Thus for the Fortran array `X`

`xj = X(1 + L0 + L1 * j) = X(5 + L1 * j).`

This stride vector (4,2) is provided by a length-2 rank-1 integer array:

COMPLEX :: X(68)

INTEGER :: Stride(2)

...................

Status = DftiCreateDescriptor(Desc_Handle, DFTI_SINGLE,

DFTI_COMPLEX, 1, 32)

Stride = (/ 4, 2 /)

Status = DftiSetValue(Desc_Handle, DFTI_INPUT_STRIDES, Stride)

Status = DftiSetValue(Desc_Handle, DFTI_OUTPUT_STRIDES, Stride)

Status = DftiCommitDescriptor(Desc_Handle)

Status = DftiComputeForward(Desc_Handle, X)

Status = DftiFreeDescriptor(Desc_Handle)

In general, for a d-dimensional transform, the stride is provided by a d+1-length integer vector (`L0, L1, L2, ..., Ld`) with the meaning:

L0 = displacement from the first array element

L1 = distance between consecutive data elements in the first dimension

L2 = distance between consecutive data elements in the second dimension

... = ...

Ld = distance between consecutive data elements in the d-th dimension.

A d-dimensional data sequence

Xj1 , j2 , ... , jd , 0 ≤ ji ≤ J i , 1 ≤ i ≤ d

will be stored in the rank-1 array X by the mapping

Xj1 , j2 , ... , jd = X (first index + L0 + j1 L1 + j2 L2 + ... + jd Ld) .

For multiple transforms, the value L0 applies to the first data sequence, and Lj, j = 1, 2,..., d apply to all the data sequences.

In the case of a single one-dimensional sequence, L1 is simply the usual stride. The default setting of strides in the general multi-dimensional situation corresponds to the case where the sequences are distributed tightly into the array:

Both the input data and output data have a stride associated with it. The default is set in accordance with the data to be stored contiguously in memory in a way that is natural to the language.

Note that in case of a real FFT, where different formats are available, the default value is not the one that seems most natural for certain formats. For example, with the CCE format, strides are set by default to L1 = 1, L2 = J1 for a real transform regardless. However, for a complex matrix, slightly over half of the matrix is actually stored, and you should set strides to L1 = 1, L2 = J1/2+1. In case of an in-place transform with the CCE data format, even for a real array, you should set strides explicitly: L1 = 1, L2 = (J1/2+1)*2.

See Example “Computing 2D FFT by One-Dimensional Transforms” as an illustration of how to use the configuration parameters discussed above. See Storage schemes and Packed formats on how to define arrays for different formats.

Parent topic: Configuration Settings