On Thu, Feb 17, 2011 at 9:10 PM, Gaurish Telang <span dir="ltr"><<a href="mailto:gaurish108@gmail.com">gaurish108@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br><br>I wanted to solve some least squares problems using PETSc. My test matrix is size 3x2 but I wish to use this code for solving large ill-conditioned rectangular systems later. <br><br>Looking at the PETSc manual I the found the KSPLSQR routine which implements the LSQR algorithm. <br>
<br>However I am unsure how to use this routine. I am pasting the lines of the code which I use to set up the solver. <br><br>Through the terminal I pass the option -ksp_type lsqr while running exectuable. <br><br> ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);<br>
<br> ierr = KSPSetOperators(ksp,A,PETSC_NULL,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);<br></blockquote><div><br></div><div>Pass A, not PETSC_NULL.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);<br><br> ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); <br><br> ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); <br>
<br>As you can see I have used PETSC_NULL for the preconditioner matrix since I wish to use the *unpreconditioned* version of the LSQR algorithm. This gives me an error. <br><br>If I pass the matrix A it gives me an error again. I am not sure how to tell PETSc not to use a preconditioner. <br>
<br>Could you please tell me how I should use KSPSetOperators statement in this case to use the unpreconditioned algorithm.<br><br>If you have a better sparse matrix least squares algorithm implemented please let me know. <br>
<br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>