:orphan:
# VecSum
Computes the sum of all the components of a vector.
## Synopsis
```
#include "petscvec.h"
PetscErrorCode VecSum(Vec v, PetscScalar *sum)
```
Collective
## Input Parameter
- ***v -*** the vector
## Output Parameter
- ***sum -*** the result
## See Also
`Vec`, `VecMean()`, `VecNorm()`
## Level
beginner
## Location
src/vec/vec/utils/vinv.c
## Examples
src/dm/tutorials/ex2.c
src/ksp/ksp/tutorials/ex59.c
src/tao/constrained/tutorials/tomographyADMM.c
src/tao/pde_constrained/tutorials/elliptic.c
src/tao/pde_constrained/tutorials/hyperbolic.c
src/tao/unconstrained/tutorials/spectraladjointassimilation.c
src/ts/tutorials/ex9.c
src/ts/tutorials/extchem.c
src/vec/vec/tutorials/ex13.c
src/vec/vec/tutorials/ex18.c
src/vec/vec/tutorials/ex18f.F90
## Implementations
VecSum_SeqKokkos in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/utils/vinv.c)
[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)