<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Greg:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<p dir="ltr">Thanks so much for the detailed response. I am glad to know the reason behind it--hopefully we eventually figure out why the solvers have this behavior! Hong, I really appreciate you working on a patch to throw an error in this case. It definitely bit me and some people using my code... Hopefully it doesn't happen to anyone else! :)</p></blockquote><div class="gmail_quote">I added an error flag for using MUMPS Cholesky factorization on Hermitian matrix. See branch hzhang/mumps-HermitianCholesky-errflag</div><div><a href="https://bitbucket.org/petsc/petsc/commits/8f21f52c465b775a76cda90fe9c51d0c742078c7">https://bitbucket.org/petsc/petsc/commits/8f21f52c465b775a76cda90fe9c51d0c742078c7</a> </div><div><br></div><div>Jose,</div><div>PETSc does not support Cholesky for Hermitian matrix.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
The linear solver table probably needs to be updated. I have tried several Cholesky solvers. With mkl_pardiso I get an explicit error message that it does not support Cholesky with complex scalars. The rest (PETSc, MUMPS, CHOLMOD) give a wrong answer (without error message). The problem is not related to your matrix, nor to shift-and-invert in SLEPc. I tried with ex1.c under PETSC_DIR/src/ksp/ksp/<wbr>examples/tutorials. The example works in complex scalars, but the matrix is real. As soon as you add complex entries Cholesky fails, for instance adding this:<br>
  ierr = MatSetValue(A,0,1,1.0+PETSC_i,<wbr>INSERT_VALUES);CHKERRQ(ierr);<br>
  ierr = MatSetValue(A,1,0,1.0-PETSC_i,<wbr>INSERT_VALUES);CHKERRQ(ierr);<br></blockquote></div></div></div></div></blockquote></div></div></div></blockquote><div> </div><div>In this case, you must call</div><div>MatSetOption(A,MAT_HERMITIAN,PETSC_TRUE);</div><div><br></div><div>Then, petsc will throw an error for '-pc_type cholesky'.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I don't know if it is a bug or that the algorithm cannot support complex Hermitian matrices. Maybe Hong can confirm any of these. In the latter case, I agree that all packages should give an error message, as mkl_pardiso does.<br></blockquote></div></div></div></div></blockquote></div></div></div></blockquote><div><br></div><div>I also add an error flag for Cholesky/ICC if user does not set </div><div>MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE) for aij matrix.<br></div><div>See <a href="https://bitbucket.org/petsc/petsc/commits/966c94c9cf4fa13d455726ec36800a577e00b171">https://bitbucket.org/petsc/petsc/commits/966c94c9cf4fa13d455726ec36800a577e00b171</a><br></div><div><br></div><div>Let me know if you have any comments about this fix.</div><div><br></div><div>Hong</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_-5683897536750051528m_-4754538946754754778HOEnZb"><div class="gmail-m_-5683897536750051528m_-4754538946754754778h5"><br>
> El 25 sept 2017, a las 7:17, Greg Meyer <<a href="mailto:gregory.meyer@gmail.com" target="_blank">gregory.meyer@gmail.com</a>> escribió:<br>
><br>
> Hi all,<br>
><br>
> Hong--looking at your link, there may be no special algorithm for Hermitian matrices in MUMPS, but that doesn't mean it can't solve them like it would any matrix. Furthermore it appears that Cholesky of complex matrices is supported from this link: <a href="https://www.mcs.anl.gov/petsc/documentation/linearsolvertable.html" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/<wbr>documentation/<wbr>linearsolvertable.html</a><br>
><br>
> So do you or anyone have any idea why I get incorrect eigenvalues?<br>
><br>
> Thanks,<br>
> Greg<br>
><br>
> On Thu, Sep 21, 2017 at 5:51 PM Greg Meyer <<a href="mailto:gregory.meyer@gmail.com" target="_blank">gregory.meyer@gmail.com</a>> wrote:<br>
> Ok, thanks. It seems that PETSc clearly should throw an error in this case instead of just giving incorrect answers? I am surprised that it does not throw an error...<br>
><br>
> On Thu, Sep 21, 2017 at 5:24 PM Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>> wrote:<br>
> Greg :<br>
> Yes, they are Hermitian.<br>
><br>
> PETSc does not support  Cholesky factorization for Hermitian.<br>
> It seems mumps does not support Hermitian either<br>
> <a href="https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2015-November/027541.html" rel="noreferrer" target="_blank">https://lists.mcs.anl.gov/<wbr>mailman/htdig/petsc-users/<wbr>2015-November/027541.html</a><br>
><br>
> Hong<br>
><br>
><br>
> On Thu, Sep 21, 2017 at 3:43 PM Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>> wrote:<br>
> Greg:<br>
><br>
> OK, the difference is whether LU or Cholesky factorization is used. But I would hope that neither one should give incorrect eigenvalues, and when I run with the latter it does!<br>
> Are your matrices symmetric/Hermitian?<br>
> Hong<br>
><br>
> On Thu, Sep 21, 2017 at 2:05 PM Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>> wrote:<br>
> Gregory :<br>
> Use '-eps_view' for both runs to check the algorithms being used.<br>
> Hong<br>
><br>
> Hi all,<br>
><br>
> I'm using shift-invert with EPS to solve for eigenvalues. I find that if I do only<br>
><br>
> ...<br>
>   ierr = EPSGetST(eps,&st);CHKERRQ(<wbr>ierr);<br>
>   ierr = STSetType(st,STSINVERT);<wbr>CHKERRQ(ierr);<br>
> ...<br>
><br>
> in my code I get correct eigenvalues. But if I do<br>
><br>
> ...<br>
>   ierr = EPSGetST(eps,&st);CHKERRQ(<wbr>ierr);<br>
>   ierr = STSetType(st,STSINVERT);<wbr>CHKERRQ(ierr);<br>
>   ierr = STGetKSP(st,&ksp);CHKERRQ(<wbr>ierr);<br>
>   ierr = KSPGetPC(ksp,&pc);CHKERRQ(<wbr>ierr);<br>
>   ierr = KSPSetType(ksp,KSPPREONLY);<wbr>CHKERRQ(ierr);<br>
>   ierr = PCSetType(pc,PCCHOLESKY);<wbr>CHKERRQ(ierr);<br>
> ...<br>
><br>
> the eigenvalues found by EPS are completely wrong! Somehow I thought I was supposed to do the latter, from the examples etc, but I guess that was not correct? I attach the full piece of test code and a test matrix.<br>
><br>
> Best,<br>
> Greg<br>
><br>
<br>
</div></div></blockquote></div><br></div></div></div></blockquote></div>
</div></div></blockquote></div><br></div></div>