Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6617 Discussions

## How to do a 2d Fourier tranformation stored in column-major? Beginner
149 Views

I have read the MKL manual but I can hardly understand the explanation below:

```MKL_LONG dims[] = { nd, …, n2, n1 };
DftiCreateDescriptor( &hand, precision, domain, d, dims );
// The above call assumes data declaration:  type X[nd]…[n2][n1]
// Default strides are { 0, nd*…*n2*n1, …,  n2*n1, n1, 1 }```

It is obvious that there are nd+2 elements in the strides configurations, i.e., for 2d data, the default strides are {0, n2*n1, n1, 1},

the first element 0 is the default value for s0, except which there are still 3 elements.

I don't know how to under the configuration of strides.

By now, I have a 2d data stored in column-major, how to set the strides for the column-major storage?

2 Replies Employee
149 Views

Hi

It seems bring some confusion here.  I will check internally.

but the key is  how the x(k1, K2) are gotten.

The memory address of the
element X(k1, k2 , ..., kd) is expressed by the formula
address of X(k1, k2, ..., kd) = address of X(0, 0, ..., 0) + offset
= address of X(0, 0, ..., 0) + s0 + k1*s1 + k2*s2 + ...+ kd*sd,
where s0 is the displacement and s1, ..., sd are generalized strides.

So for 2d data,   for   column-major storage,  X(k1,k2)= x(0,0)+K1*1 + K2* row-number, the strides looks be {0, 1, row-number}

You may refer to some sample coded under MKL install directory. for example, mkl_example\examples_core_c\dftc\source\config_placement.c to understand the stride and the compress format if real.

Regards

Ying Beginner
149 Views

Thanks！

I have guessed the solution.

Yours,

Ying H (Intel) wrote:

Hi

It seems bring some confusion here.  I will check internally.

but the key is  how the x(k1, K2) are gotten.

The memory address of the
element X(k1, k2 , ..., kd) is expressed by the formula
address of X(k1, k2, ..., kd) = address of X(0, 0, ..., 0) + offset
= address of X(0, 0, ..., 0) + s0 + k1*s1 + k2*s2 + ...+ kd*sd,
where s0 is the displacement and s1, ..., sd are generalized strides.

So for 2d data,   for   column-major storage,  X(k1,k2)= x(0,0)+K1*1 + K2* row-number, the strides looks be {0, 1, row-number}

You may refer to some sample coded under MKL install directory. for example, mkl_example\examples_core_c\dftc\source\config_placement.c to understand the stride and the compress format if real.

Regards

Ying 