:orphan:
# VecSetValue
Set a single entry into a vector. 
## Synopsis
```
#include <petscvec.h>
PetscErrorCode VecSetValue(Vec v,PetscInt row,PetscScalar value, InsertMode mode);
```
Not Collective


## Input Parameters

- ***v -*** the vector
- ***row -*** the row location of the entry
- ***value -*** the value to insert
- ***mode -*** either `INSERT_VALUES` or `ADD_VALUES`





## Notes
For efficiency one should use `VecSetValues()` and set several or
many values simultaneously if possible.

These values may be cached, so `VecAssemblyBegin()` and `VecAssemblyEnd()`
MUST be called after all calls to `VecSetValue()` have been completed.

`VecSetValue()` uses 0-based indices in Fortran as well as in C.


## See Also
 [](ch_vectors), `VecSetValues()`, `VecAssemblyBegin()`, `VecAssemblyEnd()`, `VecSetValuesBlockedLocal()`, `VecSetValueLocal()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscvec.h.html#VecSetValue">include/petscvec.h</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex43.c.html">src/ksp/ksp/tutorials/ex43.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex49.c.html">src/ksp/ksp/tutorials/ex49.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex56.c.html">src/ksp/ksp/tutorials/ex56.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex3.c.html">src/mat/tutorials/ex3.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex28.c.html">src/snes/tutorials/ex28.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex30.c.html">src/snes/tutorials/ex30.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex56.c.html">src/snes/tutorials/ex56.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex70.c.html">src/snes/tutorials/ex70.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/constrained/tutorials/ex1.c.html">src/tao/constrained/tutorials/ex1.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion3.c.html">src/tao/unconstrained/tutorials/eptorsion3.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/extchem.c.html">src/ts/tutorials/extchem.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscvec.h)


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