<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> Please send the code. This should work fine.<div class=""><br class=""></div><div class=""> Barry</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 25, 2020, at 2:43 PM, Rakesh Halder <<a href="mailto:rhalder@umich.edu" class="">rhalder@umich.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi all,</div><div class=""><br class=""></div><div class="">I'm using PETSc for matrix calculations as part of a model order reduction code. An algorithm I'm using requires that I compute the explicit inverse of a matrix, as it needs to be used in matrix-matrix products. <br class=""></div><div class=""><br class=""></div><div class="">The matrix is small (I'll show a 5x5 example), and I first find the LU factorization of it as follows:</div><div class=""><br class=""></div><div class=""> MatGetOrdering(A,MATORDERINGNATURAL,&perm,&iperm);<br class=""> MatFactorInfoInitialize(&info);<br class=""> MatLUFactor(A,perm,iperm,&info);</div><div class=""><br class=""></div><div class="">I then find the inverse of it:</div><div class=""><br class=""></div><div class=""> MatMatSolve(A,I,B);</div><div class=""><br class=""></div><div class="">Where I is the identity matrix, and B is the inverse. The subroutine does calculate an inverse, although not accurately; the matrix A I looked at is:</div><div class=""><br class=""></div><div class="">
<span class=""></span>
<table style="font-family:"Liberation Sans";font-size:x-small" cellspacing="0" border="0" class="">
<colgroup width="85" span="5" class=""></colgroup>
<tbody style="font-family:"Liberation Sans";font-size:x-small" class=""><tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">5.23E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">1.86E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">2.67E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">4.58E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">3.55E-02</td>
</tr>
<tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">6.37E-03</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">5.86E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">5.07E-03</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">1.64E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">1.36E-02</td>
</tr>
<tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">-4.07E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">3.99E-03</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">5.50E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">1.77E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-3.21E-02</td>
</tr>
<tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">1.96E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-5.53E-03</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">4.02E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-5.37E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">1.80E-02</td>
</tr>
<tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">1.51E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">1.70E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-1.57E-02</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-3.75E-03</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-5.64E-02</td>
</tr>
</tbody></table>
</div><div class=""><br class=""></div><div class="">And when I take the product A*B, I don't recover the identity matrix, but rather:</div><div class=""><br class=""></div><div class="">
<span class=""></span>
<table style="font-family:"Liberation Sans";font-size:x-small" cellspacing="0" border="0" class="">
<colgroup width="85" span="5" class=""></colgroup>
<tbody style="font-family:"Liberation Sans";font-size:x-small" class=""><tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">9.97E-01</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">2.77E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-1.66E-03</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">1.25E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-1.10E-03</td>
</tr>
<tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">-6.79E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">9.99E-01</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-1.72E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">6.24E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">1.16E-03</td>
</tr>
<tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">2.70E-03</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-3.98E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">9.98E-01</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-1.51E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">6.82E-04</td>
</tr>
<tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">-3.35E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-4.82E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-1.03E-03</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">9.99E-01</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">9.80E-05</td>
</tr>
<tr style="font-family:"Liberation Sans";font-size:x-small" class="">
<td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="right" class="">-9.50E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-8.70E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">8.37E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">-3.68E-04</td>
<td style="font-family:"Liberation Sans";font-size:x-small" align="right" class="">9.99E-01</td>
</tr>
</tbody></table>
</div><div class=""><br class=""></div><div class="">I believe this is causing large inaccuracies in my program, as the diagonal and off-diagonal entries have large errors associated with them. I am wondering if there is a way to perhaps tighten the tolerance of the subroutine, or if there are other methods I can use. I would like to avoid using KSP and solving for the inverse vector-by-vector if possible.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Rakesh Halder<br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>