Skip to main content
`Ctrl`+`K`

# KSPCGGetObjFcn

Get the conjugate gradient objective function value

## Synopsis

    #include "petscksp.h"
    PetscErrorCode KSPCGGetObjFcn(KSP ksp, PetscReal *o_fcn)

Not collective

## Input Parameters

- ksp - the iterative context

- o_fcn - the objective function value

## Note

This function will return the current objective function value \(\frac{1}{2} x^H_k A x_k - b^H x_k\). if called during `KSPSolve()` (e.g. during a monitor call). When called outside of a `KSPSolve()`, it will return the last computed value inside the solver.

## See Also

KSP: Linear System Solvers, `KSP`, `KSPCG`, `KSPNASH`, `KSPSTCG`, `KSPGLTR`, `KSPMonitorSet`

## Level

advanced

## Location

src/ksp/ksp/impls/cg/cgtype.c

## Implementations

KSPCGGetObjFcn_CG() in src/ksp/ksp/impls/cg/cg.c
KSPCGGetObjFcn_GLTR() in src/ksp/ksp/impls/cg/gltr/gltr.c
KSPCGGetObjFcn_NASH() in src/ksp/ksp/impls/cg/nash/nash.c
KSPCGGetObjFcn_STCG() in src/ksp/ksp/impls/cg/stcg/stcg.c

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