<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Question about strides in real-to-complex FFT in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Question-about-strides-in-real-to-complex-FFT/m-p/821223#M4755</link>
    <description>Dear all,&lt;BR /&gt;&lt;BR /&gt;I'm having trouble getting strides properly working
using DFTI, in particular when doing multiple real-to-complex FFTs, and
trying to transpose the FFT values in the output.&lt;BR /&gt;&lt;BR /&gt;Given that this is my matrix X (stored row-major, I'm using C++):&lt;BR /&gt;&lt;BR /&gt;X: 101.000 102.320 102.483 101.152&lt;BR /&gt;X: 202.320 206.381 205.759 201.671&lt;BR /&gt;X: 302.483 305.759 306.163 302.859&lt;BR /&gt;&lt;BR /&gt;The forward FFT's of each of the three rows are these (they are expected and correct):&lt;BR /&gt;&lt;BR /&gt;FX: ( 406.954 0.000) ( -1.483 -1.168) ( 0.011 0.000)&lt;BR /&gt;FX: ( 816.132 0.000) ( -3.439 -4.710) ( 0.026 0.000)&lt;BR /&gt;FX: ( 1217.264 0.000) ( -3.681 -2.900) ( 0.028 0.000)&lt;BR /&gt;&lt;BR /&gt;However, when I try to have MKL transpose the result within the FFT call, I cannot get this working. The best I can get is this:&lt;BR /&gt;&lt;BR /&gt;FXT: ( 406.954 0.000) ( 816.132 0.000) ( 1217.264 0.000)&lt;BR /&gt;FXT: ( -1.483 0.000) ( -3.439 -1.168) ( -3.681 -4.710)&lt;BR /&gt;FXT: ( 0.011 -2.900) ( 0.026 0.000) ( 0.028 0.000)&lt;BR /&gt;&lt;BR /&gt;The
first row is correct; furtermore, the real values of the second and
third rows are also correct. However, the imaginary values of the
second and third row are wrong; apparantly, they have moved one column
to the right!&lt;BR /&gt;&lt;BR /&gt;In all probability I am doing something wrong; I would be very grateful if anyone can help to point out my mistake.&lt;BR /&gt;&lt;BR /&gt;I have included my code that generates the output shown above below.&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Best regards, Sidney Cadot&lt;BR /&gt;&lt;BR /&gt;#include &lt;COMPLEX&gt;&lt;BR /&gt;#include &lt;CSTDIO&gt;&lt;BR /&gt;#include &lt;CASSERT&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;MKL_DFTI.H&gt;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; const unsigned NH = 3;&lt;BR /&gt; const unsigned NS = 4;&lt;BR /&gt; const unsigned NF = NS / 2 + 1;&lt;BR /&gt;&lt;BR /&gt; float X[NH * NS];&lt;BR /&gt; std::complex&lt;FLOAT&gt; FX [NH * NF];&lt;BR /&gt; std::complex&lt;FLOAT&gt; FXT[NF * NH];&lt;BR /&gt;&lt;BR /&gt; for (unsigned int i = 0; i &amp;lt; NH; ++i)&lt;BR /&gt; {&lt;BR /&gt; for (unsigned j = 0; j &amp;lt; NS; ++j)&lt;BR /&gt; {&lt;BR /&gt; X[i * NS + j] = 100 * (i + 1) + sin(i * j / double(NS) * 2.0 * M_PI ) + exp(sin(i) + sin(j));&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; for (unsigned int i = 0; i &amp;lt; NH; ++i)&lt;BR /&gt; {&lt;BR /&gt; printf("X:");&lt;BR /&gt; for (unsigned j = 0; j &amp;lt; NS; ++j)&lt;BR /&gt; {&lt;BR /&gt; printf(" %10.3f", X[i * NS + j]);&lt;BR /&gt; }&lt;BR /&gt; printf("n");&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; printf("n");&lt;BR /&gt;&lt;BR /&gt; // Do FFT&lt;BR /&gt;&lt;BR /&gt; {&lt;BR /&gt; MKL_LONG status;&lt;BR /&gt;&lt;BR /&gt; // create&lt;BR /&gt;&lt;BR /&gt; DFTI_DESCRIPTOR_HANDLE fft;&lt;BR /&gt;&lt;BR /&gt; status = DftiCreateDescriptor(&amp;amp;fft, DFTI_SINGLE, DFTI_REAL, 1, NS);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // configure&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_NUMBER_OF_TRANSFORMS, NH);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_PLACEMENT, DFTI_NOT_INPLACE);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_INPUT_DISTANCE, NS);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_OUTPUT_DISTANCE, 2 * NF);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; MKL_LONG output_strides[] = {0, 1};&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_OUTPUT_STRIDES, output_strides);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiCommitDescriptor(fft);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // execute&lt;BR /&gt;&lt;BR /&gt; status = DftiComputeForward(fft, X, FX);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // dispose&lt;BR /&gt;&lt;BR /&gt; status = DftiFreeDescriptor(&amp;amp;fft);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; for (unsigned int i = 0; i &amp;lt; NH; ++i)&lt;BR /&gt; {&lt;BR /&gt; printf("FX:");&lt;BR /&gt; for (unsigned j = 0; j &amp;lt; NF; ++j)&lt;BR /&gt; {&lt;BR /&gt; printf(" (%10.3f %10.3f)", std::real(FX[i * NF + j]), std::imag(FX[i * NF + j]));&lt;BR /&gt; }&lt;BR /&gt; printf("n");&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; printf("n");&lt;BR /&gt;&lt;BR /&gt; // Do FFT with implicit transpose of output data&lt;BR /&gt;&lt;BR /&gt; {&lt;BR /&gt; MKL_LONG status;&lt;BR /&gt;&lt;BR /&gt; // create&lt;BR /&gt;&lt;BR /&gt; DFTI_DESCRIPTOR_HANDLE fft;&lt;BR /&gt;&lt;BR /&gt; status = DftiCreateDescriptor(&amp;amp;fft, DFTI_SINGLE, DFTI_REAL, 1, NS); // OK&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // configure&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_NUMBER_OF_TRANSFORMS, NH); // OK&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_PLACEMENT, DFTI_NOT_INPLACE); // ok&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_INPUT_DISTANCE, NS); // OK&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_OUTPUT_DISTANCE, 2); // OK&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; MKL_LONG output_strides[] = {0, NH};&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_OUTPUT_STRIDES, output_strides);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiCommitDescriptor(fft);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // execute&lt;BR /&gt;&lt;BR /&gt; status = DftiComputeForward(fft, X, FXT);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // dispose&lt;BR /&gt;&lt;BR /&gt; status = DftiFreeDescriptor(&amp;amp;fft);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; // Done&lt;BR /&gt;&lt;BR /&gt; for (unsigned int i = 0; i &amp;lt; NF; ++i)&lt;BR /&gt; {&lt;BR /&gt; printf("FXT:");&lt;BR /&gt; for (unsigned j = 0; j &amp;lt; NH; ++j)&lt;BR /&gt; {&lt;BR /&gt; printf(" (%10.3f %10.3f)", std::real(FXT[i * NH + j]), std::imag(FXT[i * NH + j]));&lt;BR /&gt; }&lt;BR /&gt; printf("n");&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/FLOAT&gt;&lt;/FLOAT&gt;&lt;/MKL_DFTI.H&gt;&lt;/CASSERT&gt;&lt;/CSTDIO&gt;&lt;/COMPLEX&gt;</description>
    <pubDate>Fri, 17 Sep 2010 13:12:35 GMT</pubDate>
    <dc:creator>Sidney_Cadot</dc:creator>
    <dc:date>2010-09-17T13:12:35Z</dc:date>
    <item>
      <title>Question about strides in real-to-complex FFT</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Question-about-strides-in-real-to-complex-FFT/m-p/821223#M4755</link>
      <description>Dear all,&lt;BR /&gt;&lt;BR /&gt;I'm having trouble getting strides properly working
using DFTI, in particular when doing multiple real-to-complex FFTs, and
trying to transpose the FFT values in the output.&lt;BR /&gt;&lt;BR /&gt;Given that this is my matrix X (stored row-major, I'm using C++):&lt;BR /&gt;&lt;BR /&gt;X: 101.000 102.320 102.483 101.152&lt;BR /&gt;X: 202.320 206.381 205.759 201.671&lt;BR /&gt;X: 302.483 305.759 306.163 302.859&lt;BR /&gt;&lt;BR /&gt;The forward FFT's of each of the three rows are these (they are expected and correct):&lt;BR /&gt;&lt;BR /&gt;FX: ( 406.954 0.000) ( -1.483 -1.168) ( 0.011 0.000)&lt;BR /&gt;FX: ( 816.132 0.000) ( -3.439 -4.710) ( 0.026 0.000)&lt;BR /&gt;FX: ( 1217.264 0.000) ( -3.681 -2.900) ( 0.028 0.000)&lt;BR /&gt;&lt;BR /&gt;However, when I try to have MKL transpose the result within the FFT call, I cannot get this working. The best I can get is this:&lt;BR /&gt;&lt;BR /&gt;FXT: ( 406.954 0.000) ( 816.132 0.000) ( 1217.264 0.000)&lt;BR /&gt;FXT: ( -1.483 0.000) ( -3.439 -1.168) ( -3.681 -4.710)&lt;BR /&gt;FXT: ( 0.011 -2.900) ( 0.026 0.000) ( 0.028 0.000)&lt;BR /&gt;&lt;BR /&gt;The
first row is correct; furtermore, the real values of the second and
third rows are also correct. However, the imaginary values of the
second and third row are wrong; apparantly, they have moved one column
to the right!&lt;BR /&gt;&lt;BR /&gt;In all probability I am doing something wrong; I would be very grateful if anyone can help to point out my mistake.&lt;BR /&gt;&lt;BR /&gt;I have included my code that generates the output shown above below.&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Best regards, Sidney Cadot&lt;BR /&gt;&lt;BR /&gt;#include &lt;COMPLEX&gt;&lt;BR /&gt;#include &lt;CSTDIO&gt;&lt;BR /&gt;#include &lt;CASSERT&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;MKL_DFTI.H&gt;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; const unsigned NH = 3;&lt;BR /&gt; const unsigned NS = 4;&lt;BR /&gt; const unsigned NF = NS / 2 + 1;&lt;BR /&gt;&lt;BR /&gt; float X[NH * NS];&lt;BR /&gt; std::complex&lt;FLOAT&gt; FX [NH * NF];&lt;BR /&gt; std::complex&lt;FLOAT&gt; FXT[NF * NH];&lt;BR /&gt;&lt;BR /&gt; for (unsigned int i = 0; i &amp;lt; NH; ++i)&lt;BR /&gt; {&lt;BR /&gt; for (unsigned j = 0; j &amp;lt; NS; ++j)&lt;BR /&gt; {&lt;BR /&gt; X[i * NS + j] = 100 * (i + 1) + sin(i * j / double(NS) * 2.0 * M_PI ) + exp(sin(i) + sin(j));&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; for (unsigned int i = 0; i &amp;lt; NH; ++i)&lt;BR /&gt; {&lt;BR /&gt; printf("X:");&lt;BR /&gt; for (unsigned j = 0; j &amp;lt; NS; ++j)&lt;BR /&gt; {&lt;BR /&gt; printf(" %10.3f", X[i * NS + j]);&lt;BR /&gt; }&lt;BR /&gt; printf("n");&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; printf("n");&lt;BR /&gt;&lt;BR /&gt; // Do FFT&lt;BR /&gt;&lt;BR /&gt; {&lt;BR /&gt; MKL_LONG status;&lt;BR /&gt;&lt;BR /&gt; // create&lt;BR /&gt;&lt;BR /&gt; DFTI_DESCRIPTOR_HANDLE fft;&lt;BR /&gt;&lt;BR /&gt; status = DftiCreateDescriptor(&amp;amp;fft, DFTI_SINGLE, DFTI_REAL, 1, NS);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // configure&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_NUMBER_OF_TRANSFORMS, NH);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_PLACEMENT, DFTI_NOT_INPLACE);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_INPUT_DISTANCE, NS);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_OUTPUT_DISTANCE, 2 * NF);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; MKL_LONG output_strides[] = {0, 1};&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_OUTPUT_STRIDES, output_strides);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiCommitDescriptor(fft);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // execute&lt;BR /&gt;&lt;BR /&gt; status = DftiComputeForward(fft, X, FX);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // dispose&lt;BR /&gt;&lt;BR /&gt; status = DftiFreeDescriptor(&amp;amp;fft);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; for (unsigned int i = 0; i &amp;lt; NH; ++i)&lt;BR /&gt; {&lt;BR /&gt; printf("FX:");&lt;BR /&gt; for (unsigned j = 0; j &amp;lt; NF; ++j)&lt;BR /&gt; {&lt;BR /&gt; printf(" (%10.3f %10.3f)", std::real(FX[i * NF + j]), std::imag(FX[i * NF + j]));&lt;BR /&gt; }&lt;BR /&gt; printf("n");&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; printf("n");&lt;BR /&gt;&lt;BR /&gt; // Do FFT with implicit transpose of output data&lt;BR /&gt;&lt;BR /&gt; {&lt;BR /&gt; MKL_LONG status;&lt;BR /&gt;&lt;BR /&gt; // create&lt;BR /&gt;&lt;BR /&gt; DFTI_DESCRIPTOR_HANDLE fft;&lt;BR /&gt;&lt;BR /&gt; status = DftiCreateDescriptor(&amp;amp;fft, DFTI_SINGLE, DFTI_REAL, 1, NS); // OK&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // configure&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_NUMBER_OF_TRANSFORMS, NH); // OK&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_PLACEMENT, DFTI_NOT_INPLACE); // ok&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_INPUT_DISTANCE, NS); // OK&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_OUTPUT_DISTANCE, 2); // OK&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; MKL_LONG output_strides[] = {0, NH};&lt;BR /&gt;&lt;BR /&gt; status = DftiSetValue(fft, DFTI_OUTPUT_STRIDES, output_strides);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; status = DftiCommitDescriptor(fft);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // execute&lt;BR /&gt;&lt;BR /&gt; status = DftiComputeForward(fft, X, FXT);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt;&lt;BR /&gt; // dispose&lt;BR /&gt;&lt;BR /&gt; status = DftiFreeDescriptor(&amp;amp;fft);&lt;BR /&gt; assert(status == 0);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; // Done&lt;BR /&gt;&lt;BR /&gt; for (unsigned int i = 0; i &amp;lt; NF; ++i)&lt;BR /&gt; {&lt;BR /&gt; printf("FXT:");&lt;BR /&gt; for (unsigned j = 0; j &amp;lt; NH; ++j)&lt;BR /&gt; {&lt;BR /&gt; printf(" (%10.3f %10.3f)", std::real(FXT[i * NH + j]), std::imag(FXT[i * NH + j]));&lt;BR /&gt; }&lt;BR /&gt; printf("n");&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/FLOAT&gt;&lt;/FLOAT&gt;&lt;/MKL_DFTI.H&gt;&lt;/CASSERT&gt;&lt;/CSTDIO&gt;&lt;/COMPLEX&gt;</description>
      <pubDate>Fri, 17 Sep 2010 13:12:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Question-about-strides-in-real-to-complex-FFT/m-p/821223#M4755</guid>
      <dc:creator>Sidney_Cadot</dc:creator>
      <dc:date>2010-09-17T13:12:35Z</dc:date>
    </item>
    <item>
      <title>Question about strides in real-to-complex FFT</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Question-about-strides-in-real-to-complex-FFT/m-p/821224#M4756</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Looks like you expect CCE layout of the result, but in fact you've got screwed 2D CCS layout.&lt;BR /&gt;If you add DftiSetValue(fft,DFTI_CONJUGATE_EVEN_STORAGE,DFTI_COMPLEX_COMPLEX) after descriptor is created, everything should work as expected.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Dima&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2010 13:55:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Question-about-strides-in-real-to-complex-FFT/m-p/821224#M4756</guid>
      <dc:creator>Dmitry_B_Intel</dc:creator>
      <dc:date>2010-09-17T13:55:40Z</dc:date>
    </item>
    <item>
      <title>Question about strides in real-to-complex FFT</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Question-about-strides-in-real-to-complex-FFT/m-p/821225#M4757</link>
      <description>This does work (at least, when I also set DFTI_OUTPUT_DISTANCE to 1) -- thanks. I am not quite sure why though, the section describing the data layout options is hard to comprehend.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt; Sidney&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Sep 2010 16:17:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Question-about-strides-in-real-to-complex-FFT/m-p/821225#M4757</guid>
      <dc:creator>Sidney_Cadot</dc:creator>
      <dc:date>2010-09-17T16:17:44Z</dc:date>
    </item>
  </channel>
</rss>

