<?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 Why it is left to user to divide each element of an array by total number of points after computing backward FFT? in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-it-is-left-to-user-to-divide-each-element-of-an-array-by/m-p/858698#M7308</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Recently I 'discovered' that just after computing "DftiComputeForward(Desc_Handle, x_in)" and "DftiComputeBackward(Desc_Handle, x_in)" the array x_in is not equal to the initial: The user must divide each x_in element by total number of points in order to achieve equality.&lt;/P&gt;
&lt;P&gt;Q1: why it is left to user to do that? note, that the user might not do that in the most efficient way thus reducing overall performance.&lt;/P&gt;
&lt;P&gt;Q2: does user need to do something similar after computing only "DftiComputeForward(Desc_Handle, x_in)"?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Program code (VS2008 C++ Win32 MKL 10.0.5.025):&lt;BR /&gt;// 96.cpp : Defines the entry point for the console application.&lt;BR /&gt;//&lt;/P&gt;
&lt;P&gt;#include "stdafx.h"&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include "mkl_dfti.h"&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;MATH.H&gt;&lt;/MATH.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;int _tmain(int argc, _TCHAR* argv[])&lt;BR /&gt;{&lt;BR /&gt;printf("Hello World \n");&lt;/P&gt;
&lt;P&gt;DFTI_DESCRIPTOR_HANDLE Desc_Handle = 0;&lt;BR /&gt;int Status, i1, i2, i3, m, i;&lt;BR /&gt;double d1, d2, d3, d4;&lt;BR /&gt;char *c;&lt;BR /&gt;double *x_in;&lt;/P&gt;
&lt;P&gt;m = 128;&lt;BR /&gt;i1 = 1;&lt;/P&gt;
&lt;P&gt;c = new char;&lt;BR /&gt;x_in = new double[2 * m];&lt;BR /&gt;i2 = 0;&lt;BR /&gt;i3 = m / 2;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //Fills x_in array with gaussian pulse&lt;BR /&gt;d1 = 3.1622776601683795 * exp(-(i - i3) * (i - i3) * 0.013862943611198901);&lt;BR /&gt;x_in[i2] = d1;&lt;BR /&gt;x_in[i2 + 1] = 0.0;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;i2 = 0;&lt;BR /&gt;d4 = 0;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //searching for the peak value&lt;BR /&gt;d1 = x_in[i2];&lt;BR /&gt;d2 = x_in[i2 + 1];&lt;BR /&gt;d3 = d1 * d1 + d2 * d2;&lt;BR /&gt;if (d3 &amp;gt; d4) d4 = d3;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;printf("%f \n", d4);&lt;BR /&gt;Status = DftiCreateDescriptor(&amp;amp;Desc_Handle, DFTI_DOUBLE, DFTI_COMPLEX, i1, m);&lt;BR /&gt;printf("DftiCreateDescriptor error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;Status = DftiCommitDescriptor( Desc_Handle );&lt;BR /&gt;printf("DftiCommitDescriptor error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;Status = DftiComputeForward(Desc_Handle, x_in);&lt;BR /&gt;printf("DftiComputeForward error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;Status = DftiComputeBackward(Desc_Handle, x_in);&lt;BR /&gt;printf("DftiComputeBackward error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;DftiFreeDescriptor(&amp;amp;Desc_Handle);&lt;BR /&gt;printf("DftiFreeDescriptor error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;i2 = 0;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //dividing by number of points&lt;BR /&gt;x_in[i2] /= m;&lt;BR /&gt;x_in[i2+1] /= m;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;i2 = 0;&lt;BR /&gt;d4 = 0;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //searching for the peak value&lt;BR /&gt;d1 = x_in[i2];&lt;BR /&gt;d2 = x_in[i2 + 1];&lt;BR /&gt;d3 = d1 * d1 + d2 * d2;&lt;BR /&gt;if (d3 &amp;gt; d4) d4 = d3;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;printf("%f \n", d4);&lt;BR /&gt;c = new char;&lt;BR /&gt;scanf(c);&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Audrius&lt;/P&gt;</description>
    <pubDate>Mon, 27 Oct 2008 18:11:01 GMT</pubDate>
    <dc:creator>audrius</dc:creator>
    <dc:date>2008-10-27T18:11:01Z</dc:date>
    <item>
      <title>Why it is left to user to divide each element of an array by total number of points after computing backward FFT?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-it-is-left-to-user-to-divide-each-element-of-an-array-by/m-p/858698#M7308</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Recently I 'discovered' that just after computing "DftiComputeForward(Desc_Handle, x_in)" and "DftiComputeBackward(Desc_Handle, x_in)" the array x_in is not equal to the initial: The user must divide each x_in element by total number of points in order to achieve equality.&lt;/P&gt;
&lt;P&gt;Q1: why it is left to user to do that? note, that the user might not do that in the most efficient way thus reducing overall performance.&lt;/P&gt;
&lt;P&gt;Q2: does user need to do something similar after computing only "DftiComputeForward(Desc_Handle, x_in)"?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Program code (VS2008 C++ Win32 MKL 10.0.5.025):&lt;BR /&gt;// 96.cpp : Defines the entry point for the console application.&lt;BR /&gt;//&lt;/P&gt;
&lt;P&gt;#include "stdafx.h"&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include "mkl_dfti.h"&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;MATH.H&gt;&lt;/MATH.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;int _tmain(int argc, _TCHAR* argv[])&lt;BR /&gt;{&lt;BR /&gt;printf("Hello World \n");&lt;/P&gt;
&lt;P&gt;DFTI_DESCRIPTOR_HANDLE Desc_Handle = 0;&lt;BR /&gt;int Status, i1, i2, i3, m, i;&lt;BR /&gt;double d1, d2, d3, d4;&lt;BR /&gt;char *c;&lt;BR /&gt;double *x_in;&lt;/P&gt;
&lt;P&gt;m = 128;&lt;BR /&gt;i1 = 1;&lt;/P&gt;
&lt;P&gt;c = new char;&lt;BR /&gt;x_in = new double[2 * m];&lt;BR /&gt;i2 = 0;&lt;BR /&gt;i3 = m / 2;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //Fills x_in array with gaussian pulse&lt;BR /&gt;d1 = 3.1622776601683795 * exp(-(i - i3) * (i - i3) * 0.013862943611198901);&lt;BR /&gt;x_in[i2] = d1;&lt;BR /&gt;x_in[i2 + 1] = 0.0;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;i2 = 0;&lt;BR /&gt;d4 = 0;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //searching for the peak value&lt;BR /&gt;d1 = x_in[i2];&lt;BR /&gt;d2 = x_in[i2 + 1];&lt;BR /&gt;d3 = d1 * d1 + d2 * d2;&lt;BR /&gt;if (d3 &amp;gt; d4) d4 = d3;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;printf("%f \n", d4);&lt;BR /&gt;Status = DftiCreateDescriptor(&amp;amp;Desc_Handle, DFTI_DOUBLE, DFTI_COMPLEX, i1, m);&lt;BR /&gt;printf("DftiCreateDescriptor error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;Status = DftiCommitDescriptor( Desc_Handle );&lt;BR /&gt;printf("DftiCommitDescriptor error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;Status = DftiComputeForward(Desc_Handle, x_in);&lt;BR /&gt;printf("DftiComputeForward error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;Status = DftiComputeBackward(Desc_Handle, x_in);&lt;BR /&gt;printf("DftiComputeBackward error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;DftiFreeDescriptor(&amp;amp;Desc_Handle);&lt;BR /&gt;printf("DftiFreeDescriptor error_message = %s \n", DftiErrorMessage(Status));&lt;BR /&gt;i2 = 0;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //dividing by number of points&lt;BR /&gt;x_in[i2] /= m;&lt;BR /&gt;x_in[i2+1] /= m;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;i2 = 0;&lt;BR /&gt;d4 = 0;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //searching for the peak value&lt;BR /&gt;d1 = x_in[i2];&lt;BR /&gt;d2 = x_in[i2 + 1];&lt;BR /&gt;d3 = d1 * d1 + d2 * d2;&lt;BR /&gt;if (d3 &amp;gt; d4) d4 = d3;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;printf("%f \n", d4);&lt;BR /&gt;c = new char;&lt;BR /&gt;scanf(c);&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Audrius&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2008 18:11:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-it-is-left-to-user-to-divide-each-element-of-an-array-by/m-p/858698#M7308</guid>
      <dc:creator>audrius</dc:creator>
      <dc:date>2008-10-27T18:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Why it is left to user to divide each element of an array b</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-it-is-left-to-user-to-divide-each-element-of-an-array-by/m-p/858699#M7309</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/404779"&gt;audrius&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Recently I 'discovered' that just after computing "DftiComputeForward(Desc_Handle, x_in)" and "DftiComputeBackward(Desc_Handle, x_in)" the array x_in is not equal to the initial: The user must divide each x_in element by total number of points in order to achieve equality.&lt;/P&gt;
&lt;P&gt;Q1: why it is left to user to do that? note, that the user might not do that in the most efficient way thus reducing overall performance.&lt;/P&gt;
&lt;P&gt;Q2: does user need to do something similar after computing only "DftiComputeForward(Desc_Handle, x_in)"?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Program code (VS2008 C++ Win32 MKL 10.0.5.025):&lt;BR /&gt;// 96.cpp : Defines the entry point for the console application.&lt;BR /&gt;//&lt;/P&gt;
&lt;P&gt;#include "stdafx.h"&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include "mkl_dfti.h"&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;MATH.H&gt;&lt;/MATH.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;int _tmain(int argc, _TCHAR* argv[])&lt;BR /&gt;{&lt;BR /&gt;printf("Hello World n");&lt;/P&gt;
&lt;P&gt;DFTI_DESCRIPTOR_HANDLE Desc_Handle = 0;&lt;BR /&gt;int Status, i1, i2, i3, m, i;&lt;BR /&gt;double d1, d2, d3, d4;&lt;BR /&gt;char *c;&lt;BR /&gt;double *x_in;&lt;/P&gt;
&lt;P&gt;m = 128;&lt;BR /&gt;i1 = 1;&lt;/P&gt;
&lt;P&gt;c = new char;&lt;BR /&gt;x_in = new double[2 * m];&lt;BR /&gt;i2 = 0;&lt;BR /&gt;i3 = m / 2;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //Fills x_in array with gaussian pulse&lt;BR /&gt;d1 = 3.1622776601683795 * exp(-(i - i3) * (i - i3) * 0.013862943611198901);&lt;BR /&gt;x_in[i2] = d1;&lt;BR /&gt;x_in[i2 + 1] = 0.0;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;i2 = 0;&lt;BR /&gt;d4 = 0;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //searching for the peak value&lt;BR /&gt;d1 = x_in[i2];&lt;BR /&gt;d2 = x_in[i2 + 1];&lt;BR /&gt;d3 = d1 * d1 + d2 * d2;&lt;BR /&gt;if (d3 &amp;gt; d4) d4 = d3;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;printf("%f n", d4);&lt;BR /&gt;Status = DftiCreateDescriptor(&amp;amp;Desc_Handle, DFTI_DOUBLE, DFTI_COMPLEX, i1, m);&lt;BR /&gt;printf("DftiCreateDescriptor error_message = %s n", DftiErrorMessage(Status));&lt;BR /&gt;Status = DftiCommitDescriptor( Desc_Handle );&lt;BR /&gt;printf("DftiCommitDescriptor error_message = %s n", DftiErrorMessage(Status));&lt;BR /&gt;Status = DftiComputeForward(Desc_Handle, x_in);&lt;BR /&gt;printf("DftiComputeForward error_message = %s n", DftiErrorMessage(Status));&lt;BR /&gt;Status = DftiComputeBackward(Desc_Handle, x_in);&lt;BR /&gt;printf("DftiComputeBackward error_message = %s n", DftiErrorMessage(Status));&lt;BR /&gt;DftiFreeDescriptor(&amp;amp;Desc_Handle);&lt;BR /&gt;printf("DftiFreeDescriptor error_message = %s n", DftiErrorMessage(Status));&lt;BR /&gt;i2 = 0;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //dividing by number of points&lt;BR /&gt;x_in[i2] /= m;&lt;BR /&gt;x_in[i2+1] /= m;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;i2 = 0;&lt;BR /&gt;d4 = 0;&lt;BR /&gt;for (i = 0; i &amp;lt; m; i++) { //searching for the peak value&lt;BR /&gt;d1 = x_in[i2];&lt;BR /&gt;d2 = x_in[i2 + 1];&lt;BR /&gt;d3 = d1 * d1 + d2 * d2;&lt;BR /&gt;if (d3 &amp;gt; d4) d4 = d3;&lt;BR /&gt;i2 += 2;&lt;BR /&gt;}&lt;BR /&gt;printf("%f n", d4);&lt;BR /&gt;c = new char;&lt;BR /&gt;scanf(c);&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Audrius&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Audrius,&lt;/P&gt;
&lt;P&gt;In order to achieve the behaviour described in Q1 you need to set the DFTI_BACKWARD_SCALE parameter before committing the descriptor like this:&lt;/P&gt;
&lt;P&gt;Status = DftiSetValue(Desc_Handle, DFTI_BACKWARD_SCALE, 1.0/(double)m);&lt;/P&gt;
&lt;P&gt;Please note also that the DFTI interface uses MKL_LONG as the type of the return values as well as the integer parameters (most important when you pass integer arrays to DFTI).&lt;/P&gt;
&lt;P&gt;Regarding Q2, could you be more specific as to what is "something similar"?&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;-Vladimir&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2008 05:27:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Why-it-is-left-to-user-to-divide-each-element-of-an-array-by/m-p/858699#M7309</guid>
      <dc:creator>Vladimir_Petrov__Int</dc:creator>
      <dc:date>2008-10-28T05:27:09Z</dc:date>
    </item>
  </channel>
</rss>

