# KSPGetErrorHistory
Gets the array used to hold the error history and the number of residuals it contains. 
## Synopsis
```
#include "petscksp.h" 
#include "petscmat.h" 
PetscErrorCode KSPGetErrorHistory(KSP ksp, const PetscReal *a[], PetscInt *na)
```
Not Collective


## Input Parameter

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



## Output Parameters

- ***a  -*** pointer to array to hold history (or NULL)
- ***na -*** number of used entries in a (or NULL)





## Notes
This array is borrowed and should not be freed by the caller.
Can only be called after a `KSPSetErrorHistory()` otherwise a and na are set to zero


## Fortran Note
The Fortran version of this routine has a calling sequence
```none
call KSPGetErrorHistory(KSP ksp, integer na, integer ierr)
```
note that you have passed a Fortran array into `KSPSetErrorHistory()` and you need
to access the residual values from this Fortran array you provided. Only the na (number of
residual norms currently held) is set.


## See Also
 [](chapter_ksp), `KSPSetErrorHistory()`, `KSPGetResidualHistory()`, `KSP`

## Level
advanced

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


---
[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)  
