# SNESLineSearchSetPreCheck

Sets a routine to check the validity of a new direction given by the linear solve before the line search is called.

### Synopsis

    PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchSetPreCheck(SNES snes,PetscErrorCode (*func)(SNES,Vec,Vec,void*,PetscTruth*),void *checkctx)

### Input Parameters

| snes | - nonlinear context obtained from SNESCreate()
| func | - pointer to function
| checkctx | - optional user-defined context for use by step checking routine

Collective on SNES

### Calling sequence of func

       int func (SNES snes, Vec x,Vec y,void *checkctx, PetscTruth *changed_y)

where func returns an error code of 0 on success and a nonzero on failure.

### Input parameters for func

| snes | - nonlinear context
| checkctx | - optional user-defined context for use by step checking routine
| x | - previous iterate
| y | - new search direction and length

### Output parameters for func

| y | - search direction (possibly changed)
| changed_y | - indicates search direction was changed by this routine

Notes: All line searches accept the new iterate computed by the line search checking routine.

### Keywords

SNES, nonlinear, set, line search check, step check, routine

### See Also

SNESLineSearchSet(), SNESLineSearchSetPostCheck(), SNESSetUpdate()

Level:advanced
Location: src/snes/impls/ls/ls.c
Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/snes/examples/tutorials/ex3.c.html