Skip to main content
`Ctrl`+`K`

# MatSetUp

Sets up the internal matrix data structures for later use by the matrix

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatSetUp(Mat A)

Collective

## Input Parameter

- A - the matrix

## Notes

If the user has not set preallocation for this matrix then an efficient algorithm will be used for the first round of setting values in the matrix.

This routine is called internally by other `Mat` functions when needed so rarely needs to be called by users

## See Also

Matrices, `Mat`, `MatMult()`, `MatCreate()`, `MatDestroy()`, `MatXAIJSetPreallocation()`

## Level

advanced

## Location

src/mat/interface/matrix.c

## Examples

src/ksp/ksp/tutorials/ex12.c
src/ksp/ksp/tutorials/ex18.c
src/ksp/ksp/tutorials/ex19.c
src/ksp/ksp/tutorials/ex23.c
src/ksp/ksp/tutorials/ex16.c
src/ksp/ksp/tutorials/ex51.c
src/ksp/ksp/tutorials/ex15.c
src/ksp/ksp/tutorials/ex11.c
src/ksp/ksp/tutorials/ex100.c
src/ksp/ksp/tutorials/ex1.c

## Implementations

MatSetUp_HYPREStruct() in src/dm/impls/da/hypre/mhyp.c
MatSetUp_HYPRESStruct() in src/dm/impls/da/hypre/mhyp.c
MatSetUp_MPIDense() in src/mat/impls/dense/mpi/mpidense.c
MatSetUp_SeqDense() in src/mat/impls/dense/seq/dense.c
MatSetUp_Diagonal() in src/mat/impls/diagonal/diagonal.c
MatSetUp_Elemental() in src/mat/impls/elemental/matelem.cxx
MatSetUp_HYPRE() in src/mat/impls/hypre/mhypre.c
MatSetUp_IS() in src/mat/impls/is/matis.c
MatSetUp_KAIJ() in src/mat/impls/kaij/kaij.c
MatSetUp_LRC() in src/mat/impls/lrc/lrc.c
MatSetUp_MAIJ() in src/mat/impls/maij/maij.c
MatSetUp_Preallocator() in src/mat/impls/preallocator/matpreallocator.c
MatSetUp_ScaLAPACK() in src/mat/impls/scalapack/matscalapack.c
MatSetUp_MPISELL() in src/mat/impls/sell/mpi/mpisell.c
MatSetUp_SeqSELL() in src/mat/impls/sell/seq/sell.c

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