<?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 strange values for the FFT of an odd function in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810331#M3839</link>
    <description>Hi vtorri,&lt;BR /&gt;&lt;BR /&gt;The function you take FFT of is not odd. An odd function must have x_in[0]==0.&lt;BR /&gt;Instead of x_in = [-1 + (0:31)*2/32] try [0, -1 + (0:30)*2/30].&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Dima</description>
    <pubDate>Sat, 09 Oct 2010 03:31:01 GMT</pubDate>
    <dc:creator>Dmitry_B_Intel</dc:creator>
    <dc:date>2010-10-09T03:31:01Z</dc:date>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810328#M3836</link>
      <description>I want to compute the Fourier coefficients of the 2-periodic function that is equal to x |---&amp;gt; x on [-1,1]. When I display them, they have the correct imaginary value, but a real value which is not equal to 0 (like it should be), but which is equal to -1.&lt;BR /&gt;&lt;BR /&gt;Here is the code:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[cpp]#include &lt;STDIO.H&gt;

#include &lt;MATHIMF.H&gt;
#include &lt;MKL_DFTI.H&gt;

float fct_der(float x)
{
  return x;
}


int main()
{
  float _Complex x_in[32];
  float _Complex x_out[32];
  DFTI_DESCRIPTOR_HANDLE my_desc1_handle;
  MKL_LONG status;
  int i;

  for (i = 0; i &amp;lt; 32; i++)
    {
      float x;

      x = -1.0f + (float)(2 * i) / 32.0f;
      x_in&lt;I&gt; = fct_der(x);
    }

  status = DftiCreateDescriptor( &amp;amp;my_desc1_handle, DFTI_SINGLE, DFTI_COMPLEX, 1, 32);
  status = DftiSetValue( my_desc1_handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
  status = DftiCommitDescriptor( my_desc1_handle );
  status = DftiComputeForward( my_desc1_handle, x_in, x_out);
  status = DftiFreeDescriptor(&amp;amp;my_desc1_handle);

  for (i = 0; i &amp;lt; 32; i++)
    {
      printf ("%f + i %f\n", creal(x_out&lt;I&gt;), cimag(x_out&lt;I&gt;));
    }

  return 0;
}[/cpp]&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/MKL_DFTI.H&gt;&lt;/MATHIMF.H&gt;&lt;/STDIO.H&gt;&lt;/PRE&gt; &lt;BR /&gt;And here is the output:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[plain]-1.000000 + i 0.000000
-1.000000 + i 10.153171
-1.000000 + i 5.027339
-1.000000 + i 3.296558
-1.000000 + i 2.414214
-1.000000 + i 1.870868
-1.000000 + i 1.496606
-1.000000 + i 1.218504
-1.000000 + i 1.000000
-1.000000 + i 0.820679
-1.000000 + i 0.668179
-1.000000 + i 0.534511
-1.000000 + i 0.414214
-1.000000 + i 0.303347
-1.000000 + i 0.198912
-1.000000 + i 0.098491
-1.000000 + i 0.000000
-1.000000 + i -0.098491
-1.000000 + i -0.198912
-1.000000 + i -0.303347
etc...[/plain]&lt;/PRE&gt; &lt;BR /&gt;Does someone see why the real part is not 0 ?&lt;BR /&gt;&lt;BR /&gt;thank you</description>
      <pubDate>Fri, 08 Oct 2010 15:13:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810328#M3836</guid>
      <dc:creator>vincent-torri</dc:creator>
      <dc:date>2010-10-08T15:13:44Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810329#M3837</link>
      <description>I'm trying to read your program and understand what you're trying to do. You mention a real function and in your program you initialize your variable of type float with real data, but then you assign it to your float _Complex data variable and perform a complex FFT.&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Is this intended? Is there a reason you don't just use a real data type for x_in and perform a real FFT?&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Todd&lt;/DIV&gt;</description>
      <pubDate>Fri, 08 Oct 2010 18:41:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810329#M3837</guid>
      <dc:creator>Todd_R_Intel</dc:creator>
      <dc:date>2010-10-08T18:41:20Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810330#M3838</link>
      <description>it is intended, indeed. It is the first time that i use the Intel compiler and the MKL. So I am doing tests. Especially tests that can theoretically be computed. It works for an even function (I tried x^2-1) and the imaginary part is 0. But not with that simple odd function.&lt;BR /&gt;&lt;BR /&gt;In the future, i will use the FFT on a complex valued function (more precisely, i want to solve a non linear Schrdinger equation). So I prefer getting familiar with the complex API.</description>
      <pubDate>Fri, 08 Oct 2010 21:20:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810330#M3838</guid>
      <dc:creator>vincent-torri</dc:creator>
      <dc:date>2010-10-08T21:20:47Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810331#M3839</link>
      <description>Hi vtorri,&lt;BR /&gt;&lt;BR /&gt;The function you take FFT of is not odd. An odd function must have x_in[0]==0.&lt;BR /&gt;Instead of x_in = [-1 + (0:31)*2/32] try [0, -1 + (0:30)*2/30].&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Dima</description>
      <pubDate>Sat, 09 Oct 2010 03:31:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810331#M3839</guid>
      <dc:creator>Dmitry_B_Intel</dc:creator>
      <dc:date>2010-10-09T03:31:01Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810332#M3840</link>
      <description>Of course the function that i took is odd. I discretized x |--&amp;gt; x on [-1,1] which is obviously odd. On the other hand, your remark raises a good point: must I "shift" the vector values, with something like:&lt;BR /&gt;&lt;BR /&gt;int shift = N/2 + 1;&lt;BR /&gt;int i;&lt;BR /&gt;for (i = 0; i &amp;lt; N; i++)&lt;BR /&gt; out2&lt;I&gt; = out[i+shift)%N];&lt;BR /&gt;&lt;BR /&gt;so that the discretized value of x=0 is the first value of my array ?&lt;BR /&gt;&lt;/I&gt;</description>
      <pubDate>Sat, 09 Oct 2010 15:42:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810332#M3840</guid>
      <dc:creator>vincent-torri</dc:creator>
      <dc:date>2010-10-09T15:42:35Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810333#M3841</link>
      <description>Right, the input x[0:N-1] to FFT is expecpected to bedirectly mapped frominterval[0,P] rather than from [-P/2,P/2], so that f(0) is the first value of the input array.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Dima&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Oct 2010 02:23:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810333#M3841</guid>
      <dc:creator>Dmitry_B_Intel</dc:creator>
      <dc:date>2010-10-11T02:23:44Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810334#M3842</link>
      <description>I shifted the values:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[bash]  for (i = 0; i &amp;lt; 32; i++)
    {
      float x;

      x = -1.0f + (float)(2 * i) / 32.0f;
      tmp&lt;I&gt; = fct_der(x);
    }

  shift = 32 / 2;
  for (i = 0; i &amp;lt; 32; i++)
    {
      x_in&lt;I&gt; = tmp[(i+shift)%32];
    }[/bash]&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;BR /&gt;but the result is still wrong (1st column : i, 2nd : x_in&lt;I&gt;, 3rd and 4th x_out&lt;I&gt;) :&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;&lt;/I&gt;&lt;PRE&gt;&lt;I&gt;&lt;I&gt;[bash]0 ** 0.000000 ** -1.000000 + i 0.000000
1 ** 0.062500 ** 1.000000 + i -10.153171
2 ** 0.125000 ** -1.000000 + i 5.027339
3 ** 0.187500 ** 1.000000 + i -3.296558
4 ** 0.250000 ** -1.000000 + i 2.414214
5 ** 0.312500 ** 1.000000 + i -1.870868
6 ** 0.375000 ** -1.000000 + i 1.496606
7 ** 0.437500 ** 1.000000 + i -1.218504
8 ** 0.500000 ** -1.000000 + i 1.000000
9 ** 0.562500 ** 1.000000 + i -0.820679
10 ** 0.625000 ** -1.000000 + i 0.668179
11 ** 0.687500 ** 1.000000 + i -0.534511
12 ** 0.750000 ** -1.000000 + i 0.414214
13 ** 0.812500 ** 1.000000 + i -0.303347
14 ** 0.875000 ** -1.000000 + i 0.198912
15 ** 0.937500 ** 1.000000 + i -0.098491
16 ** -1.000000 ** -1.000000 + i 0.000000
17 ** -0.937500 ** 1.000000 + i 0.098491
18 ** -0.875000 ** -1.000000 + i -0.198912
19 ** -0.812500 ** 1.000000 + i 0.303347
20 ** -0.750000 ** -1.000000 + i -0.414214
21 ** -0.687500 ** 1.000000 + i 0.534511
22 ** -0.625000 ** -1.000000 + i -0.668179
23 ** -0.562500 ** 1.000000 + i 0.820679
24 ** -0.500000 ** -1.000000 + i -1.000000
25 ** -0.437500 ** 1.000000 + i 1.218504
26 ** -0.375000 ** -1.000000 + i -1.496606
27 ** -0.312500 ** 1.000000 + i 1.870868
28 ** -0.250000 ** -1.000000 + i -2.414214
29 ** -0.187500 ** 1.000000 + i 3.296558
30 ** -0.125000 ** -1.000000 + i -5.027339
31 ** -0.062500 ** 1.000000 + i 10.153171
[/bash]&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;BR /&gt;Any idea ?</description>
      <pubDate>Mon, 11 Oct 2010 10:57:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810334#M3842</guid>
      <dc:creator>vincent-torri</dc:creator>
      <dc:date>2010-10-11T10:57:38Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810335#M3843</link>
      <description>Hi vtorri,&lt;BR /&gt;&lt;BR /&gt;To be odd, the discretization should obey the property:&lt;BR /&gt;x_in[0] = 0&lt;BR /&gt;x_in&lt;K&gt; = -x_in[N-k], k=1...N-1&lt;BR /&gt;In your case this property doesn't hold for k=16.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Dima&lt;/K&gt;</description>
      <pubDate>Mon, 11 Oct 2010 11:13:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810335#M3843</guid>
      <dc:creator>Dmitry_B_Intel</dc:creator>
      <dc:date>2010-10-11T11:13:59Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810336#M3844</link>
      <description>Ok. So the shift is not what should be done, actually. It's more a symetry. And it's certainly why it works without problem with en even function. I'll try that.</description>
      <pubDate>Mon, 11 Oct 2010 11:22:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810336#M3844</guid>
      <dc:creator>vincent-torri</dc:creator>
      <dc:date>2010-10-11T11:22:44Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810337#M3845</link>
      <description>it works well for an even function because the number of coefficients are even. The problem is the number of coefficient for an odd function if I have to satisfy : x_in[0]=0 and x_in&lt;I&gt;=x_in[N-i] i=1...N-1 (the number of coef is then odd)&lt;/I&gt;</description>
      <pubDate>Mon, 11 Oct 2010 11:52:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810337#M3845</guid>
      <dc:creator>vincent-torri</dc:creator>
      <dc:date>2010-10-11T11:52:53Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810338#M3846</link>
      <description>&lt;P&gt;Consider even N = 2L.&lt;BR /&gt;&lt;BR /&gt;For even function this should hold:&lt;BR /&gt;x_in[0] = any&lt;BR /&gt;x_in&lt;K&gt; = x_in[N-k]&lt;BR /&gt;In particular, x_in&lt;L&gt; = x_in&lt;L&gt; which means x_in&lt;L&gt; is arbitrary.&lt;BR /&gt;&lt;BR /&gt;For odd function this should hold:&lt;BR /&gt;x_in[0] = any&lt;BR /&gt;x_in&lt;K&gt; = -x_in[N-k]&lt;BR /&gt;In particular, x_in&lt;L&gt; = -x_in&lt;L&gt; which means x_in&lt;L&gt; must be zero.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Dima&lt;/L&gt;&lt;/L&gt;&lt;/L&gt;&lt;/K&gt;&lt;/L&gt;&lt;/L&gt;&lt;/L&gt;&lt;/K&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2010 12:17:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810338#M3846</guid>
      <dc:creator>Dmitry_B_Intel</dc:creator>
      <dc:date>2010-10-11T12:17:05Z</dc:date>
    </item>
    <item>
      <title>strange values for the FFT of an odd function</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810339#M3847</link>
      <description>I have found my error. The way I discretized x |----&amp;gt; x is wrong.The value ax x=-1 should be 0 and not -1. Thank you for your answers !</description>
      <pubDate>Mon, 11 Oct 2010 21:52:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/strange-values-for-the-FFT-of-an-odd-function/m-p/810339#M3847</guid>
      <dc:creator>vincent-torri</dc:creator>
      <dc:date>2010-10-11T21:52:09Z</dc:date>
    </item>
  </channel>
</rss>

