:orphan:
# VecAXPBYPCZ
Computes `z = alpha x + beta y + gamma z`
## Synopsis
```
#include "petscvec.h"
PetscErrorCode VecAXPBYPCZ(Vec z, PetscScalar alpha, PetscScalar beta, PetscScalar gamma, Vec x, Vec y)
```
Logically Collective
## Input Parameters
- ***alpha -*** first scalar
- ***beta -*** second scalar
- ***gamma -*** third scalar
- ***x -*** first vector
- ***y -*** second vector
- ***z -*** third vector
## Output Parameter
- ***z -*** output vector
## Note
`x`, `y` and `z` must be different vectors
## Developer Note
The implementation is optimized for `alpha` of 1.0 and `gamma` of 1.0 or 0.0
## See Also
[](ch_vectors), `Vec`, `VecAYPX()`, `VecMAXPY()`, `VecWAXPY()`, `VecAXPY()`, `VecAXPBY()`
## Level
intermediate
## Location
src/vec/vec/interface/rvector.c
## Examples
src/tao/tutorials/ex4.c
## Implementations
VecAXPBYPCZ_Nest in src/vec/vec/impls/nest/vecnest.c
VecAXPBYPCZ_Seq in src/vec/vec/impls/seq/bvec1.c
VecAXPBYPCZ_SeqKokkos in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx
VecAXPBYPCZ_SeqViennaCL in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/interface/rvector.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)