<?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 The FFT adjusts only half size... in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/The-FFT-adjusts-only-half-size/m-p/876924#M9042</link>
    <description>&lt;P&gt;I attacthed the example source and the results.&lt;/P&gt;
&lt;P&gt;Please check it.&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;siinii&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------- -----&lt;/P&gt;
&lt;P&gt;The excerpt looks good, and it should process whole array.&lt;/P&gt;
&lt;P&gt;Could you provide a self-contained example that shows your problem?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Dima&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------- -----&lt;/P&gt;
&lt;P&gt;I received below source code from Dima. I adjusted it to image.&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------- -----&lt;/P&gt;
&lt;P&gt;You probably did the small size on a static array, defined as x[100][40]. The way the dynamic array is arranged in your example is incorrect and it demonstrates typical mistake. For static array '_complex x&lt;M&gt;&lt;N&gt;' expression 'x' has type '_complex *' whereas for dynamic array that one would use with double-subscript notation 'x&lt;I&gt;&lt;J&gt;' the type of 'x' is '_complex**' that is pointer to pointers. In other words, in this example when you call DftiComputeForward(..., x) the input data to the FFT routine is pointers, not the complex numbers!&lt;/J&gt;&lt;/I&gt;&lt;/N&gt;&lt;/M&gt;&lt;/P&gt;
&lt;P&gt;I'd suggest you to refrain from the practice of using double-subscript notation for dynamic arrays, and adopt the following usage instead:&lt;/P&gt;
&lt;P&gt;const int ROWS=3072, COLS=2560;&lt;/P&gt;
&lt;P&gt;const int ROWSIZE=COLS, COLSIZE=ROWS;&lt;/P&gt;
&lt;P&gt;_complex *x = new _complex[ROWS*COLS];&lt;/P&gt;
&lt;P&gt;#define x(r,c) x[*ROWSIZE+(c)] /* explicit row-major indexing */&lt;/P&gt;
&lt;P&gt;memset(x,0,sizeof(x[0])*ROWS*COLS); /* zero fill initialization */&lt;/P&gt;
&lt;P&gt;for (r=0;r&lt;/P&gt;
&lt;P&gt;The rest of this reply is duplicating your example in the above terms.&lt;/P&gt;
&lt;P&gt;DftiCreateDescriptor(rowfft,DFTI_SINGLE,DFTI_COMPLEX,1,ROWSIZE); /* stride 1 by default */&lt;/P&gt;
&lt;P&gt;DftiSetValue(rowfft,DFTI_NUMBER_OF_TRANSFORMS,(MKL_LONG)ROWS);&lt;/P&gt;
&lt;P&gt;DftiSetValue(rowfft,DFTI_INPUT_DISTANCE,(MKL_LONG)ROWSIZE);&lt;/P&gt;
&lt;P&gt;DftiSetValue(rowfft,DFTI_OUTPUT_DISTANCE,(MKL_LONG)ROWSIZE);&lt;/P&gt;
&lt;P&gt;DftiCreateDescriptor(colfft,DFTI_SINGLE,DFTI_COMPLEX,1,COLSIZE); /* will set strides */&lt;/P&gt;
&lt;P&gt;MKL_LONG colfft_strides[] = { 0, ROWSIZE };&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_INPUT_STRIDES,colfft_strides);&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_OUTPUT_STRIDES,colfft_strides);&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_NUMBER_OF_TRANSFORMS,(MKL_LONG)COLS);&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_INPUT_DISTANCE,(MKL_LONG)1);&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_OUTPUT_DISTANCE,(MKL_LONG)1);&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;DftiComputeForward(rowfft,x);&lt;/P&gt;
&lt;P&gt;DftiComputeForward(colfft,x);&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Dima&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------- -----&lt;/P&gt;
&lt;P&gt;///FFT&lt;/P&gt;
&lt;P&gt;DftiComputeForward(rowfft,x);&lt;/P&gt;
&lt;P&gt;DftiComputeForward(colfft,x);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;//Inverse FFT&lt;/P&gt;
&lt;P&gt;DftiComputeBackward(rowfft,x);&lt;/P&gt;
&lt;P&gt;DftiComputeBackward(colfft,x);&lt;/P&gt;
&lt;P&gt;like this...&lt;/P&gt;
&lt;P&gt;but The FFT adjusted only 2560*1536(original image size is 2560*3072)&lt;/P&gt;
&lt;P&gt;Which code should I change?&lt;/P&gt;</description>
    <pubDate>Fri, 05 Mar 2010 02:46:11 GMT</pubDate>
    <dc:creator>siinii</dc:creator>
    <dc:date>2010-03-05T02:46:11Z</dc:date>
    <item>
      <title>The FFT adjusts only half size...</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/The-FFT-adjusts-only-half-size/m-p/876924#M9042</link>
      <description>&lt;P&gt;I attacthed the example source and the results.&lt;/P&gt;
&lt;P&gt;Please check it.&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;siinii&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------- -----&lt;/P&gt;
&lt;P&gt;The excerpt looks good, and it should process whole array.&lt;/P&gt;
&lt;P&gt;Could you provide a self-contained example that shows your problem?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Dima&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------- -----&lt;/P&gt;
&lt;P&gt;I received below source code from Dima. I adjusted it to image.&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------- -----&lt;/P&gt;
&lt;P&gt;You probably did the small size on a static array, defined as x[100][40]. The way the dynamic array is arranged in your example is incorrect and it demonstrates typical mistake. For static array '_complex x&lt;M&gt;&lt;N&gt;' expression 'x' has type '_complex *' whereas for dynamic array that one would use with double-subscript notation 'x&lt;I&gt;&lt;J&gt;' the type of 'x' is '_complex**' that is pointer to pointers. In other words, in this example when you call DftiComputeForward(..., x) the input data to the FFT routine is pointers, not the complex numbers!&lt;/J&gt;&lt;/I&gt;&lt;/N&gt;&lt;/M&gt;&lt;/P&gt;
&lt;P&gt;I'd suggest you to refrain from the practice of using double-subscript notation for dynamic arrays, and adopt the following usage instead:&lt;/P&gt;
&lt;P&gt;const int ROWS=3072, COLS=2560;&lt;/P&gt;
&lt;P&gt;const int ROWSIZE=COLS, COLSIZE=ROWS;&lt;/P&gt;
&lt;P&gt;_complex *x = new _complex[ROWS*COLS];&lt;/P&gt;
&lt;P&gt;#define x(r,c) x[*ROWSIZE+(c)] /* explicit row-major indexing */&lt;/P&gt;
&lt;P&gt;memset(x,0,sizeof(x[0])*ROWS*COLS); /* zero fill initialization */&lt;/P&gt;
&lt;P&gt;for (r=0;r&lt;/P&gt;
&lt;P&gt;The rest of this reply is duplicating your example in the above terms.&lt;/P&gt;
&lt;P&gt;DftiCreateDescriptor(rowfft,DFTI_SINGLE,DFTI_COMPLEX,1,ROWSIZE); /* stride 1 by default */&lt;/P&gt;
&lt;P&gt;DftiSetValue(rowfft,DFTI_NUMBER_OF_TRANSFORMS,(MKL_LONG)ROWS);&lt;/P&gt;
&lt;P&gt;DftiSetValue(rowfft,DFTI_INPUT_DISTANCE,(MKL_LONG)ROWSIZE);&lt;/P&gt;
&lt;P&gt;DftiSetValue(rowfft,DFTI_OUTPUT_DISTANCE,(MKL_LONG)ROWSIZE);&lt;/P&gt;
&lt;P&gt;DftiCreateDescriptor(colfft,DFTI_SINGLE,DFTI_COMPLEX,1,COLSIZE); /* will set strides */&lt;/P&gt;
&lt;P&gt;MKL_LONG colfft_strides[] = { 0, ROWSIZE };&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_INPUT_STRIDES,colfft_strides);&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_OUTPUT_STRIDES,colfft_strides);&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_NUMBER_OF_TRANSFORMS,(MKL_LONG)COLS);&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_INPUT_DISTANCE,(MKL_LONG)1);&lt;/P&gt;
&lt;P&gt;DftiSetValue(colfft,DFTI_OUTPUT_DISTANCE,(MKL_LONG)1);&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;DftiComputeForward(rowfft,x);&lt;/P&gt;
&lt;P&gt;DftiComputeForward(colfft,x);&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Dima&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------------- -----&lt;/P&gt;
&lt;P&gt;///FFT&lt;/P&gt;
&lt;P&gt;DftiComputeForward(rowfft,x);&lt;/P&gt;
&lt;P&gt;DftiComputeForward(colfft,x);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;//Inverse FFT&lt;/P&gt;
&lt;P&gt;DftiComputeBackward(rowfft,x);&lt;/P&gt;
&lt;P&gt;DftiComputeBackward(colfft,x);&lt;/P&gt;
&lt;P&gt;like this...&lt;/P&gt;
&lt;P&gt;but The FFT adjusted only 2560*1536(original image size is 2560*3072)&lt;/P&gt;
&lt;P&gt;Which code should I change?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2010 02:46:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/The-FFT-adjusts-only-half-size/m-p/876924#M9042</guid>
      <dc:creator>siinii</dc:creator>
      <dc:date>2010-03-05T02:46:11Z</dc:date>
    </item>
    <item>
      <title>The FFT adjusts only half size...</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/The-FFT-adjusts-only-half-size/m-p/876925#M9043</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;See below slightly corrected test (on plain Cbut printing elements) with just added scaling because DFTI is not normalized.&lt;/P&gt;
&lt;P&gt;Also, the last loop at the end was deleted (maybe,it's your problem?)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;#include "stdio.h"&lt;BR /&gt;#include "string.h"&lt;BR /&gt;#include "mkl.h"&lt;/P&gt;
&lt;P&gt;typedef struct {float x,y;} singlecomplex;&lt;BR /&gt;int main(void) {&lt;BR /&gt;int r,c;&lt;/P&gt;
&lt;P&gt;const int ROWS=3072, COLS=2560;&lt;BR /&gt;//const int ROWS=3, COLS=5;&lt;/P&gt;
&lt;P&gt;const int ROWSIZE=COLS, COLSIZE=ROWS;&lt;/P&gt;
&lt;P&gt;//float complex *xx; = new _complex[ROWS*COLS];&lt;BR /&gt;singlecomplex* xx;&lt;/P&gt;
&lt;P&gt;xx = (singlecomplex *)malloc(2*sizeof(float)*ROWS*COLS);&lt;/P&gt;
&lt;P&gt;memset(xx,0,2*sizeof(float)*ROWS*COLS); /* zero fill initialization */&lt;/P&gt;
&lt;P&gt;for(r=0;r&lt;ROWS&gt;&lt;/ROWS&gt;{&lt;BR /&gt;for (c=0;c&lt;COLS&gt;&lt;/COLS&gt;{&lt;BR /&gt;xx[*ROWSIZE+(c)].x = r*10.0f+c;&lt;BR /&gt;xx[*ROWSIZE+(c)].y = c*10.0f+r;&lt;BR /&gt;//xx[*ROWSIZE+(c)].x = (img[*ROWSIZE+(c)]);&lt;BR /&gt;//xx[*ROWSIZE+(c)].y = (img[*ROWSIZE+(c)]);&lt;BR /&gt;//printf("init xx[%d,%d]=%f %f\n", r, c, xx[*ROWSIZE+(c)].x, xx[*ROWSIZE+(c)].y);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;printf("init xx[*-1,*-1]=%f %f\n", xx[(ROWS-1)*ROWSIZE+(COLS-1)].x, xx[(ROWS-1)*ROWSIZE+(COLS-1)].y);&lt;/P&gt;
&lt;P&gt;int Height_f = ROWS;&lt;BR /&gt;int Widtht_f = COLS;&lt;/P&gt;
&lt;P&gt;DFTI_DESCRIPTOR_HANDLE rowfft;&lt;BR /&gt;DFTI_DESCRIPTOR_HANDLE colfft;&lt;BR /&gt;MKL_LONG status;&lt;BR /&gt;MKL_LONG colfft_strides[] = {0, ROWSIZE};&lt;/P&gt;
&lt;P&gt;////////////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;&lt;BR /&gt;status = DftiCreateDescriptor(&amp;amp;rowfft, DFTI_SINGLE, DFTI_COMPLEX, 1, (MKL_LONG)ROWSIZE); /* stride 1 by default */&lt;BR /&gt;status = DftiSetValue(rowfft, DFTI_NUMBER_OF_TRANSFORMS, (MKL_LONG)ROWS);&lt;BR /&gt;status = DftiSetValue(rowfft, DFTI_INPUT_DISTANCE, (MKL_LONG)ROWSIZE);&lt;BR /&gt;status = DftiSetValue(rowfft, DFTI_BACKWARD_SCALE, 1.0/(ROWS*COLS));&lt;BR /&gt;//status = DftiSetValue(rowfft, DFTI_OUTPUT_DISTANCE, (MKL_LONG)ROWSIZE); // not needed for in-place&lt;/P&gt;
&lt;P&gt;status = DftiCreateDescriptor(&amp;amp;colfft, DFTI_SINGLE, DFTI_COMPLEX, 1, (MKL_LONG)COLSIZE); /* will set strides */&lt;BR /&gt;status = DftiSetValue(colfft, DFTI_NUMBER_OF_TRANSFORMS, (MKL_LONG)COLS);&lt;BR /&gt;status = DftiSetValue(colfft, DFTI_INPUT_DISTANCE, (MKL_LONG)1);&lt;BR /&gt;//status = DftiSetValue(colfft, DFTI_OUTPUT_DISTANCE, (MKL_LONG)1); // not needed for in-place&lt;BR /&gt;status = DftiSetValue(colfft, DFTI_INPUT_STRIDES, colfft_strides);&lt;BR /&gt;//status = DftiSetValue(colfft, DFTI_OUTPUT_STRIDES, colfft_strides); // not needed for in-place&lt;/P&gt;
&lt;P&gt;status = DftiCommitDescriptor( rowfft);&lt;BR /&gt;status = DftiComputeForward(rowfft, xx);&lt;/P&gt;
&lt;P&gt;status = DftiCommitDescriptor( colfft);&lt;BR /&gt;status = DftiComputeForward(colfft, xx);&lt;/P&gt;
&lt;P&gt;//////&lt;BR /&gt;printf("\n");&lt;BR /&gt;for(r=0;r&lt;HEIGHT_F&gt;&lt;/HEIGHT_F&gt;{&lt;BR /&gt;for (c=0;c&lt;WIDTHT_F&gt;&lt;/WIDTHT_F&gt;{&lt;BR /&gt;//printf("transformed xx[%d,%d]=%f %f\n", r, c, xx[*ROWSIZE+(c)].x, xx[*ROWSIZE+(c)].y);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;printf("transformed xx[*-1,*-1]=%f %f\n", xx[(ROWS-1)*ROWSIZE+(COLS-1)].x, xx[(ROWS-1)*ROWSIZE+(COLS-1)].y);&lt;/P&gt;
&lt;P&gt;//////When Inverse FFT I add below&lt;/P&gt;
&lt;P&gt;//status = DftiCommitDescriptor( rowfft); // not needed at all&lt;BR /&gt;//status = DftiCommitDescriptor( colfft);&lt;/P&gt;
&lt;P&gt;status = DftiComputeBackward(colfft, xx);&lt;BR /&gt;status = DftiComputeBackward(rowfft, xx);&lt;BR /&gt;&lt;BR /&gt;status = DftiFreeDescriptor(&amp;amp;rowfft);&lt;BR /&gt;status = DftiFreeDescriptor(&amp;amp;colfft);&lt;/P&gt;
&lt;P&gt;printf("\n");&lt;BR /&gt;for(r=0;r&lt;HEIGHT_F&gt;&lt;/HEIGHT_F&gt;{&lt;BR /&gt;for (c=0;c&lt;WIDTHT_F&gt;&lt;/WIDTHT_F&gt;{&lt;BR /&gt;//(img[*ROWSIZE+(c)]) = xx[*ROWSIZE+(c)].y;&lt;BR /&gt;//printf("after xx[%d,%d]=%f %f\n", r, c, xx[*ROWSIZE+(c)].x, xx[*ROWSIZE+(c)].y);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;printf("after xx[*-1,*-1]=%f %f\n", xx[(ROWS-1)*ROWSIZE+(COLS-1)].x, xx[(ROWS-1)*ROWSIZE+(COLS-1)].y);&lt;/P&gt;
&lt;P&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;what outputs last elements:&lt;/P&gt;
&lt;P&gt;init xx[*-1,*-1]=33269.000000 28661.000000&lt;/P&gt;
&lt;P&gt;transformed xx[*-1,*-1]=0.000000 0.000000&lt;/P&gt;
&lt;P&gt;after xx[*-1,*-1]=33269.000000 28661.003906&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Please try to uncomment all prints to see all elements.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2010 14:01:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/The-FFT-adjusts-only-half-size/m-p/876925#M9043</guid>
      <dc:creator>barragan_villanueva_</dc:creator>
      <dc:date>2010-03-05T14:01:59Z</dc:date>
    </item>
  </channel>
</rss>

