MatSetSizes#

Sets the local and global sizes, and checks to determine compatibility

Synopsis#

#include "petscmat.h"  
PetscErrorCode MatSetSizes(Mat A, PetscInt m, PetscInt n, PetscInt M, PetscInt N)

Collective

Input Parameters#

Notes#

m (n) and M (N) cannot be both PETSC_DECIDE If one processor calls this with M (N) of PETSC_DECIDE then all processors must, otherwise the program will hang.

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’.

You cannot change the sizes once they have been set.

The sizes must be set before MatSetUp() or MatXXXSetPreallocation() is called.

See Also#

Matrices, Mat, MatGetSize(), PetscSplitOwnership()

Level#

beginner

Location#

src/mat/utils/gcreate.c

Examples#

src/ts/tutorials/ex16fwd.c
src/ts/tutorials/ex40.c
src/ts/tutorials/ex20td.c
src/ts/tutorials/ex36A.c
src/ts/tutorials/ex36.c
src/ts/tutorials/ex20fwd.c
src/ts/tutorials/ex21.c
src/ts/tutorials/ex49.c
src/ts/tutorials/ex5.c
src/ts/tutorials/ex20opt_ic.c


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