[petsc-users] Least squares: using unpreconditioned LSQR

Hong Zhang hzhang at mcs.anl.gov
Thu Feb 17 22:01:50 CST 2011


You can use '-ksp_type lsqr -pc_type none'

Hong

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);
>
> 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.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


More information about the petsc-users mailing list