# VecBoundGradientProjection
Projects  vector according to this definition. If XL[i] < X[i] < XU[i], then GP[i] = G[i]; If X[i] <= XL[i], then GP[i] = min(G[i],0); If X[i] >= XU[i], then GP[i] = max(G[i],0); 
## Synopsis
```
#include "petscvec.h"  
PetscErrorCode VecBoundGradientProjection(Vec G, Vec X, Vec XL, Vec XU, Vec GP)
```

## Input Parameters

- ***G -*** current gradient vector
- ***X -*** current solution vector with XL[i] <= X[i] <= XU[i]
- ***XL -*** lower bounds
- ***XU -*** upper bounds



## Output Parameter

- ***GP -*** gradient projection vector



## Notes
GP may be the same vector as G



## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/utils/projection.c.html#VecBoundGradientProjection">src/vec/vec/utils/projection.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/utils/projection.c)


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