# MatGetGhosts
Get the global indices of all ghost nodes defined by the sparse matrix 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatGetGhosts(Mat mat, PetscInt *nghosts, const PetscInt *ghosts[])
```
Collective


## Input Parameter

- ***mat -*** the matrix



## Output Parameters

- ***nghosts -*** number of ghosts (note for `MATBAIJ` and `MATSBAIJ` matrices there is one ghost for each block)
- ***ghosts -*** the global indices of the ghost points





## Note
`nghosts` and `ghosts` are suitable to pass into `VecCreateGhost()`


## See Also
 `Mat`, `VecCreateGhost()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/interface/matrix.c.html#MatGetGhosts">src/mat/interface/matrix.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/mpiaij.c.html#MatGetGhosts_MPIAIJ">MatGetGhosts_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/baij/mpi/mpibaij.c.html#MatGetGhosts_MPIBAIJ">MatGetGhosts_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sell/mpi/mpisell.c.html#MatGetGhosts_MPISELL">MatGetGhosts_MPISELL in src/mat/impls/sell/mpi/mpisell.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matrix.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)  
