:orphan:
# MatCompositeMerge
Given a composite matrix, replaces it with a "regular" matrix by summing or computing the product of all the matrices inside the composite matrix.
## Synopsis
```
#include "petscmat.h"
PetscErrorCode MatCompositeMerge(Mat mat)
```
Collective
## Input Parameter
- ***mat -*** the composite matrix
## Options Database Keys
- ***-mat_composite_merge -*** merge in `MatAssemblyEnd()`
- ***-mat_composite_merge_type -*** set merge direction
## Note
The `MatType` of the resulting matrix will be the same as the `MatType` of the FIRST matrix in the composite matrix.
## See Also
[](ch_matrices), `Mat`, `MatDestroy()`, `MatMult()`, `MatCompositeAddMat()`, `MatCreateComposite()`, `MatCompositeSetMatStructure()`, `MatCompositeSetMergeType()`, `MATCOMPOSITE`
## Level
advanced
## Location
src/mat/impls/composite/mcomposite.c
## Examples
src/mat/tutorials/ex9.c
## Implementations
MatCompositeMerge_Composite in src/mat/impls/composite/mcomposite.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/impls/composite/mcomposite.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)