# TaoIsGradientDefined
Checks to see if the user has declared an objective-only routine.  Useful for determining when it is appropriate to call `TaoComputeGradient()` or `TaoComputeGradientAndGradient()` 
## Synopsis
```
#include "petsctao.h" 
PetscErrorCode TaoIsGradientDefined(Tao tao, PetscBool *flg)
```
Not Collective


## Input Parameter

- ***tao -*** the Tao context



## Output Parameter

- ***flg -*** `PETSC_TRUE` if function routine is set by user, `PETSC_FALSE` otherwise





## See Also
 `TaoSetGradient()`, `TaoIsObjectiveDefined()`, `TaoIsObjectiveAndGradientDefined()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/interface/taosolver_fg.c.html#TaoIsGradientDefined">src/tao/interface/taosolver_fg.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/tao/interface/taosolver_fg.c)


[Index of all Tao routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
