Skip to main content
`Ctrl`+`K`

# MatCreateFromOptions

Creates a matrix whose type is set from the options database

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatCreateFromOptions(MPI_Comm comm, const char *prefix, PetscInt bs, PetscInt m, PetscInt n, PetscInt M, PetscInt N, Mat *A)

Collective

## Input Parameters

- comm - MPI communicator

- prefix - [optional] prefix for the options database

- bs - the blocksize (commonly 1)

- m - the local number of rows (or `PETSC_DECIDE`)

- n - the local number of columns (or `PETSC_DECIDE` or `PETSC_DETERMINE`)

- M - the global number of rows (or `PETSC_DETERMINE`)

- N - the global number of columns (or `PETSC_DETERMINE`)

## Output Parameter

- A - the matrix

## Options Database Key

- -mat_type - see `MatType`, for example `aij`, `aijcusparse`, `baij`, `sbaij`, `dense`, defaults to `aij`

## See Also

Matrices, `Mat`, `MatCreateSeqAIJ()`, `MatCreateAIJ()`, `MatCreateSeqDense()`, `MatCreateDense()`, `MatCreateSeqBAIJ()`, `MatCreateBAIJ()`, `MatCreateSeqSBAIJ()`, `MatCreateSBAIJ()`, `MatConvert()`, `MatCreate()`

## Level

beginner

## Location

src/mat/utils/gcreate.c

## Examples

src/ksp/ksp/tutorials/ex27.c
src/ksp/ksp/tutorials/ex14f.F90

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages