<div>Hello,</div><div><br></div><div>I'm solving a small least-squares problem with LSQR. I want to set up Jacobi preconditioning, so I do something like the following:</div><div>  </div><div><b> MatCreateMPIAIJWithSplitArrays( PETSC_COMM_WORLD, *locrow, *loccol, nrow,</b></div>
<div><b><span class="Apple-tab-span" style="white-space:pre">                             </span>  *ncol, onrowidx, oncolidx,</b></div><div><b><span class="Apple-tab-span" style="white-space:pre">                              </span>  (PetscScalar*) onvals, offrowidx, offcolidx,</b></div>
<div><b><span class="Apple-tab-span" style="white-space:pre">                             </span>  (PetscScalar*) values, &A_mat );</b></div><div><b>/* Create Linear Solver Context (and set options) */</b></div><div><b>  KSPCreate( PETSC_COMM_WORLD, &solksp );</b></div>
<div><b>  KSPSetType( solksp, "lsqr" );</b></div><div><b><br></b></div><div><b>  MatCreateNormal(A_mat, &P_mat);</b></div><div><b>  MatSetUp(P_mat); </b></div><div><b>  KSPSetOperators( solksp, A_mat, P_mat, DIFFERENT_NONZERO_PATTERN );</b></div>
<div><b><br></b></div><div><b>  KSPGetPC( solksp, &pc);</b></div><div><b>  PCSetType( pc, PCJACOBI );</b></div><div><b><br></b></div><div><b>  KSPSetFromOptions( solksp );</b></div><div><b>  KSPSolve( solksp, b_vec, x_vec );</b></div>
<div><br></div><div>However, PETSc detects zeros on the diagonal of P_mat:</div><div><br></div><div><div>[0] PCSetUp_Jacobi(): Zero detected in diagonal of matrix, using 1 at those locations</div></div><div><br></div><div>
I then printed out the indices at which the zeros are detected. It turns out that PETSC believes that all the diagonal elements are zero.</div><div>There is no zero column in my A_mat though... I confirmed this by examining both A_mat and A_mat^T * A_mat in Matlab. </div>
<div><br></div><div>What am I doing wrong?</div><div><br></div><div>kind regards,</div><div>Mihai</div>