Skip to main content
`Ctrl`+`K`

# KSPSetComputeInitialGuess

set routine to compute the initial guess of the linear system

## Synopsis

    #include "petscksp.h"
    #include "petscmat.h"
    PetscErrorCode KSPSetComputeInitialGuess(KSP ksp, KSPComputeInitialGuessFn *func, void *ctx)

Logically Collective

## Input Parameters

- ksp - the `KSP` context

- func - function to compute the initial guess, see `KSPComputeInitialGuessFn` for calling sequence

- ctx - optional context

## Note

This should only be used in conjunction with `KSPSetComputeRHS()` and `KSPSetComputeOperators()`, otherwise call `KSPSetInitialGuessNonzero()` and set the initial guess values in the solution vector passed to `KSPSolve()` before calling the solver

## See Also

KSP: Linear System Solvers, `KSP`, `KSPSolve()`, `KSPSetComputeRHS()`, `KSPSetComputeOperators()`, `DMKSPSetComputeInitialGuess()`, `KSPSetInitialGuessNonzero()`, `KSPComputeInitialGuessFn`

## Level

beginner

## Location

src/ksp/ksp/interface/itfunc.c

## Examples

src/ksp/ksp/tutorials/ex45.c
src/ksp/ksp/tutorials/ex45f.F90

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