# MatSetType
Builds matrix object for a particular matrix type 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatSetType(Mat mat, MatType matype)
```
Collective on mat


## Input Parameters

- ***mat      -*** the matrix object
- ***matype   -*** matrix type



## Options Database Key

- ***-mat_type  <method> -*** Sets the type; use -help for a list
of available methods (for instance, seqaij)



## Note
See "${PETSC_DIR}/include/petscmat.h" for available methods




## See Also
 `PCSetType()`, `VecSetType()`, `MatCreate()`, `MatType`, `Mat`

## Level
intermediate

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex1.c.html">src/mat/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex10.c.html">src/mat/tutorials/ex10.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex12.c.html">src/mat/tutorials/ex12.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/ex5k.kokkos.cxx.html">src/mat/tutorials/ex5k.kokkos.cxx.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex8.c.html">src/mat/tutorials/ex8.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex100.c.html">src/ksp/ksp/tutorials/ex100.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex100f.F90.html">src/ksp/ksp/tutorials/ex100f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex15f.F90.html">src/ksp/ksp/tutorials/ex15f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex27.c.html">src/ksp/ksp/tutorials/ex27.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex52f.F90.html">src/ksp/ksp/tutorials/ex52f.F90.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matreg.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)  
