:orphan: # MatMPIAIJGetLocalMat Creates a `MATSEQAIJ` from a `MATMPIAIJ` matrix by taking all its local rows and putting them into a sequential matrix with mlocal rows and n columns. Where mlocal is the row count obtained with `MatGetLocalSize()` and n is the global column count obtained with `MatGetSize()` ## Synopsis ``` #include "petscmat.h" PetscErrorCode MatMPIAIJGetLocalMat(Mat A, MatReuse scall, Mat *A_loc) ``` Not Collective ## Input Parameters - ***A -*** the matrix - ***scall -*** either `MAT_INITIAL_MATRIX` or `MAT_REUSE_MATRIX` ## Output Parameter - ***A_loc -*** the local sequential matrix generated ## Notes In other words combines the two parts of a parallel `MATMPIAIJ` matrix on each process to a single matrix. When the communicator associated with `A` has size 1 and `MAT_INITIAL_MATRIX` is requested, the matrix returned is the diagonal part of `A`. If `MAT_REUSE_MATRIX` is requested with comm size 1, `MatCopy`(Adiag,*`A_loc`,`SAME_NONZERO_PATTERN`) is called. This means that one can preallocate the proper sequential matrix first and then call this routine with `MAT_REUSE_MATRIX` to safely modify the values of the returned `A_loc`. ## See Also [](ch_matrices), `Mat`, `MATMPIAIJ`, `MatGetOwnershipRange()`, `MatMPIAIJGetLocalMatCondensed()`, `MatMPIAIJGetLocalMatMerge()` ## Level developer ## Location src/mat/impls/aij/mpi/mpiaij.c --- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/impls/aij/mpi/mpiaij.c) [Index of all Mat routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)