:orphan:
# MatGetValue
Gets a single value from a matrix 
## Synopsis
```
static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va)
```
Not Collective; can only return a value owned by the given process


## Input Parameters

- ***mat -*** the matrix
- ***row -*** the row location of the entry
- ***col -*** the column location of the entry



## Output Parameter

- ***va -*** the value





## Notes
The matrix must have been assembled with `MatAssemblyBegin()` and `MatAssemblyEnd` before this call

For efficiency one should use `MatGetValues()` and get several values simultaneously.

See notes for `MatGetValues()`.


## See Also
 [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd`, `MatSetValue()`, `MatGetValueLocal()`, `MatGetValues()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscmat.h.html#MatGetValue">include/petscmat.h</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex48.c.html">src/snes/tutorials/ex48.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex14.c.html">src/ts/tutorials/ex14.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscmat.h)


[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)  
