TaoIsGradientDefined — PETSc 3.25.2 documentation

Skip to main content
`Ctrl`+`K`

# TaoIsGradientDefined

Checks to see if the user has declared a gradient-only routine. Useful for determining when it is appropriate to call `TaoComputeGradient()` or `TaoComputeObjectiveAndGradient()`

## Synopsis

    #include "petsctao.h"
    PetscErrorCode TaoIsGradientDefined(Tao tao, PetscBool *flg)

Not Collective

## Input Parameter

- tao - the `Tao` context

## Output Parameter

- flg - `PETSC_TRUE` if the objective `TaoTerm` has this routine, `PETSC_FALSE` otherwise

## Note

If the objective of `Tao` has been altered via `TaoAddTerm()`, it will return whether the summation of all terms has this routine.

## See Also

TAO: Optimization Solvers, `TaoSetGradient()`, `TaoIsObjectiveDefined()`, `TaoIsObjectiveAndGradientDefined()`

## Level

developer

## Location

src/tao/interface/taosolver_fg.c

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