# 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 AIJ, using the routines MatCreateSeqAIJ() and MatCreateMPIAIJ() if you do not select a type in the options database.

### Synopsis

    #include "petscmat.h"
    PetscErrorCode PETSCMAT_DLLEXPORT MatSetFromOptions(Mat B)

Collective on Mat

### Input Parameter

A -the matrix

### Options Database Keys

| -mat_type seqaij | - AIJ type, uses MatCreateSeqAIJ()
| -mat_type mpiaij | - AIJ type, uses MatCreateMPIAIJ()
| -mat_type seqbdiag | - block diagonal type, uses MatCreateSeqBDiag()
| -mat_type mpibdiag | - block diagonal type, uses MatCreateMPIBDiag()
| -mat_type mpirowbs | - rowbs type, uses MatCreateMPIRowbs()
| -mat_type seqdense | - dense type, uses MatCreateSeqDense()
| -mat_type mpidense | - dense type, uses MatCreateMPIDense()
| -mat_type seqbaij | - block AIJ type, uses MatCreateSeqBAIJ()
| -mat_type mpibaij | - block AIJ type, uses MatCreateMPIBAIJ()

### Even More Options Database Keys

See the manpages for particular formats (e.g., MatCreateSeqAIJ()) for additional format-specific options.

### Keywords

matrix, create

### See Also

MatCreateSeqAIJ((), MatCreateMPIAIJ(),
MatCreateSeqBDiag(),MatCreateMPIBDiag(), MatCreateSeqDense(), MatCreateMPIDense(), MatCreateMPIRowbs(), MatCreateSeqBAIJ(), MatCreateMPIBAIJ(), MatCreateSeqSBAIJ(), MatCreateMPISBAIJ(), MatConvert()

Level:beginner
Location:src/mat/utils/gcreate.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/examples/tutorials/ex1.c.html
src/ksp/examples/tutorials/ex2.c.html
src/ksp/examples/tutorials/ex3.c.html
src/ksp/examples/tutorials/ex4.c.html
src/ksp/examples/tutorials/ex5.c.html
src/ksp/examples/tutorials/ex7.c.html
src/ksp/examples/tutorials/ex8.c.html
src/ksp/examples/tutorials/ex9.c.html
src/ksp/examples/tutorials/ex11.c.html
src/ksp/examples/tutorials/ex12.c.html
src/ksp/examples/tutorials/ex15.c.html