MatCreate

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().

Synopsis

#include "petscmat.h"  
int MatCreate(MPI_Comm comm,int m,int n,int M,int N,Mat *A)
Collective on MPI_Comm

Input Parameters

m - number of local rows (or PETSC_DECIDE)
n - number of local columns (or PETSC_DECIDE)
M - number of global rows (or PETSC_DETERMINE)
N - number of global columns (or PETSC_DETERMINE)
comm - MPI communicator

Output Parameter

A -the matrix

Basic Options Database Keys

These options use MatCreateSeqXXX or MatCreateMPIXXX, depending on the communicator, comm.
-mat_aij - AIJ type
-mat_baij - block AIJ type
-mat_dense - dense type
-mat_bdiag - block diagonal type

More Options Database Keys

-mat_seqaij - AIJ type, uses MatCreateSeqAIJ()
-mat_mpiaij - AIJ type, uses MatCreateMPIAIJ()
-mat_seqbdiag - block diagonal type, uses MatCreateSeqBDiag()
-mat_mpibdiag - block diagonal type, uses MatCreateMPIBDiag()
-mat_mpirowbs - rowbs type, uses MatCreateMPIRowbs()
-mat_seqdense - dense type, uses MatCreateSeqDense()
-mat_mpidense - dense type, uses MatCreateMPIDense()
-mat_seqbaij - block AIJ type, uses MatCreateSeqBAIJ()
-mat_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.

Notes

If PETSC_DECIDE is not used for the arguments 'm' and 'n', then the user must ensure that they are chosen to be compatible with the vectors. To do this, one first considers the matrix-vector product 'y = A x'. The 'm' that is used in the above routine must match the local size used in the vector creation routine VecCreateMPI() for 'y'. Likewise, the 'n' used must match that used as the local size in VecCreateMPI() for 'x'.

This routine calls MatGetTypeFromOptions() to determine the matrix type.

Keywords

matrix, create

See Also

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

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/sles/examples/tutorials/ex1.c
src/sles/examples/tutorials/ex2.c
src/sles/examples/tutorials/ex3.c
src/sles/examples/tutorials/ex4.c
src/sles/examples/tutorials/ex5.c
src/sles/examples/tutorials/ex7.c
src/sles/examples/tutorials/ex8.c
src/sles/examples/tutorials/ex9.c
src/sles/examples/tutorials/ex11.c
src/sles/examples/tutorials/ex12.c
src/sles/examples/tutorials/ex14.c