KSPBuildResidualDefault — PETSc 3.21.4 documentation

Skip to main content
`Ctrl`+`K`

# KSPBuildResidualDefault

Default code to compute the residual.

## Synopsis

    #include "petscksp.h"
    PetscErrorCode KSPBuildResidualDefault(KSP ksp, Vec t, Vec v, Vec *V)

Collecive on ksp

## Input Parameters

- ksp - iterative context

- t - pointer to temporary vector

- v - pointer to user vector

## Output Parameter

- V - pointer to a vector containing the residual

## Note

Some `KSP` methods such as `KSPGMRES` do not compute the explicit residual at each iteration, this routine takes the information they have computed during the previous iterations and uses it to compute the explicit residual via the formula r = b - A*x.

## Developer Note

This is `PETSC_EXTERN` because it may be used by user written plugin `KSPType` implementations

## See Also

KSP: Linear System Solvers, `KSP`, `KSPBuildSolutionDefault()`

## Level

advanced

## Location

src/ksp/ksp/interface/iterativ.c

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