# MatCompositeSetMergeType
Sets order of `MatCompositeMerge()`. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatCompositeSetMergeType(Mat mat, MatCompositeMergeType type)
```
Logically Collective


## Input Parameters

- ***mat -*** the composite matrix
- ***type -*** `MAT_COMPOSITE_MERGE RIGHT` (default) to start merge from right with the first added matrix (mat[0]),
`MAT_COMPOSITE_MERGE_LEFT` to start merge from left with the last added matrix (mat[nmat-1])





## Note
The resulting matrix is the same regardless of the `MatCompositeMergeType`. Only the order of operation is changed.
If set to `MAT_COMPOSITE_MERGE_RIGHT` the order of the merge is mat[nmat-1]*(mat[nmat-2]*(...*(mat[1]*mat[0])))
otherwise the order is (((mat[nmat-1]*mat[nmat-2])*mat[nmat-3])*...)*mat[0].


## See Also
 `MatCreateComposite()`, `MatCompositeMerge()`, `MATCOMPOSITE`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/composite/mcomposite.c.html#MatCompositeSetMergeType">src/mat/impls/composite/mcomposite.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex9.c.html">src/mat/tutorials/ex9.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/composite/mcomposite.c.html#MatCompositeSetMergeType_Composite">MatCompositeSetMergeType_Composite in src/mat/impls/composite/mcomposite.c</A><BR>


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