:orphan:
# MatAXPY
Computes Y = a*X + Y.
## Synopsis
```
#include "petscmat.h"
PetscErrorCode MatAXPY(Mat Y, PetscScalar a, Mat X, MatStructure str)
```
Logically Collective
## Input Parameters
- ***a -*** the scalar multiplier
- ***X -*** the first matrix
- ***Y -*** the second matrix
- ***str -*** either `SAME_NONZERO_PATTERN`, `DIFFERENT_NONZERO_PATTERN`, `UNKNOWN_NONZERO_PATTERN`, or `SUBSET_NONZERO_PATTERN` (nonzeros of `X` is a subset of `Y`'s)
## See Also
[](ch_matrices), `Mat`, `MatAYPX()`
## Level
intermediate
## Location
src/mat/utils/axpy.c
## Examples
src/ksp/ksp/tutorials/ex21.c
src/ksp/ksp/tutorials/ex29.c
src/ksp/ksp/tutorials/ex34.c
src/ksp/ksp/tutorials/ex76.c
src/ksp/ksp/tutorials/ex79.c
src/tao/pde_constrained/tutorials/hyperbolic.c
src/tao/tutorials/ex4.c
src/tao/unconstrained/tutorials/burgers_spectral.c
src/tao/unconstrained/tutorials/spectraladjointassimilation.c
src/ts/tutorials/ex50.c
## Implementations
MatAXPY_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c
MatAXPY_SeqAIJ in src/mat/impls/aij/seq/aij.c
MatAXPY_SeqAIJKokkos in src/mat/impls/aij/seq/kokkos/aijkok.kokkos.cxx
MatAXPY_SeqAIJCUSPARSE in src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu
MatAXPY_SeqAIJHIPSPARSE in src/mat/impls/aij/seq/seqhipsparse/aijhipsparse.hip.c
MatAXPY_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c
MatAXPY_SeqBAIJ in src/mat/impls/baij/seq/baij.c
MatAXPY_SeqBAIJMKL in src/mat/impls/baij/seq/baijmkl/baijmkl.c
MatAXPY_ConstantDiagonal in src/mat/impls/cdiagonal/cdiagonal.c
MatAXPY_MPIDense in src/mat/impls/dense/mpi/mpidense.c
MatAXPY_SeqDense in src/mat/impls/dense/seq/dense.c
MatAXPY_Elemental in src/mat/impls/elemental/matelem.cxx
MatAXPY_HYPRE in src/mat/impls/hypre/mhypre.c
MatAXPY_IS in src/mat/impls/is/matis.c
MatAXPY_Nest in src/mat/impls/nest/matnest.c
MatAXPY_MPISBAIJ in src/mat/impls/sbaij/mpi/mpisbaij.c
MatAXPY_SeqSBAIJ in src/mat/impls/sbaij/seq/sbaij.c
MatAXPY_ScaLAPACK in src/mat/impls/scalapack/matscalapack.c
MatAXPY_Shell in src/mat/impls/shell/shell.c
MatAXPY_HT in src/mat/impls/transpose/htransm.c
MatAXPY_Transpose in src/mat/impls/transpose/transm.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/utils/axpy.c)
[Index of all Mat routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)