Skip to main content
`Ctrl`+`K`

# KSPGetResidualNorm

Gets the last (possibly approximate and/or preconditioned) residual norm that has been computed.

## Synopsis

    #include "petscksp.h"
    PetscErrorCode KSPGetResidualNorm(KSP ksp, PetscReal *rnorm)

Not Collective

## Input Parameter

- ksp - the iterative context

## Output Parameter

- rnorm - residual norm

## Notes

For some methods, such as `KSPGMRES`, the norm is not computed directly from the residual.

The type of norm used by the method can be controlled with `KSPSetNormType()`

Certain solvers, under certain conditions, may not compute the final residual norm in an iteration, in that case the previous norm is returned.

## See Also

KSP: Linear System Solvers, `KSP`, `KSPSetNormType()`, `KSPBuildResidual()`, `KSPNormType`

## Level

intermediate

## Location

src/ksp/ksp/interface/iterativ.c

## Examples

src/ksp/ksp/tutorials/ex10.c

Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages