<?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 Re: FGMRES + Diagonal preconditioner.  Is this correct? in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FGMRES-Diagonal-preconditioner-Is-this-correct/m-p/864592#M7764</link>
    <description>Sergey-&lt;BR /&gt;&lt;BR /&gt;Thanks for the info! &lt;BR /&gt;&lt;BR /&gt;The problem was indeed in a different portion of the code. Just was trying to rule out improper pre-conditioning. All is working fine now.&lt;BR /&gt;&lt;BR /&gt;-Mark&lt;BR /&gt;</description>
    <pubDate>Mon, 07 Jul 2008 13:54:04 GMT</pubDate>
    <dc:creator>mdobossy</dc:creator>
    <dc:date>2008-07-07T13:54:04Z</dc:date>
    <item>
      <title>FGMRES + Diagonal preconditioner.  Is this correct?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FGMRES-Diagonal-preconditioner-Is-this-correct/m-p/864590#M7762</link>
      <description>I am trying to put together a FGMRES iterative sparse solver routine, that uses a diagonal preconditioner (the code is being written in c). I am having some trouble with the convergence of the solution, and want to rule out a problem in how I am applying the preconditioner. Most of the code is from the FGMRES with ILU preconditioner examples, with a few small modifications.&lt;BR /&gt;&lt;BR /&gt;My sparse matrix is in a compressed row format with a column index array (&lt;FONT face="Courier New"&gt;_col_ind&lt;/FONT&gt;), row pointer array (&lt;FONT face="Courier New"&gt;_row_ptr&lt;/FONT&gt;), and values (&lt;FONT face="Courier New"&gt;_data&lt;/FONT&gt;) as shown in the MKL documentation. The indices in _col_ind and _row_ptr are in fortran format, so they start with 1. These arrays are STL::vector containers (thus my referencing the memory address of the first element of interest). &lt;FONT face="Courier New"&gt;ivar&lt;/FONT&gt; is the number of rows.&lt;BR /&gt;&lt;BR /&gt;Does this code look like the correct way to apply a diaganal preconditioner during the FGMRES solve with a diagonal preconditioner using the &lt;FONT face="Courier New"&gt;mkl_dcsrsv&lt;/FONT&gt; function? I have bolded the application of the preconditioner and initial guess, but included the entire iterative solve method I'm attempting for reference (again, most of the code here is directly from the FGMRES solver examples, so much of it should be correct). Obviously portions of this code need to be cleaned up, but please bear with me as this is a first attempt at getting the solver to work.&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="Courier New" size="2"&gt;vector&lt;DOUBLE&gt; SPMat::iterativeSolve(vector&lt;DOUBLE&gt; &amp;amp;RHS) {&lt;BR /&gt; if(_format!=CRS) //Checks to see if the SPMat has been formatted as a CRS yet&lt;BR /&gt;  toCRS();&lt;BR /&gt; solveError=false;&lt;BR /&gt; status statusCode=CONTINUE;&lt;BR /&gt; vector&lt;DOUBLE&gt; solution(_rows);&lt;BR /&gt; MKL_INT ipar[128];&lt;BR /&gt; double dpar[128], *tmp=new double [_rows*(2*_rows+1)+(_rows*(_rows+9))/2+1];&lt;BR /&gt; double *trvec = new double[_rows];&lt;BR /&gt; double *b = new double[_rows];&lt;BR /&gt; double *residual = new double[_rows];&lt;BR /&gt; &lt;BR /&gt; MKL_INT itercount,ierr=0;&lt;BR /&gt; MKL_INT RCI_request, i, ivar;&lt;BR /&gt; double dvar;&lt;BR /&gt; ivar=_rows;&lt;BR /&gt; double alpha=1.0;&lt;BR /&gt; i=1;&lt;BR /&gt; dcopy(&amp;amp;ivar, &amp;amp;RHS[0], &amp;amp;i, b, &amp;amp;i);&lt;BR /&gt; &lt;BR /&gt; /*---------------------------------------------------------------------------&lt;BR /&gt;&lt;/DOUBLE&gt;&lt;/DOUBLE&gt;&lt;/DOUBLE&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;/* Make an initial guess- inverse of the diagonal * RHS.&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;/*---------------------------------------------------------------------------*/&lt;BR /&gt; &lt;B&gt;mkl_dcsrsv("N", &amp;amp;ivar, α, "DLNF ", &amp;amp;_data[0], &amp;amp;_col_ind[0], &amp;amp;_row_ptr[0], &amp;amp;_row_ptr[1], b, &amp;amp;solution.front());&lt;/B&gt;&lt;BR /&gt; &lt;BR /&gt; /*---------------------------------------------------------------------------&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;/* Initi
alize the solver &lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;/*---------------------------------------------------------------------------*/&lt;BR /&gt; dfgmres_init(&amp;amp;ivar, &amp;amp;solution.front(), b, &amp;amp;RCI_request, ipar, dpar, tmp);&lt;BR /&gt; if (RCI_request!=0) { cout &amp;lt;&amp;lt; "dfgmres_init failed." &amp;lt;&amp;lt; endl; statusCode=FAILED; }&lt;BR /&gt; &lt;BR /&gt; ipar[30]=1;&lt;BR /&gt; dpar[30]=1.E-5;&lt;BR /&gt; ipar[14]=2;&lt;BR /&gt; ipar[7]=0;&lt;BR /&gt; ipar[8]=1;&lt;BR /&gt; ipar[9]=0;&lt;BR /&gt; ipar[10]=1;&lt;BR /&gt; ipar[11]=1;&lt;BR /&gt; dpar[0]=1.0E-6;&lt;BR /&gt; &lt;BR /&gt; /*---------------------------------------------------------------------------&lt;BR /&gt; /* Check the correctness and consistency of the newly set parameters&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;/*---------------------------------------------------------------------------*/&lt;BR /&gt; dfgmres_check(&amp;amp;ivar, &amp;amp;solution.front(), b, &amp;amp;RCI_request, ipar, dpar, tmp);&lt;BR /&gt; if (RCI_request!=0) { cout &amp;lt;&amp;lt; "dfgmres_check failed." &amp;lt;&amp;lt; endl; statusCode=FAILED; }&lt;BR /&gt; &lt;BR /&gt; while(statusCode==CONTINUE) {&lt;BR /&gt;  //Compute the solution by RCI (P)FGMRES solver with preconditioning&lt;BR /&gt;  dfgmres(&amp;amp;ivar, &amp;amp;solution.front(), b, &amp;amp;RCI_request, ipar, dpar, tmp);&lt;BR /&gt;  &lt;BR /&gt;  /*---------------------------------------------------------------------------&lt;BR /&gt;  /* If RCI_request=0, then the solution was found with the required precision&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;/*---------------------------------------------------------------------------*/&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;if (RCI_request==0) &lt;BR /&gt;   statusCode=COMPLETE;&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;/*---------------------------------------------------------------------------&lt;BR /&gt;  /* If RCI_request=1, then compute the vector A*tmp[ipar[21]-1]&lt;BR /&gt;  /* and put the result in vector tmp[ipar[22]-1]&lt;BR /&gt;  /*---------------------------------------------------------------------------&lt;BR /&gt;  else if (RCI_request==1) {&lt;BR /&gt;   mkl_dcsrgemv("N", &amp;amp;ivar, &amp;amp;_data[0], &amp;amp;_row_ptr[0], &amp;amp;_col_ind[0],&amp;amp;tmp[ipar[21]-1], &amp;amp;tmp[ipar[22]-1]);&lt;BR /&gt;   statusCode=CONTINUE;&lt;BR /&gt;  }&lt;BR /&gt;
  /*---------------------------------------------------------------------------&lt;BR /&gt;  /* If RCI_request=2, then do the user-defined stopping test&lt;BR /&gt;  /* The residual stopping test for the computed solution is performed here&lt;BR /&gt;  /*---------------------------------------------------------------------------&lt;BR /&gt;  else if (RCI_request==2) {&lt;BR /&gt;   /* Request to the dfgmres_get routine to put the solution&lt;BR /&gt;   /* into b&lt;N&gt; via ipar[12]&lt;BR /&gt;   /*---------------------------------------------------------------------------&lt;BR /&gt;   ipar[12]=1;&lt;BR /&gt;   /* Get the current FGMRES solution in the vector b&lt;N&gt; */&lt;BR /&gt;   dfgmres_get(&amp;amp;ivar, &amp;amp;solution.front(), b, &amp;amp;RCI_request, ipar, dpar,&lt;BR /&gt;      tmp, &amp;amp;itercount);&lt;BR /&gt;   /* Compute the current true residual via MKL (Sparse)&lt;BR /&gt;   /* BLAS routines */&lt;BR /&gt;   mkl_dcsrgemv("N", &amp;amp;ivar, &amp;amp;_data[0], &amp;amp;_row_ptr[0], &amp;amp;_col_ind[0], b, residual);&lt;BR /&gt;   dvar=-1.0E0;&lt;BR /&gt;   i=1;&lt;BR /&gt;   daxpy(&amp;amp;ivar, &amp;amp;dvar, b, &amp;amp;i, residual, &amp;amp;i);&lt;BR /&gt;   dvar=dnrm2(&amp;amp;ivar,residual,&amp;amp;i);&lt;BR /&gt;   if (dvar&amp;lt;1.0E-10)&lt;BR /&gt;    statusCode=COMPLETE;&lt;BR /&gt;   else&lt;BR /&gt;    statusCode=CONTINUE;&lt;BR /&gt;  }&lt;BR /&gt;  /*---------------------------------------------------------------------------&lt;BR /&gt;  /* If RCI_request=3, then apply the preconditioner on the vector&lt;BR /&gt;  /* tmp[ipar[21]-1] and put the result in vector tmp[ipar[22]-1]&lt;BR /&gt;  /*---------------------------------------------------------------------------&lt;BR /&gt;  /* NOTE that ipar[21] and ipar[22] contain FORTRAN style addresses,&lt;BR /&gt;  /* therefore, in C code it is required to subtract 1 from them to get C style&lt;BR /&gt;  /* addresses&lt;BR /&gt;  /* Here is the recommended usage of the result produced by ILUT routine&lt;BR /&gt;  /* via standard MKL Sparse Blas solver routine mkl_dcsrtrsv.&lt;BR /&gt;  /*---------------------------------------------------------------------------*/&lt;BR /&gt;&lt;B&gt;&amp;amp;
nbsp;  else if (RCI_request==3) {&lt;BR /&gt;   char cvar='N';&lt;BR /&gt;   double alpha=1.0;&lt;BR /&gt;   mkl_dcsrsv(&amp;amp;cvar, &amp;amp;ivar, α, "DLNF ", &amp;amp;_data[0], &amp;amp;_col_ind[0], &amp;amp;_row_ptr[0], &amp;amp;_row_ptr[1], &amp;amp;tmp[ipar[21]-1],&amp;amp;tmp[ipar[22]-1]);&lt;BR /&gt;   statusCode=CONTINUE;&lt;BR /&gt;  }&lt;/B&gt;&lt;BR /&gt;  /*---------------------------------------------------------------------------&lt;BR /&gt;  /* If RCI_request=4, then check if the norm of the next generated vector is&lt;BR /&gt;  /* not zero up to rounding and computational errors. The norm is contained&lt;BR /&gt;  /* in dpar[6] parameter&lt;BR /&gt;  /*---------------------------------------------------------------------------*/&lt;BR /&gt;  else if (RCI_request==4) {&lt;BR /&gt;   if (dpar[6]&amp;lt;1.0E-12) statusCode=COMPLETE;&lt;BR /&gt;   else statusCode=CONTINUE;&lt;BR /&gt;  }&lt;BR /&gt;  /*---------------------------------------------------------------------------&lt;BR /&gt;  /* If RCI_request=anything else, then dfgmres subroutine failed&lt;BR /&gt;  /* to compute the solution vector: computed_solution&lt;N&gt;&lt;BR /&gt;  /*---------------------------------------------------------------------------*/&lt;BR /&gt;  else {&lt;BR /&gt;   statusCode=FAILED;&lt;BR /&gt;  }&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; if(statusCode==COMPLETE) {&lt;BR /&gt;  ipar[12]=0;&lt;BR /&gt;  dfgmres_get(&amp;amp;ivar, &amp;amp;solution.front(), b, &amp;amp;RCI_request, ipar, dpar, tmp, &amp;amp;itercount);&lt;BR /&gt; &lt;BR /&gt; } else if (statusCode==FAILED)&lt;BR /&gt;  cout &amp;lt;&amp;lt; "The solver has returned the ERROR code " &amp;lt;&amp;lt; RCI_request &amp;lt;&amp;lt; endl;&lt;BR /&gt; else&lt;BR /&gt;   cout &amp;lt;&amp;lt; "The FGMRES solver has FAILED" &amp;lt;&amp;lt; endl;&lt;BR /&gt; &lt;BR /&gt; delete [] b;&lt;BR /&gt; delete [] tmp;&lt;BR /&gt; delete [] residual;&lt;BR /&gt; delete [] trvec;&lt;BR /&gt; &lt;BR /&gt; return solution;&lt;BR /&gt;}&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;BR /&gt;Any thoughts would be greatly appreciated. Thanks!&lt;BR /&gt;&lt;BR /&gt;-Mark&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Jul 2008 13:54:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FGMRES-Diagonal-preconditioner-Is-this-correct/m-p/864590#M7762</guid>
      <dc:creator>mdobossy</dc:creator>
      <dc:date>2008-07-02T13:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: FGMRES + Diagonal preconditioner.  Is this correct?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FGMRES-Diagonal-preconditioner-Is-this-correct/m-p/864591#M7763</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi Mark,&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for using Intel MKL!&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The marked part of your code looks OK.&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The convergence problem may come from the big condition number of the matrix (roughly speaking, around 10&lt;SUP&gt;12 &lt;/SUP&gt;or larger). Diagonal preconditioner cannot always help to decrease the condition number, thus the method may not converge even with the correct program. &lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you feel that you need more assistance with your program, please submit a test case through MKL support page (&lt;/SPAN&gt;&lt;A href="http://www.intel.com/support/performancetools/libraries/mkl/index.htm"&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;A href="http://www.intel.com/support/performancetools/libraries/mkl/index.htm" target="_blank"&gt;http://www.intel.com/support/performancetools/libraries/mkl/index.htm&lt;/A&gt;&lt;SPAN&gt;), register (if you are not registered yet), and describe the problem and submit the test case. Thank you!&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jul 2008 04:43:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FGMRES-Diagonal-preconditioner-Is-this-correct/m-p/864591#M7763</guid>
      <dc:creator>Sergey_G_Intel</dc:creator>
      <dc:date>2008-07-07T04:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: FGMRES + Diagonal preconditioner.  Is this correct?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FGMRES-Diagonal-preconditioner-Is-this-correct/m-p/864592#M7764</link>
      <description>Sergey-&lt;BR /&gt;&lt;BR /&gt;Thanks for the info! &lt;BR /&gt;&lt;BR /&gt;The problem was indeed in a different portion of the code. Just was trying to rule out improper pre-conditioning. All is working fine now.&lt;BR /&gt;&lt;BR /&gt;-Mark&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jul 2008 13:54:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FGMRES-Diagonal-preconditioner-Is-this-correct/m-p/864592#M7764</guid>
      <dc:creator>mdobossy</dc:creator>
      <dc:date>2008-07-07T13:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: FGMRES + Diagonal preconditioner.  Is this correct?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FGMRES-Diagonal-preconditioner-Is-this-correct/m-p/864593#M7765</link>
      <description>&lt;P&gt;Mark,&lt;/P&gt;
&lt;P&gt;I'm glad to hear that your problem is resolved.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jul 2008 02:34:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/FGMRES-Diagonal-preconditioner-Is-this-correct/m-p/864593#M7765</guid>
      <dc:creator>Sergey_G_Intel</dc:creator>
      <dc:date>2008-07-08T02:34:01Z</dc:date>
    </item>
  </channel>
</rss>

