<?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 3D FFT examples: forward-&amp;gt;backward works, backward-&amp;gt;forward doe in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/3D-FFT-examples-forward-gt-backward-works-backward-gt-forward/m-p/819601#M4613</link>
    <description>Most of it is not. However, some symmetry should be present (e.g. Im(Y(0,0,0)==0).&lt;BR /&gt;Dima</description>
    <pubDate>Sat, 30 Oct 2010 16:17:36 GMT</pubDate>
    <dc:creator>Dmitry_B_Intel</dc:creator>
    <dc:date>2010-10-30T16:17:36Z</dc:date>
    <item>
      <title>3D FFT examples: forward-&gt;backward works, backward-&gt;forward doesn't</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/3D-FFT-examples-forward-gt-backward-works-backward-gt-forward/m-p/819598#M4610</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I am doing a very similar test to the dfti-examples.&lt;BR /&gt;&lt;BR /&gt;Take example real_3d_cce_double_ex2.c:&lt;BR /&gt;&lt;BR /&gt;(1) It does a forward and a backward fft and it checks the error on the real domain to see if we get back the original data.&lt;BR /&gt;&lt;BR /&gt;Now I'm trying to do the opposite with the same fft settings:&lt;BR /&gt;&lt;BR /&gt;(2) I first do a backward and then a forward fft and I check the error on the complex domain to see if I can get back the original&lt;BR /&gt;(complex) data.&lt;BR /&gt;&lt;BR /&gt;However, (1) works (i.e. I get error ~1.0e-15), but in case (2) the error is large.&lt;BR /&gt;&lt;BR /&gt;&lt;B&gt;Details:&lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt;The code below uses the following constants:&lt;BR /&gt;&lt;PRE&gt;[cpp]const MKL_LONG N = 32;
const MKL_LONG LENGTHS[3] = {N,N,N};
const MKL_LONG PS[4] = {0,N*N,N,1};
const MKL_LONG SS[4] = {0,N*(N/2+1),N/2+1,1};
const MKL_LONG PO = N*N*N;
const MKL_LONG SO = N*N*(N/2+1);&lt;BR /&gt;const MKL_LONG n = 1;[/cpp]&lt;/PRE&gt; &lt;BR /&gt;My settings for (both forward and backward) fft are as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[cpp]if ( status = DftiCreateDescriptor(fft, DFTI_DOUBLE, DFTI_REAL, 3, LENGTHS) )
    ERR(DftiErrorMessage(status));

  if ( status = DftiSetValue(*fft, DFTI_PLACEMENT, DFTI_NOT_INPLACE) )
    ERR(DftiErrorMessage(status));

  if ( status = DftiSetValue(*fft, DFTI_CONJUGATE_EVEN_STORAGE, DFTI_COMPLEX_COMPLEX) )
    ERR(DftiErrorMessage(status));

  if ( status = DftiSetValue(*fft, DFTI_PACKED_FORMAT, DFTI_CCE_FORMAT) )
    ERR(DftiErrorMessage(status));

  if ( status = DftiSetValue(*fft, DFTI_NUMBER_OF_TRANSFORMS, n) )
    ERR(DftiErrorMessage(status));

  if ( status = DftiSetValue(*fft, DFTI_FORWARD_SCALE, 1.0) )
    ERR(DftiErrorMessage(status));

  if ( status = DftiSetValue(*fft, DFTI_BACKWARD_SCALE, 1.0/(double)PO) )
    ERR(DftiErrorMessage(status));[/cpp]&lt;/PRE&gt; &lt;BR /&gt;Settings for only forward fft:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[cpp] // specifically initialize for forward (physical to spectral) transform
    if ( status = DftiSetValue(fft, DFTI_INPUT_DISTANCE, PO) )
      ERR(DftiErrorMessage(status));

    if ( status = DftiSetValue(fft, DFTI_OUTPUT_DISTANCE, SO) )
      ERR(DftiErrorMessage(status));

    if ( status = DftiSetValue(fft, DFTI_INPUT_STRIDES, PS) )
      ERR(DftiErrorMessage(status));

    if ( status = DftiSetValue(fft, DFTI_OUTPUT_STRIDES, SS) )
      ERR(DftiErrorMessage(status));

    if ( status = DftiCommitDescriptor(fft) )
      ERR(DftiErrorMessage(status));

    // perform forward FFT
    if ( status = DftiComputeForward(fft,u,U) )
      ERR(DftiErrorMessage(status));[/cpp]&lt;/PRE&gt; &lt;BR /&gt;Settings for only backward fft:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[cpp] // specifically initialize for backward (spectral to physical) transform
    if ( status = DftiSetValue(fft, DFTI_INPUT_DISTANCE, SO) )
      ERR(DftiErrorMessage(status));

    if ( status = DftiSetValue(fft, DFTI_OUTPUT_DISTANCE, PO) )
      ERR(DftiErrorMessage(status));

    if ( status = DftiSetValue(fft, DFTI_INPUT_STRIDES, SS) )
      ERR(DftiErrorMessage(status));

    if ( status = DftiSetValue(fft, DFTI_OUTPUT_STRIDES, PS) )
      ERR(DftiErrorMessage(status));

    if ( status = DftiCommitDescriptor(fft) )
      ERR(DftiErrorMessage(status));

    // perform backward FFT
    if ( status = DftiComputeBackward(fft,U,u) )
      ERR(DftiErrorMessage(status));[/cpp]&lt;/PRE&gt;&lt;BR /&gt;The code I use to initialize, transform and then test the complex data is as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[cpp]  MKL_LONG ki;
  double maxerr;
  double complex *P, *expP;
  double *p;


  // allocate memory
  if ( !(P = (double complex*)malloc(SO*sizeof(double complex))) )
    ERR("Can't allocate memory!");
  if ( !(exP = (double complex*)malloc(SO*sizeof(double complex))) )
    ERR("Can't allocate memory!");
  if ( !(p = (double*)malloc(PO*sizeof(double))) )
    ERR("Can't allocate memory!");

  // initialize complex data
  for ( ki = 0; ki &amp;lt; SO; ki++ )
    P[ki] = some complex random number

  // inverse &amp;amp; forward fft  
  do backward FFT P -&amp;gt; p
  do forward FFT p -&amp;gt; exP

  // test error
  maxerr = 0.0;
  for ( ki = 0; ki &amp;lt; SO; ki++ )
  {
    if (fabs(creal(P[ki]-exP[ki])) &amp;gt; maxerr)
      maxerr = fabs(creal(P[ki]-exP[ki]));
    if (fabs(cimag(P[ki]-exP[ki])) &amp;gt; maxerr)
      maxerr = fabs(cimag(P[ki]-exP[ki]));
  }
  printf("maxerr = %g\n",maxerr);[/cpp]&lt;/PRE&gt;&lt;BR /&gt;&lt;B&gt;QUESTION:&lt;/B&gt; Are there any particular settings that need to be done as a setup to the FFT routines if one wants to apply backward fft first? What am I missing?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Jozsef</description>
      <pubDate>Wed, 22 Sep 2010 00:16:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/3D-FFT-examples-forward-gt-backward-works-backward-gt-forward/m-p/819598#M4610</guid>
      <dc:creator>Jozsef</dc:creator>
      <dc:date>2010-09-22T00:16:17Z</dc:date>
    </item>
    <item>
      <title>3D FFT examples: forward-&gt;backward works, backward-&gt;forward doe</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/3D-FFT-examples-forward-gt-backward-works-backward-gt-forward/m-p/819599#M4611</link>
      <description>Hi Jozsef,&lt;BR /&gt;&lt;BR /&gt;Probably, it is input data issue. Complex-to-real transform expects the input is conjugate-even [that isP(n1,n2,n3)==conj(P(N-n1,N-n2,N-n3)) ]. Ifthe input is not conjugate-even,the transform produces junk, because it doesn't attempt to 'symmetrize' the input.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Dima</description>
      <pubDate>Wed, 22 Sep 2010 07:36:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/3D-FFT-examples-forward-gt-backward-works-backward-gt-forward/m-p/819599#M4611</guid>
      <dc:creator>Dmitry_B_Intel</dc:creator>
      <dc:date>2010-09-22T07:36:05Z</dc:date>
    </item>
    <item>
      <title>3D FFT examples: forward-&gt;backward works, backward-&gt;forward doe</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/3D-FFT-examples-forward-gt-backward-works-backward-gt-forward/m-p/819600#M4612</link>
      <description>But I thought the conjugate-symmetric part is not stored. Is it?&lt;BR /&gt;J</description>
      <pubDate>Fri, 29 Oct 2010 17:21:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/3D-FFT-examples-forward-gt-backward-works-backward-gt-forward/m-p/819600#M4612</guid>
      <dc:creator>Jozsef</dc:creator>
      <dc:date>2010-10-29T17:21:58Z</dc:date>
    </item>
    <item>
      <title>3D FFT examples: forward-&gt;backward works, backward-&gt;forward doe</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/3D-FFT-examples-forward-gt-backward-works-backward-gt-forward/m-p/819601#M4613</link>
      <description>Most of it is not. However, some symmetry should be present (e.g. Im(Y(0,0,0)==0).&lt;BR /&gt;Dima</description>
      <pubDate>Sat, 30 Oct 2010 16:17:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/3D-FFT-examples-forward-gt-backward-works-backward-gt-forward/m-p/819601#M4613</guid>
      <dc:creator>Dmitry_B_Intel</dc:creator>
      <dc:date>2010-10-30T16:17:36Z</dc:date>
    </item>
  </channel>
</rss>

