Skip to main content
`Ctrl`+`K`

# 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

Matrices, `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValue()`, `MatGetValuesLocal()`, `MatGetValues()`

## Level

advanced

## Location

include/petscmat.h

## Examples

src/dm/impls/plex/tutorials/ex19.c
src/snes/tutorials/ex48.c
src/ts/tutorials/ex14.c

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