<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br>I am trying to do LU factorization to an ill-conditioned system. PETSc gives me "Detected zero pivot in LU factorization". The problem is solved when I use PCFactorSetShiftNonzero.<br><br>Just to be sure, I used Matlab and Lapack(DGETRF) to do the factorization. They did it without any complain and they gave me the same answer. However, the answer I got from PETSc is completely different.<br><br>In PETSc I did the following:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call KSPCreate(PETSC_COMM_SELF,ksp1,ierr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call KSPSetOperators(ksp1,PSASTF,PSASTF,SAME_NONZERO_PATTERN,ierr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call KSPSetType(ksp1,KSPPREONLY,ierr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call KSPGetPC(ksp1,prec1,ierr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call PCSetType(prec1,PCLU,ierr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call
 PCFactorSetShiftNonzero(prec1,PETSC_DECIDE,IERR)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call KSPSetFromOptions(ksp1,ierr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call KSPSetUp(ksp1,ierr)<br><br>Any idea why PETSc gives different answer than Matlab and Lapack routine (DGETRF).<br><br>Thanks<br><br>Waad <br></td></tr></table><br>