:orphan: # MatSetFromOptions Creates a matrix where the type is determined from the options database. Generates a parallel MPI matrix if the communicator has more than one processor. The default matrix type is `MATAIJ`, using the routines `MatCreateSeqAIJ()` and `MatCreateAIJ()` if you do not select a type in the options database. ## Synopsis ``` #include "petscmat.h" PetscErrorCode MatSetFromOptions(Mat B) ``` Collective ## Input Parameter - ***A -*** the matrix ## Options Database Keys - ***-mat_type seqaij -*** `MATSEQAIJ` type, uses `MatCreateSeqAIJ()` - ***-mat_type mpiaij -*** `MATMPIAIJ` type, uses `MatCreateAIJ()` - ***-mat_type seqdense -*** `MATSEQDENSE` type, uses `MatCreateSeqDense()` - ***-mat_type mpidense -*** `MATMPIDENSE`, uses `MatCreateDense()` - ***-mat_type seqbaij -*** `MATSEQBAIJ`, uses `MatCreateSeqBAIJ()` - ***-mat_type mpibaij -*** `MATMPIBAIJ`, uses `MatCreateBAIJ()` See the manpages for particular formats (e.g., `MATSEQAIJ`) for additional format-specific options. ## See Also [](ch_matrices), `Mat`, `MatCreateSeqAIJ()`, `MatCreateAIJ()`, `MatCreateSeqDense()`, `MatCreateDense()`, `MatCreateSeqBAIJ()`, `MatCreateBAIJ()`, `MatCreateSeqSBAIJ()`, `MatCreateSBAIJ()`, `MatConvert()` ## Level beginner ## Location src/mat/utils/gcreate.c ## Examples src/ksp/ksp/tutorials/bench_kspsolve.c
src/ksp/ksp/tutorials/ex1.c
src/ksp/ksp/tutorials/ex10.c
src/ksp/ksp/tutorials/ex11.c
src/ksp/ksp/tutorials/ex11f.F90
src/ksp/ksp/tutorials/ex12.c
src/ksp/ksp/tutorials/ex15.c
src/ksp/ksp/tutorials/ex15f.F90
src/ksp/ksp/tutorials/ex16.c
src/ksp/ksp/tutorials/ex18.c
src/ksp/ksp/tutorials/ex19.c
## Implementations MatSetFromOptions_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c
MatSetFromOptions_MPIAIJCUSPARSE in src/mat/impls/aij/mpi/mpicusparse/mpiaijcusparse.cu
MatSetFromOptions_MPIAIJHIPSPARSE in src/mat/impls/aij/mpi/mpihipsparse/mpiaijhipsparse.hip.c
MatSetFromOptions_MUMPS in src/mat/impls/aij/mpi/mumps/mumps.c
MatSetFromOptions_SeqAIJCUSPARSE in src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu
MatSetFromOptions_SeqAIJHIPSPARSE in src/mat/impls/aij/seq/seqhipsparse/aijhipsparse.hip.c
MatSetFromOptions_Composite in src/mat/impls/composite/mcomposite.c
MatSetFromOptions_H2OPUS in src/mat/impls/h2opus/cuda/math2opus.cu
MatSetFromOptions_Htool in src/mat/impls/htool/htool.cxx
MatSetFromOptions_IS in src/mat/impls/is/matis.c
MatSetFromOptions_MFFD in src/mat/impls/mffd/mffd.c
MatSetFromOptions_MPISELL in src/mat/impls/sell/mpi/mpisell.c
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/utils/gcreate.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)