petsc-3.7.1 2016-05-15
Report Typos and Errors

# MatCreate

Creates a matrix where the type is determined from either a call to MatSetType() or from the options database with a call to MatSetFromOptions(). The default matrix type is AIJ, using the routines MatCreateSeqAIJ() or MatCreateAIJ() if you do not set a type in the options database. If you never call MatSetType() or MatSetFromOptions() it will generate an error when you try to use the matrix.

### Synopsis

    #include "petscmat.h"
    PetscErrorCode  MatCreate(MPI_Comm comm,Mat *A)

Collective on MPI_Comm Many br

### Input Parameter

comm -MPI communicator Many br

### Output Parameter

A -the matrix Many br

### Options Database Keys

| -mat_type seqaij | - AIJ type, uses MatCreateSeqAIJ() Many br
| -mat_type mpiaij | - AIJ type, uses MatCreateAIJ() Many br
| -mat_type seqdense | - dense type, uses MatCreateSeqDense() Many br
| -mat_type mpidense | - dense type, uses MatCreateDense() Many br
| -mat_type seqbaij | - block AIJ type, uses MatCreateSeqBAIJ() Many br
| -mat_type mpibaij | - block AIJ type, uses MatCreateBAIJ() Many br

### Even More Options Database Keys

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

### Notes

Many br

### User manual sections

| Section 3.1 Creating and Assembling Matrices | - - Chapter 3 Matrices Many br

### Keywords

matrix, create

### See Also

MatCreateSeqAIJ(), MatCreateAIJ(),
MatCreateSeqDense(), MatCreateDense(), Many brMatCreateSeqBAIJ(), MatCreateBAIJ(), Many brMatCreateSeqSBAIJ(), MatCreateSBAIJ(), Many brMatConvert() Many br

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/mat/examples/tutorials/ex1.c.html
src/mat/examples/tutorials/ex2.c.html
src/mat/examples/tutorials/ex4.c.html
src/mat/examples/tutorials/ex5.c.html
src/mat/examples/tutorials/ex8.c.html
src/mat/examples/tutorials/ex9.c.html
src/mat/examples/tutorials/ex10.c.html
src/mat/examples/tutorials/ex12.c.html
src/mat/examples/tutorials/ex15.c.html
src/mat/examples/tutorials/ex16.c.html
src/mat/examples/tutorials/ex17.c.html