Skip to main content
`Ctrl`+`K`

# TaoSetResidualRoutine

Sets the residual evaluation routine for least-square applications

## Synopsis

    #include "petsctao.h"
    PetscErrorCode TaoSetResidualRoutine(Tao tao, Vec res, PetscErrorCode (*func)(Tao tao, Vec x, Vec res, PetscCtx ctx), PetscCtx ctx)

Logically Collective

## Input Parameters

- tao - the `Tao` context

- res - the residual vector

- func - the residual evaluation routine

- ctx - [optional] user-defined context for private data for the function evaluation routine (may be `NULL`)

## Calling sequence of `func`

- tao - the optimizer

- x - input vector

- res - function value vector

- ctx - [optional] user-defined function context

## See Also

TAO: Optimization Solvers, `Tao`, `TaoSetObjective()`, `TaoSetJacobianRoutine()`

## Level

beginner

## Location

src/tao/interface/taosolver_fg.c

## Examples

src/tao/leastsquares/tutorials/chwirut1f.F90
src/tao/leastsquares/tutorials/tomography.c
src/tao/leastsquares/tutorials/cs1.c
src/tao/leastsquares/tutorials/chwirut1.c
src/tao/leastsquares/tutorials/chwirut2f.F90
src/tao/leastsquares/tutorials/chwirut2.c

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