# KSPComputeEigenvaluesExplicitly
Computes all of the eigenvalues of the preconditioned operator using LAPACK. 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPComputeEigenvaluesExplicitly(KSP ksp, PetscInt nmax, PetscReal r[], PetscReal c[])
```
Collective


## Input Parameters

- ***ksp -*** iterative context obtained from `KSPCreate()`
- ***n -*** size of arrays r and c



## Output Parameters

- ***r -*** real part of computed eigenvalues, provided by user with a dimension at least of n
- ***c -*** complex part of computed eigenvalues, provided by user with a dimension at least of n



## Notes
This approach is very slow but will generally provide accurate eigenvalue
estimates.  This routine explicitly forms a dense matrix representing
the preconditioned operator, and thus will run only for relatively small
problems, say n < 500.

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

The preconditioner operator, rhs vector, solution vectors should be
set before this routine is called. i.e use `KSPSetOperators()`, `KSPSolve()`




## See Also
 [](chapter_ksp), `KSP`, `KSPComputeEigenvalues()`, `KSPMonitorSingularValue()`, `KSPComputeExtremeSingularValues()`, `KSPSetOperators()`, `KSPSolve()`

## Level
advanced

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


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