# DAAppSetObjectiveAndGradientRoutine

Set a routine that will evaluate the objective and gradient functions on the given DA at the given point.

## Synopsis

    #include "taodaapplication.h"
    int DAAppSetObjectiveAndGradientRoutine(TAO_APPLICATION daapplication, int (*funcgrad)(TAO_APPLICATION,DA,Vec,double*,Vec, void*),void *ctx)

Collective on TAO_APPLICATION

## Input Parameters

| daapplication | - the DA Application object
| grad | - the function pointer for the gradient evaluation routine
| ctx | - the function-gradient context

## Calling sequence of funcgrad

        funcgrad(TAO_APPLICATION daapplication,DA da, Vec x,double *f,Vec g,void *ctx);

| daapplication | - the TAO_APPLICATION daapplication context
| da | - the Distributed Array
| x | - input vector
| f | - objective value
| g | - gradient vector
| ctx | - user defined function-gradient context set from DAAppSetObjectiveAndGradientRoutine()

## Fortran Note

If your Fortran compiler does not recognize symbols over 31 characters in length, then use the identical routine with the shortened name DAAppSetObjectiveAndGradientRou()

## Options Database Key

-tao_view_gradient -view the gradient after each evaluation using PETSC_VIEWER_STDOUT_SELF

## Keywords

DA, Gradient, Objective Function

## See Also

DAAppSetObjectiveRoutine(), DAAppSetGradientRoutine();

Level:beginner
Location:src/petsctao/gridapplication/interface/daapp.c
TAO DA Application Index
Table of Contents

### Examples

src/petsctao/gridapplication/examples/eptorsion3.c.html

### Examples

src/petsctao/gridapplication/examples/jbearing3.c.html

### Examples

src/petsctao/gridapplication/examples/minsurf3.c.html

### Examples

src/petsctao/gridapplication/examples/combustion3.c.html