# MatCreateScatter
Creates a new matrix of `MatType` `MATSCATTER`, based on a VecScatter 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatCreateScatter(MPI_Comm comm, VecScatter scatter, Mat *A)
```
Collective


## Input Parameters

- ***comm -*** MPI communicator
- ***scatter -*** a `VecScatter`



## Output Parameter

- ***A -*** the matrix




PETSc requires that matrices and vectors being used for certain
operations are partitioned accordingly.  For example, when
creating a scatter matrix, A, that supports parallel matrix-vector
products using `MatMult`(A,x,y) the user should set the number
of local matrix rows to be the number of local elements of the
corresponding result vector, y. Note that this is information is
required for use of the matrix interface routines, even though
the scatter matrix may not actually be physically partitioned.


## Developer Note
This directly accesses information inside the `VecScatter` associated with the matrix-vector product
for this matrix. This is not desirable..


## See Also
 `MatScatterSetVecScatter()`, `MatScatterGetVecScatter()`, `MATSCATTER`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/scatter/mscatter.c.html#MatCreateScatter">src/mat/impls/scatter/mscatter.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/impls/scatter/mscatter.c)


[Index of all Mat routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
