# VecAXPY
Computes y = alpha x + y. 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecAXPY(Vec y, PetscScalar alpha, Vec x)
```
Logically Collective on Vec


## Input Parameters

- ***alpha -*** the scalar
- ***x, y  -*** the vectors



## Output Parameter

- ***y -*** output vector





## Notes
x and y MUST be different vectors
This routine is optimized for alpha of 0.0, otherwise it calls the BLAS routine

```none
VecAXPY(y,alpha,x)                   y = alpha x           +      y
```
```none
VecAYPX(y,beta,x)                    y =       x           + beta y
```
```none
VecAXPBY(y,alpha,beta,x)             y = alpha x           + beta y
```
```none
VecWAXPY(w,alpha,x,y)                w = alpha x           +      y
```
```none
VecAXPBYPCZ(w,alpha,beta,gamma,x,y)  z = alpha x           + beta y + gamma z
```
```none
VecMAXPY(y,nv,alpha[],x[])           y = sum alpha[i] x[i] +      y
```


## See Also
 `VecAYPX()`, `VecMAXPY()`, `VecWAXPY()`, `VecAXPBYPCZ()`, `VecAXPBY()`

## Level
intermediate

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex1.c.html">src/vec/vec/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex1f.F90.html">src/vec/vec/tutorials/ex1f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex1f90.F90.html">src/vec/vec/tutorials/ex1f90.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex20f90.F90.html">src/vec/vec/tutorials/ex20f90.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/performance.c.html">src/vec/vec/tutorials/performance.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex2.c.html">src/mat/tutorials/ex2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex9.c.html">src/mat/tutorials/ex9.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex1.c.html">src/dm/impls/stag/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex2.c.html">src/dm/impls/stag/tutorials/ex2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex3.c.html">src/dm/impls/stag/tutorials/ex3.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex10.c.html">src/dm/tutorials/ex10.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/nest/vecnest.c.html#VecAXPY_Nest">VecAXPY_Nest in src/vec/vec/impls/nest/vecnest.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/bvec1.c.html#VecAXPY_Seq">VecAXPY_Seq in src/vec/vec/impls/seq/bvec1.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx.html#VecAXPY_SeqKokkos">VecAXPY_SeqKokkos in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqcuda/veccuda2.cu.html#VecAXPY_SeqCUDA">VecAXPY_SeqCUDA in src/vec/vec/impls/seq/seqcuda/veccuda2.cu</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqhip/vechip2.hip.c.html#VecAXPY_SeqHIP">VecAXPY_SeqHIP in src/vec/vec/impls/seq/seqhip/vechip2.hip.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx.html#VecAXPY_SeqViennaCL">VecAXPY_SeqViennaCL in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx</A><BR>


---
[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](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
