:orphan: # MatRegister - Adds a new matrix type implementation ## Synopsis ``` #include "petscmat.h" PetscErrorCode MatRegister(const char sname[], PetscErrorCode (*function)(Mat)) ``` Not Collective ## Input Parameters - ***sname -*** name of a new user-defined matrix type - ***function -*** routine to create method context ## Note `MatRegister()` may be called multiple times to add several user-defined solvers. ## Sample usage ```none MatRegister("my_mat", MyMatCreate); ``` Then, your solver can be chosen with the procedural interface via ```none MatSetType(Mat, "my_mat") ``` or at runtime via the option ```none -mat_type my_mat ``` ## See Also [](ch_matrices), `Mat`, `MatType`, `MatSetType()`, `MatRegisterAll()` ## Level advanced ## Location src/mat/interface/matreg.c --- [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](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)