<div dir="ltr"><div><div>Thanks a lot for your answer<br></div>Best regards <br></div>Natacha <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 6, 2015 at 6:52 PM, Hong <span dir="ltr"><<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Natacha:</div><div class="gmail_quote">I can repeat the error with your ex1f.F.</div><div class="gmail_quote"><br></div><div class="gmail_quote">The lsqr solver in PETSc was contributed by a user a decade ago. I'll read the original algorithm and investigate it.</div><div class="gmail_quote"><br></div><div class="gmail_quote">I'll let you know the result. </div><span class="HOEnZb"><font color="#888888"><div class="gmail_quote"><br></div><div class="gmail_quote">Hong</div></font></span><div><div class="h5"><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Dear PETSc users,<br></div>I am trying to solve an over determined linear system of equations Ax =b with the least square solver LSQR.<br></div>The matrix A is rectangular : it has m rows and n columns with m>n. <br></div>I set the preconditioner to "PCNONE" (following for instance post <a href="https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2012-May/013591.html" target="_blank">https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2012-May/013591.html</a>)<br><br></div>Matrix A has the form : <br></div><div>A(1:n,1:n) = Identity(n)<br></div><div>A(n+1:m, 1:n) = 0.<br><br></div><div>I define a vector u of size n and set u(1:n) to 1.0<br><br></div><div>The right hand side b= Au. <br><br></div><div>The (fortran) test program is attached (it's petsc-3.5.2/src/ksp/ksp/examples/tutorials/ex1f.F slightly modified)<br><br></div><div>The size of matrix A is defined at runtime<br><br></div><div>The solver ends OK with m=10, n=2 but goes wrong with m=10, n=3 (KSP Converged reason = -5)<br><br></div><div>The output is shown below:<br><br>First run with n=2 columns <br>====================<br>./ex1f -ksp_type lsqr -vec_type seq -ksp_monitor -m 10 -n 2<br><br> 0 KSP Residual norm 1.414213562373e+00 <br> 1 KSP Residual norm 3.790370795009e-16 <br>KSP Object: 1 MPI processes<br> type: lsqr<br> maximum iterations=10000, initial guess is zero<br> tolerances: relative=1e-07, absolute=1e-50, divergence=10000<br> left preconditioning<br> using UNPRECONDITIONED norm type for convergence test<br>PC Object: 1 MPI processes<br> type: none<br> linear system matrix = precond matrix:<br> Mat Object: 1 MPI processes<br> type: seqaij<br> rows=10, cols=2<br> total: nonzeros=2, allocated nonzeros=50<br> total number of mallocs used during MatSetValues calls =0<br> using I-node routines: found 4 nodes, limit used is 5<br> KSP Converged Reason 2<br>Norm of error < 1.e-12,Iterations = 1<br><br></div><div>Second run, with n=3<br>================<br>./ex1f -ksp_type lsqr -vec_type seq -ksp_monitor -m 10 -n 3<br><br> 0 KSP Residual norm 1.732050807569e+00 <br>KSP Object: 1 MPI processes<br> type: lsqr<br> maximum iterations=10000, initial guess is zero<br> tolerances: relative=1e-07, absolute=1e-50, divergence=10000<br> left preconditioning<br> using UNPRECONDITIONED norm type for convergence test<br>PC Object: 1 MPI processes<br> type: none<br> linear system matrix = precond matrix:<br> Mat Object: 1 MPI processes<br> type: seqaij<br> rows=10, cols=3<br> total: nonzeros=3, allocated nonzeros=50<br> total number of mallocs used during MatSetValues calls =0<br> using I-node routines: found 5 nodes, limit used is 5<br> KSP Converged Reason -5<br>Norm of error = 0.1732E+01, Iterations = 0<br><br></div><div><br></div><div>I am using version 3.5.2 of PETSc library<br><br></div><div>I am probably doing something wrong, but I don't understand what the problem is. <br></div><div>Does anyone have an idea of what is going on ? <br></div><div>Best regards<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>Natacha <br></div><div><br></div><div> <br></div><div><br></div><br></font></span></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>