[petsc-users] Least squares: using unpreconditioned LSQR

Gaurish Telang gaurish108 at gmail.com
Thu Feb 17 21:10:44 CST 2011


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.

Looking at the PETSc manual I the found the KSPLSQR routine which implements
the LSQR algorithm.

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.

Through the terminal I pass the option -ksp_type lsqr while running

 ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);

 ierr =

ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);

 ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);

 ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);

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.

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.

Could you please tell me how I should use KSPSetOperators statement in this
case to use the unpreconditioned algorithm.

If you have a better sparse matrix least squares algorithm implemented
please let me know.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110217/f0132d46/attachment.htm>

More information about the petsc-users mailing list