<?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 2D FFT in C: confused in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/2D-FFT-in-C-confused/m-p/913298#M12328</link>
    <description>Hi folks. I'm trying to do a simple 2d real fft with MKL 9.0beta in C, and I'm getting garbage out, not sure why. I think it's something to do with data layout though.&lt;BR /&gt;&lt;BR /&gt;Here's my code; it's pretty simple:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="Courier New" size="2"&gt; /* Create float array of pixels. The idea is it should be rowsize across, and colsize down. It needs extra elements to hold the FFT data (in CCS format by default). */&lt;BR /&gt; int real_rowsize = 2 * (rowsize/2 + 1);&lt;BR /&gt; int complex_rowsize = rowsize/2 + 1;&lt;BR /&gt; int arraysize = real_colsize * complex_rowsize;&lt;BR /&gt; float *f_in = malloc(sizeof(float _Complex) * arraysize);&lt;BR /&gt; float *f_out = malloc(sizeof(float _Complex) * arraysize);&lt;BR /&gt; /* ... fill in f_in with image data... */&lt;BR /&gt;&lt;BR /&gt; length[0] = colsize;&lt;BR /&gt; length[1] = rowsize;&lt;BR /&gt; status = DftiCreateDescriptor(&amp;amp;desc_handle, DFTI_SINGLE, DFTI_REAL, 2, length);&lt;BR /&gt; status = DftiSetValue(desc_handle, DFTI_BACKWARD_SCALE, 1.0/(colsize * rowsize));&lt;BR /&gt; status = DftiCommitDescriptor(desc_handle);&lt;BR /&gt; status = DftiComputeForward(desc_handle, f_in);&lt;BR /&gt; memcpy(f_out, f_in, sizeof(float _Complex) * arraysize);&lt;BR /&gt; status = DftiComputeBackward(desc_handle, f_out);&lt;BR /&gt; /* read image data out of f_out. */&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;Looks trivial, and it should return f_out == f_in. But I get garbage. Actually not &lt;I&gt;quite &lt;/I&gt;garbage, I can see a little of my original image, like I'm looking at the LSBs or something. Can anyone see anything wrong with this?&lt;BR /&gt;&lt;BR /&gt;I know I've allocated enough memory, but I'm not sure I've got the length args right. Still, I think a fwd-&amp;gt;backward transform pair ought to work even if I got them backwards! What else is there to go wrong? I'm checking all the status return values and they're fine.&lt;BR /&gt;&lt;BR /&gt;This is on Windows ia32, btw, with the Intel 9.0 compiler and 9.0beta MKL. I'm linking with -lmkl_c -lmkl_ia32 -lguide40.&lt;BR /&gt;</description>
    <pubDate>Fri, 25 Aug 2006 07:04:15 GMT</pubDate>
    <dc:creator>gary-oberbrunner</dc:creator>
    <dc:date>2006-08-25T07:04:15Z</dc:date>
    <item>
      <title>2D FFT in C: confused</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/2D-FFT-in-C-confused/m-p/913298#M12328</link>
      <description>Hi folks. I'm trying to do a simple 2d real fft with MKL 9.0beta in C, and I'm getting garbage out, not sure why. I think it's something to do with data layout though.&lt;BR /&gt;&lt;BR /&gt;Here's my code; it's pretty simple:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="Courier New" size="2"&gt; /* Create float array of pixels. The idea is it should be rowsize across, and colsize down. It needs extra elements to hold the FFT data (in CCS format by default). */&lt;BR /&gt; int real_rowsize = 2 * (rowsize/2 + 1);&lt;BR /&gt; int complex_rowsize = rowsize/2 + 1;&lt;BR /&gt; int arraysize = real_colsize * complex_rowsize;&lt;BR /&gt; float *f_in = malloc(sizeof(float _Complex) * arraysize);&lt;BR /&gt; float *f_out = malloc(sizeof(float _Complex) * arraysize);&lt;BR /&gt; /* ... fill in f_in with image data... */&lt;BR /&gt;&lt;BR /&gt; length[0] = colsize;&lt;BR /&gt; length[1] = rowsize;&lt;BR /&gt; status = DftiCreateDescriptor(&amp;amp;desc_handle, DFTI_SINGLE, DFTI_REAL, 2, length);&lt;BR /&gt; status = DftiSetValue(desc_handle, DFTI_BACKWARD_SCALE, 1.0/(colsize * rowsize));&lt;BR /&gt; status = DftiCommitDescriptor(desc_handle);&lt;BR /&gt; status = DftiComputeForward(desc_handle, f_in);&lt;BR /&gt; memcpy(f_out, f_in, sizeof(float _Complex) * arraysize);&lt;BR /&gt; status = DftiComputeBackward(desc_handle, f_out);&lt;BR /&gt; /* read image data out of f_out. */&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;Looks trivial, and it should return f_out == f_in. But I get garbage. Actually not &lt;I&gt;quite &lt;/I&gt;garbage, I can see a little of my original image, like I'm looking at the LSBs or something. Can anyone see anything wrong with this?&lt;BR /&gt;&lt;BR /&gt;I know I've allocated enough memory, but I'm not sure I've got the length args right. Still, I think a fwd-&amp;gt;backward transform pair ought to work even if I got them backwards! What else is there to go wrong? I'm checking all the status return values and they're fine.&lt;BR /&gt;&lt;BR /&gt;This is on Windows ia32, btw, with the Intel 9.0 compiler and 9.0beta MKL. I'm linking with -lmkl_c -lmkl_ia32 -lguide40.&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Aug 2006 07:04:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/2D-FFT-in-C-confused/m-p/913298#M12328</guid>
      <dc:creator>gary-oberbrunner</dc:creator>
      <dc:date>2006-08-25T07:04:15Z</dc:date>
    </item>
  </channel>
</rss>

