[petsc-users] Least squares: using unpreconditioned LSQR

Gaurish Telang gaurish108 at gmail.com
Thu Feb 17 22:40:50 CST 2011


Thank you. On using A in place of Pmat position in the KSPSetOperators list
of arguments, I was able to get the small test system to work.










On Thu, Feb 17, 2011 at 10:20 PM, Matthew Knepley <knepley at gmail.com> wrote:

> On Thu, Feb 17, 2011 at 9:10 PM, Gaurish Telang <gaurish108 at gmail.com>wrote:
>
>> Hi,
>>
>> 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
>> exectuable.
>>
>>  ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);
>>
>>  ierr =
>> KSPSetOperators(ksp,A,PETSC_NULL,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);
>>
>
> Pass A, not PETSC_NULL.
>
>    Matt
>
>
>> 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.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110217/0ad214e6/attachment.htm>


More information about the petsc-users mailing list