# KSPComputeExtremeSingularValues
Computes the extreme singular values for the preconditioned operator. Called after or during `KSPSolve()`. 
## Synopsis
```
#include "petscksp.h" 
#include "petscmat.h" 
PetscErrorCode KSPComputeExtremeSingularValues(KSP ksp, PetscReal *emax, PetscReal *emin)
```
Not Collective


## Input Parameter

- ***ksp -*** iterative context obtained from `KSPCreate()`



## Output Parameters

- ***emin, emax -*** extreme singular values



## Options Database Keys

- ***-ksp_view_singularvalues -*** compute extreme singular values and print when `KSPSolve()` completes.



## Notes
One must call `KSPSetComputeSingularValues()` before calling `KSPSetUp()`
(or use the option -ksp_view_eigenvalues) in order for this routine to work correctly.

Many users may just want to use the monitoring routine
`KSPMonitorSingularValue()` (which can be set with option -ksp_monitor_singular_value)
to print the extreme singular values at each iteration of the linear solve.

Estimates of the smallest singular value may be very inaccurate, especially if the Krylov method has not converged.
The largest singular value is usually accurate to within a few percent if the method has converged, but is still not
intended for eigenanalysis. Consider the excellent package `SLEPc` if accurate values are required.

Disable restarts if using KSPGMRES, otherwise this estimate will only be using those iterations after the last
restart. See `KSPGMRESSetRestart()` for more details.




## See Also
 [](chapter_ksp), `KSPSetComputeSingularValues()`, `KSPMonitorSingularValue()`, `KSPComputeEigenvalues()`, `KSP`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/interface/itfunc.c.html#KSPComputeExtremeSingularValues">src/ksp/ksp/interface/itfunc.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex56.c.html">src/ksp/ksp/tutorials/ex56.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex59.c.html">src/ksp/ksp/tutorials/ex59.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/cgeig.c.html#KSPComputeExtremeSingularValues_CG">KSPComputeExtremeSingularValues_CG in src/ksp/ksp/impls/cg/cgeig.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/fetidp/fetidp.c.html#KSPComputeExtremeSingularValues_FETIDP">KSPComputeExtremeSingularValues_FETIDP in src/ksp/ksp/impls/fetidp/fetidp.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gmres/gmreig.c.html#KSPComputeExtremeSingularValues_GMRES">KSPComputeExtremeSingularValues_GMRES in src/ksp/ksp/impls/gmres/gmreig.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/ksp/interface/itfunc.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)  
