# KSPLSQRConvergedDefault
Determines convergence of the `KSPLSQR` Krylov method. 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPLSQRConvergedDefault(KSP ksp, PetscInt n, PetscReal rnorm, KSPConvergedReason *reason, void *ctx)
```
Collective


## Input Parameters

- ***ksp   -*** iterative context
- ***n     -*** iteration number
- ***rnorm -*** 2-norm residual value (may be estimated)
- ***ctx -*** convergence context which must be created by `KSPConvergedDefaultCreate()`



## reason is set to

- ***positive -*** if the iteration has converged;
- ***negative -*** if residual norm exceeds divergence threshold;
- ***0 -*** otherwise.



## Notes
`KSPConvergedDefault()` is called first to check for convergence in A*x=b.
If that does not determine convergence then checks convergence for the least squares problem, i.e. in min{|b-A*x|}.
Possible convergence for the least squares problem (which is based on the residual of the normal equations) are `KSP_CONVERGED_RTOL_NORMAL` norm
and `KSP_CONVERGED_ATOL_NORMAL`.

`KSP_CONVERGED_RTOL_NORMAL` is returned if ||A'*r|| < rtol * ||A|| * ||r||.
Matrix norm ||A|| is iteratively refined estimate, see `KSPLSQRGetNorms()`.
This criterion is now largely compatible with that in MATLAB `lsqr()`.




## See Also
 [](chapter_ksp), `KSPLSQR`, `KSPSetConvergenceTest()`, `KSPSetTolerances()`, `KSPConvergedSkip()`, `KSPConvergedReason`, `KSPGetConvergedReason()`,
`KSPConvergedDefaultSetUIRNorm()`, `KSPConvergedDefaultSetUMIRNorm()`, `KSPConvergedDefaultCreate()`, `KSPConvergedDefaultDestroy()`, `KSPConvergedDefault()`, `KSPLSQRGetNorms()`, `KSPLSQRSetExactMatNorm()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/lsqr/lsqr.c.html#KSPLSQRConvergedDefault">src/ksp/ksp/impls/lsqr/lsqr.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/ksp/impls/lsqr/lsqr.c)


[Index of all KSP routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
