<?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 MKL Cookbook Example 1 -- a Critique in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053223#M21272</link>
    <description>&lt;P&gt;The MKL Cookbook at&amp;nbsp;https://software.intel.com/en-us/mkl_cookbook has a set of interesting and useful examples of solving physics problems using MKL. After reading the first of the cookbook examples, which is nicely described at &lt;A href="https://software.intel.com/en-us/node/507039,&amp;nbsp;and" target="_blank"&gt;https://software.intel.com/en-us/node/507039,&amp;nbsp;and&lt;/A&gt; trying to verify the results given by the cookbook code at&amp;nbsp;https://software.intel.com/en-us/mkl_cookbook_samples, I have some critical comments. I hope someone will view these comments as constructive criticism.&lt;/P&gt;&lt;P&gt;1. The brief description given at&amp;nbsp;https://software.intel.com/en-us/mkl_cookbook says "Finding an approximate solution to a nonlinear equation", which would suggest to most people that the example concerns solving a nonlinear equation in one variable. The example, in fact, is about solving a nonlinear PDE using finite-difference discretization, and solving the resulting system of nonlinear algebraic equations using Pardiso.&lt;/P&gt;&lt;P&gt;2. The nonlinearity is introduced through the temperature dependence of thermal conductivity, as described on&amp;nbsp;https://software.intel.com/en-us/node/507039 under "Discussion" (two different but similar symbols are used for temperature -- v and the Greek letter 'nu' -- please fix this). To treat this nonlinearity, the discretized equations are solved iteratively, using the solution of each iteration to recompute the coefficients to be used in the next iteration. In principle, this is fine, and there are many applications where such iterations are necessary. However, in the specific problem chosen this iteration is unnecessary. Gustav Kirchhoff showed in 1894 that using w = \int \mu dv as the dependent variable reduces the variable conductivity problem to an equivalent constant conductivity problem.&lt;/P&gt;&lt;P&gt;3. I added 'printf' statements to the code in file&amp;nbsp;pardiso_nonlinear.c to print out the final solution for temperature. The solution is not only incorrect in the interior of the unit cube domain, but shows values of 1 at the faces of the cube instead of the specified value of 0. I have not debugged the 300-line code to find out what is wrong. Instead, I give below two different ways of solving the problem and the results, so that you (Intel/MKL group) can debug the C code in the cookbook.&lt;/P&gt;&lt;P&gt;4. The example code employs a mesh with 6&lt;SUP&gt;3&lt;/SUP&gt; nodes, of which 4&lt;SUP&gt;3&lt;/SUP&gt; are interior nodes with unknown values of the dependent variable, and solves for these unknowns by calling Pardiso with n = 216. Exploiting the symmetry of the problem enables us to recognize that there are only four distinct temperature values! Let us name these four values as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; x &amp;nbsp; &amp;nbsp; y &amp;nbsp; &amp;nbsp; z &amp;nbsp; &amp;nbsp; w&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;0.2 &amp;nbsp;0.2 &amp;nbsp;0.2 &amp;nbsp; &amp;nbsp; p&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;0.2 &amp;nbsp;0.4 &amp;nbsp;0.2 &amp;nbsp; &amp;nbsp; q&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;0.4 &amp;nbsp;0.4 &amp;nbsp;0.2 &amp;nbsp; &amp;nbsp; r&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;0.4 &amp;nbsp;0.4 &amp;nbsp;0.4 &amp;nbsp; &amp;nbsp; s&lt;/P&gt;&lt;P&gt;Then, the heat equation is represented by A w = b, where A =&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp;-3 &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; -1 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;-2 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp;-2 &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp;-1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp;-3 &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;and b = h&lt;SUP&gt;2&lt;/SUP&gt;, with h = 0.2 being the mesh size, and w = [p q r s]&lt;SUP&gt;T&lt;/SUP&gt;. The solution is w = [&amp;nbsp; &amp;nbsp;0.0196 ,&amp;nbsp; &amp;nbsp;0.0260,&amp;nbsp; &amp;nbsp; 0.0351,&amp;nbsp;&amp;nbsp; &amp;nbsp; 0.0484]&lt;SUP&gt;T&lt;/SUP&gt;. By reversing the Kirchhoff transformation, we recover the solution for temperature as T =&amp;nbsp;&amp;nbsp; [ &amp;nbsp;0.0180,&amp;nbsp; &amp;nbsp; 0.0233,&amp;nbsp; &amp;nbsp; 0.0305,&amp;nbsp; &amp;nbsp; 0.0403]&lt;SUP&gt;T&lt;/SUP&gt;.&lt;/P&gt;&lt;P&gt;5. Here is simple Fortran code to solve the problem using Gauss-Seidel iteration to solve the linear equations for w (denoted T in the code). To keep the code short, I have not exploited symmetry, using which would have reduced the number of variables. The output values agree with those given above in Item 4.&lt;/P&gt;&lt;P&gt;! Poisson equation in unit cube, with T = zero at faces. program lapl3d implicit none integer, parameter :: nx=5, ny=5, nz=5 ! number of segments real, dimension (0:nx,0:ny,0:nz) :: T = 0.0 ! Kirchhoff flow temperature real :: h=1.0/nx, dT, Tn integer :: i,j,k,iter=0 do dT=0 do i=1,nx-1 do j=1,ny-1 do k=1,nz-1 Tn = (T(i-1,j,k)+T(i+1,j,k)+ &amp;amp; T(i,j-1,k)+T(i,j+1,k)+ &amp;amp; T(i,j,k-1)+T(i,j,k+1) + h*h)/6.0 ! discrete Poisson eq. dT = max(dT,abs(T(i,j,k)-Tn)) T(i,j,k) = Tn ! Gauss-Seidel end do end do end do iter=iter+1 if(mod(iter,10).eq.0)write(*,'(1x,I4,2x,E10.3)')iter,dT if(iter.gt.500.or.dT.lt.1e-8)exit end do ! recover temperatures from Kirchhoff flow temperatures do i=1,nx-1 do j=1,ny-1 write(*,10)i,j,(sqrt(0.2*T(i,j,k)+0.01)-0.1,k=1,nz-1) end do end do 10 format(1x,2I3,&amp;lt;nx-1&amp;gt;F10.5) end program&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 May 2015 01:26:31 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2015-05-05T01:26:31Z</dc:date>
    <item>
      <title>MKL Cookbook Example 1 -- a Critique</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053223#M21272</link>
      <description>&lt;P&gt;The MKL Cookbook at&amp;nbsp;https://software.intel.com/en-us/mkl_cookbook has a set of interesting and useful examples of solving physics problems using MKL. After reading the first of the cookbook examples, which is nicely described at &lt;A href="https://software.intel.com/en-us/node/507039,&amp;nbsp;and" target="_blank"&gt;https://software.intel.com/en-us/node/507039,&amp;nbsp;and&lt;/A&gt; trying to verify the results given by the cookbook code at&amp;nbsp;https://software.intel.com/en-us/mkl_cookbook_samples, I have some critical comments. I hope someone will view these comments as constructive criticism.&lt;/P&gt;&lt;P&gt;1. The brief description given at&amp;nbsp;https://software.intel.com/en-us/mkl_cookbook says "Finding an approximate solution to a nonlinear equation", which would suggest to most people that the example concerns solving a nonlinear equation in one variable. The example, in fact, is about solving a nonlinear PDE using finite-difference discretization, and solving the resulting system of nonlinear algebraic equations using Pardiso.&lt;/P&gt;&lt;P&gt;2. The nonlinearity is introduced through the temperature dependence of thermal conductivity, as described on&amp;nbsp;https://software.intel.com/en-us/node/507039 under "Discussion" (two different but similar symbols are used for temperature -- v and the Greek letter 'nu' -- please fix this). To treat this nonlinearity, the discretized equations are solved iteratively, using the solution of each iteration to recompute the coefficients to be used in the next iteration. In principle, this is fine, and there are many applications where such iterations are necessary. However, in the specific problem chosen this iteration is unnecessary. Gustav Kirchhoff showed in 1894 that using w = \int \mu dv as the dependent variable reduces the variable conductivity problem to an equivalent constant conductivity problem.&lt;/P&gt;&lt;P&gt;3. I added 'printf' statements to the code in file&amp;nbsp;pardiso_nonlinear.c to print out the final solution for temperature. The solution is not only incorrect in the interior of the unit cube domain, but shows values of 1 at the faces of the cube instead of the specified value of 0. I have not debugged the 300-line code to find out what is wrong. Instead, I give below two different ways of solving the problem and the results, so that you (Intel/MKL group) can debug the C code in the cookbook.&lt;/P&gt;&lt;P&gt;4. The example code employs a mesh with 6&lt;SUP&gt;3&lt;/SUP&gt; nodes, of which 4&lt;SUP&gt;3&lt;/SUP&gt; are interior nodes with unknown values of the dependent variable, and solves for these unknowns by calling Pardiso with n = 216. Exploiting the symmetry of the problem enables us to recognize that there are only four distinct temperature values! Let us name these four values as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; x &amp;nbsp; &amp;nbsp; y &amp;nbsp; &amp;nbsp; z &amp;nbsp; &amp;nbsp; w&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;0.2 &amp;nbsp;0.2 &amp;nbsp;0.2 &amp;nbsp; &amp;nbsp; p&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;0.2 &amp;nbsp;0.4 &amp;nbsp;0.2 &amp;nbsp; &amp;nbsp; q&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;0.4 &amp;nbsp;0.4 &amp;nbsp;0.2 &amp;nbsp; &amp;nbsp; r&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;0.4 &amp;nbsp;0.4 &amp;nbsp;0.4 &amp;nbsp; &amp;nbsp; s&lt;/P&gt;&lt;P&gt;Then, the heat equation is represented by A w = b, where A =&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp;-3 &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; -1 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;-2 &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp;-2 &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp;-1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp;-3 &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;and b = h&lt;SUP&gt;2&lt;/SUP&gt;, with h = 0.2 being the mesh size, and w = [p q r s]&lt;SUP&gt;T&lt;/SUP&gt;. The solution is w = [&amp;nbsp; &amp;nbsp;0.0196 ,&amp;nbsp; &amp;nbsp;0.0260,&amp;nbsp; &amp;nbsp; 0.0351,&amp;nbsp;&amp;nbsp; &amp;nbsp; 0.0484]&lt;SUP&gt;T&lt;/SUP&gt;. By reversing the Kirchhoff transformation, we recover the solution for temperature as T =&amp;nbsp;&amp;nbsp; [ &amp;nbsp;0.0180,&amp;nbsp; &amp;nbsp; 0.0233,&amp;nbsp; &amp;nbsp; 0.0305,&amp;nbsp; &amp;nbsp; 0.0403]&lt;SUP&gt;T&lt;/SUP&gt;.&lt;/P&gt;&lt;P&gt;5. Here is simple Fortran code to solve the problem using Gauss-Seidel iteration to solve the linear equations for w (denoted T in the code). To keep the code short, I have not exploited symmetry, using which would have reduced the number of variables. The output values agree with those given above in Item 4.&lt;/P&gt;&lt;P&gt;! Poisson equation in unit cube, with T = zero at faces. program lapl3d implicit none integer, parameter :: nx=5, ny=5, nz=5 ! number of segments real, dimension (0:nx,0:ny,0:nz) :: T = 0.0 ! Kirchhoff flow temperature real :: h=1.0/nx, dT, Tn integer :: i,j,k,iter=0 do dT=0 do i=1,nx-1 do j=1,ny-1 do k=1,nz-1 Tn = (T(i-1,j,k)+T(i+1,j,k)+ &amp;amp; T(i,j-1,k)+T(i,j+1,k)+ &amp;amp; T(i,j,k-1)+T(i,j,k+1) + h*h)/6.0 ! discrete Poisson eq. dT = max(dT,abs(T(i,j,k)-Tn)) T(i,j,k) = Tn ! Gauss-Seidel end do end do end do iter=iter+1 if(mod(iter,10).eq.0)write(*,'(1x,I4,2x,E10.3)')iter,dT if(iter.gt.500.or.dT.lt.1e-8)exit end do ! recover temperatures from Kirchhoff flow temperatures do i=1,nx-1 do j=1,ny-1 write(*,10)i,j,(sqrt(0.2*T(i,j,k)+0.01)-0.1,k=1,nz-1) end do end do 10 format(1x,2I3,&amp;lt;nx-1&amp;gt;F10.5) end program&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2015 01:26:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053223#M21272</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2015-05-05T01:26:31Z</dc:date>
    </item>
    <item>
      <title>Historical point: Kirchoff</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053224#M21273</link>
      <description>&lt;P&gt;Historical point: Kirchhoff died in 1887 (see &lt;A href="http://commons.wikimedia.org/wiki/File:Grabstein.Gustav.Kirchhoff.jpg)&amp;nbsp;" target="_blank"&gt;http://commons.wikimedia.org/wiki/File:Grabstein.Gustav.Kirchhoff.jpg)&amp;nbsp;&lt;/A&gt;. The date reference in Item 2 is to his posthumously published lecture notes.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2015 01:33:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053224#M21273</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2015-05-05T01:33:00Z</dc:date>
    </item>
    <item>
      <title>Hi Mecej4, </title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053225#M21274</link>
      <description>&lt;P&gt;Hi Mecej4,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thank you much for the review of the cookbook and &lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;constructive comments. &amp;nbsp;I will escalate them to the corresponding authors to further check. &lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Ying H.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Intel MKL Support &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2015 02:01:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053225#M21274</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2015-05-05T02:01:27Z</dc:date>
    </item>
    <item>
      <title>Intel, please respond!</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053226#M21275</link>
      <description>&lt;P&gt;Intel, please respond!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2015 13:55:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053226#M21275</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2015-06-02T13:55:44Z</dc:date>
    </item>
    <item>
      <title>Hi Mecej4,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053227#M21276</link>
      <description>&lt;P&gt;Hi Mecej4,&lt;/P&gt;

&lt;P&gt;Sorry for the delay. we are still investigating the problem internally. Some one in our team will cover it in next few days.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;Ying&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 01:38:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053227#M21276</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2015-06-04T01:38:20Z</dc:date>
    </item>
    <item>
      <title>Ying,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053228#M21277</link>
      <description>&lt;P&gt;Ying,&lt;/P&gt;

&lt;P&gt;Thanks, I'll wait. Since nearly a month had passed since I made the posting, I wrote a line as a reminder.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 02:51:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053228#M21277</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2015-06-04T02:51:00Z</dc:date>
    </item>
    <item>
      <title>Hello mecej4,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053229#M21278</link>
      <description>&lt;P&gt;Hello mecej4,&lt;BR /&gt;
	&lt;BR /&gt;
	Firstly I wand to thank you for all of your comments and&amp;nbsp;apologize for the delay in answering.&lt;/P&gt;

&lt;P&gt;I&amp;nbsp;took into account&amp;nbsp;your remarks and suppose that the result requires further consideration. I would like to take time to carefully investigate this problem.&lt;BR /&gt;
	&lt;BR /&gt;
	Best regards,&lt;BR /&gt;
	Maria.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2015 04:09:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053229#M21278</guid>
      <dc:creator>MariaZh</dc:creator>
      <dc:date>2015-07-09T04:09:34Z</dc:date>
    </item>
    <item>
      <title>Hi, mecej4--</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053230#M21279</link>
      <description>&lt;P&gt;Hi, mecej4--&lt;/P&gt;

&lt;P&gt;We posted an updated version of the recipe here:&amp;nbsp;&lt;A href="https://software.intel.com/en-us/node/507039"&gt;https://software.intel.com/en-us/node/507039&lt;/A&gt;, and updated sample code here:&amp;nbsp;&lt;A href="https://software.intel.com/en-us/mkl_cookbook_samples"&gt;https://software.intel.com/en-us/mkl_cookbook_samples&lt;/A&gt;. I hope this fixes the issues that you mentioned.&lt;/P&gt;

&lt;P&gt;Thank you so much for your valuable and constructive feedback.&lt;/P&gt;

&lt;P&gt;--Jeanette&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2015 21:26:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Cookbook-Example-1-a-Critique/m-p/1053230#M21279</guid>
      <dc:creator>Jeanette_F_Intel</dc:creator>
      <dc:date>2015-09-17T21:26:14Z</dc:date>
    </item>
  </channel>
</rss>

