[petsc-users] using KSPLSQR and SKPCGNE

Hong Zhang hzhang at mcs.anl.gov
Mon Jan 17 08:48:20 CST 2011


You can run ~petsc/src/ksp/ksp/examples/tutorials/ex2.c with runtime option

petsc-3.1/src/ksp/ksp/examples/tutorials>./ex2 -ksp_type lsqr -ksp_monitor
  0 KSP Residual norm 6.164414002969e+00
  1 KSP Residual norm 3.193020760242e+00
...
 19 KSP Residual norm 5.405772406774e-04
Norm of error 0.000404485 iterations 19

option '-ksp_view' display the solver being used.

Hong

On Mon, Jan 17, 2011 at 2:15 AM, Gaurish Telang <gaurish108 at gmail.com> wrote:
> Hi,
>
> I am new to PETSc and I wanted to solve some least squares problems with it.
> On searching the net I found that KSPLSQR() and KSPCGNE() solve the least
> squares system |Ax-b|
>
> But I don't really know how to use these functions to get my answer. This
> manual page did not help:
> http://www.mcs.anl.gov/petsc/petsc-2/snapshots/petsc-current/docs/manualpages/KSP/KSPLSQR.html
>
> Apparently no tutorial code uses these functions.
>
> If anyone could could give a small code snippet of how to use these
> functions (assuming A and b are given) then it would be really helpful.
>
> Thanks,
>
> Gaurish
>


More information about the petsc-users mailing list