# VecSetOperation
Allows user to set a vector operation. 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecSetOperation(Vec vec, VecOperation op, void (*f)(void))
```
Logically Collective; No Fortran Support


## Input Parameters

- ***vec -*** the vector
- ***op -*** the name of the operation
- ***f -*** the function that provides the operation.





## Usage
```none
      PetscErrorCode userview(Vec,PetscViewer);
      PetscCall(VecCreateMPI(comm,m,M,&x));
      PetscCall(VecSetOperation(x,VECOP_VIEW,(void(*)(void))userview));
```



## Notes
See the file include/petscvec.h for a complete list of matrix
operations, which all have the form VECOP_<OPERATION>, where
<OPERATION> is the name (in all capital letters) of the
user interface routine (e.g., VecView() -> VECOP_VIEW).


## See Also
 [](chapter_vectors), `Vec`, `VecCreate()`, `MatShellSetOperation()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/interface/vector.c.html#VecSetOperation">src/vec/vec/interface/vector.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/interface/vector.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)  
