# MatMultAdd
Computes v3 = v2 + A * v1. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatMultAdd(Mat mat, Vec v1, Vec v2, Vec v3)
```
Neighbor-wise Collective


## Input Parameters

- ***mat -*** the matrix
- ***v1, v2 -*** the vectors



## Output Parameters

- ***v3 -*** the result





## Note
The vectors `v1` and `v3` cannot be the same.  I.e., one cannot
call `MatMultAdd`(A,v1,v2,v1).


## See Also
 `Mat`, `MatMultTranspose()`, `MatMult()`, `MatMultTransposeAdd()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/interface/matrix.c.html#MatMultAdd">src/mat/interface/matrix.c</A>

## Examples
<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/ksp/ksp/tutorials/ex74.c.html">src/ksp/ksp/tutorials/ex74.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex70.c.html">src/snes/tutorials/ex70.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex73f90t.F90.html">src/snes/tutorials/ex73f90t.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex50.c.html">src/ts/tutorials/ex50.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/burgers_spectral.c.html">src/tao/unconstrained/tutorials/burgers_spectral.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/kokkos/mpiaijkok.kokkos.cxx.html#MatMultAdd_MPIAIJKokkos">MatMultAdd_MPIAIJKokkos in src/mat/impls/aij/mpi/kokkos/mpiaijkok.kokkos.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/mpiaij.c.html#MatMultAdd_MPIAIJ">MatMultAdd_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/mpicusparse/mpiaijcusparse.cu.html#MatMultAdd_MPIAIJCUSPARSE">MatMultAdd_MPIAIJCUSPARSE in src/mat/impls/aij/mpi/mpicusparse/mpiaijcusparse.cu</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/mpihipsparse/mpiaijhipsparse.hip.c.html#MatMultAdd_MPIAIJHIPSPARSE">MatMultAdd_MPIAIJHIPSPARSE in src/mat/impls/aij/mpi/mpihipsparse/mpiaijhipsparse.hip.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aij.c.html#MatMultAdd_SeqAIJ">MatMultAdd_SeqAIJ in src/mat/impls/aij/seq/aij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aijmkl/aijmkl.c.html#MatMultAdd_SeqAIJMKL">MatMultAdd_SeqAIJMKL in src/mat/impls/aij/seq/aijmkl/aijmkl.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aijperm/aijperm.c.html#MatMultAdd_SeqAIJPERM">MatMultAdd_SeqAIJPERM in src/mat/impls/aij/seq/aijperm/aijperm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aijsell/aijsell.c.html#MatMultAdd_SeqAIJSELL">MatMultAdd_SeqAIJSELL in src/mat/impls/aij/seq/aijsell/aijsell.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/kokkos/aijkok.kokkos.cxx.html#MatMultAdd_SeqAIJKokkos">MatMultAdd_SeqAIJKokkos in src/mat/impls/aij/seq/kokkos/aijkok.kokkos.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu.html#MatMultAdd_SeqAIJCUSPARSE">MatMultAdd_SeqAIJCUSPARSE in src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/seqhipsparse/aijhipsparse.hip.c.html#MatMultAdd_SeqAIJHIPSPARSE">MatMultAdd_SeqAIJHIPSPARSE in src/mat/impls/aij/seq/seqhipsparse/aijhipsparse.hip.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/seqviennacl/aijviennacl.cxx.html#MatMultAdd_SeqAIJViennaCL">MatMultAdd_SeqAIJViennaCL in src/mat/impls/aij/seq/seqviennacl/aijviennacl.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/baij/mpi/mpibaij.c.html#MatMultAdd_MPIBAIJ">MatMultAdd_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/blockmat/seq/blockmat.c.html#MatMultAdd_BlockMat">MatMultAdd_BlockMat in src/mat/impls/blockmat/seq/blockmat.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/cdiagonal/cdiagonal.c.html#MatMultAdd_ConstantDiagonal">MatMultAdd_ConstantDiagonal in src/mat/impls/cdiagonal/cdiagonal.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/composite/mcomposite.c.html#MatMultAdd_Composite">MatMultAdd_Composite in src/mat/impls/composite/mcomposite.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/dense/mpi/mpidense.c.html#MatMultAdd_MPIDense">MatMultAdd_MPIDense in src/mat/impls/dense/mpi/mpidense.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/dense/seq/cuda/densecuda.cu.html#MatMultAdd_SeqDenseCUDA">MatMultAdd_SeqDenseCUDA in src/mat/impls/dense/seq/cuda/densecuda.cu</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/dense/seq/dense.c.html#MatMultAdd_SeqDense">MatMultAdd_SeqDense in src/mat/impls/dense/seq/dense.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/dense/seq/hip/densehip.hip.c.html#MatMultAdd_SeqDenseHIP">MatMultAdd_SeqDenseHIP in src/mat/impls/dense/seq/hip/densehip.hip.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/elemental/matelem.cxx.html#MatMultAdd_Elemental">MatMultAdd_Elemental in src/mat/impls/elemental/matelem.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/h2opus/cuda/math2opus.cu.html#MatMultAdd_H2OPUS">MatMultAdd_H2OPUS in src/mat/impls/h2opus/cuda/math2opus.cu</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/htool/htool.cxx.html#MatMultAdd_Htool">MatMultAdd_Htool in src/mat/impls/htool/htool.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/hypre/mhypre.c.html#MatMultAdd_HYPRE">MatMultAdd_HYPRE in src/mat/impls/hypre/mhypre.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/is/matis.c.html#MatMultAdd_IS">MatMultAdd_IS in src/mat/impls/is/matis.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/kaij/kaij.c.html#MatMultAdd_SeqKAIJ">MatMultAdd_SeqKAIJ in src/mat/impls/kaij/kaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/kaij/kaij.c.html#MatMultAdd_MPIKAIJ">MatMultAdd_MPIKAIJ in src/mat/impls/kaij/kaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/nest/matnest.c.html#MatMultAdd_Nest">MatMultAdd_Nest in src/mat/impls/nest/matnest.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/normal/normm.c.html#MatMultAdd_Normal">MatMultAdd_Normal in src/mat/impls/normal/normm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sbaij/mpi/mpisbaij.c.html#MatMultAdd_MPISBAIJ">MatMultAdd_MPISBAIJ in src/mat/impls/sbaij/mpi/mpisbaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/scalapack/matscalapack.c.html#MatMultAdd_ScaLAPACK">MatMultAdd_ScaLAPACK in src/mat/impls/scalapack/matscalapack.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/scatter/mscatter.c.html#MatMultAdd_Scatter">MatMultAdd_Scatter in src/mat/impls/scatter/mscatter.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sell/mpi/mpisell.c.html#MatMultAdd_MPISELL">MatMultAdd_MPISELL in src/mat/impls/sell/mpi/mpisell.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sell/seq/sell.c.html#MatMultAdd_SeqSELL">MatMultAdd_SeqSELL in src/mat/impls/sell/seq/sell.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/shell/shell.c.html#MatMultAdd_Shell">MatMultAdd_Shell in src/mat/impls/shell/shell.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/submat/submat.c.html#MatMultAdd_SubMatrix">MatMultAdd_SubMatrix in src/mat/impls/submat/submat.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/transpose/htransm.c.html#MatMultAdd_HT">MatMultAdd_HT in src/mat/impls/transpose/htransm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/transpose/transm.c.html#MatMultAdd_Transpose">MatMultAdd_Transpose in src/mat/impls/transpose/transm.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matrix.c)


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