petsc-3.7.1 2016-05-15
Report Typos and Errors

# MatGetDiagonal

Gets the diagonal of a matrix.

### Synopsis

    #include "petscmat.h"
    PetscErrorCode MatGetDiagonal(Mat mat,Vec v)

Logically Collective on Mat and Vec Many br

### Input Parameters

| mat | - the matrix Many br
| v | - the vector for storing the diagonal Many br

### Output Parameter

v -the diagonal of the matrix Many br

Many br

### Note

Currently only correct in parallel for square matrices. Many br

### See Also

MatGetRow(), MatGetSubMatrices(), MatGetSubmatrix(), MatGetRowMaxAbs()

Level:intermediate
Location:src/mat/interface/matrix.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/pc/examples/tutorials/ex1.c.html
src/ksp/pc/examples/tutorials/ex2.c.html
src/ksp/ksp/examples/tutorials/ex15.c.html
src/ksp/ksp/examples/tutorials/ex52.c.html
src/ksp/ksp/examples/tutorials/ex15f.F.html
src/snes/examples/tutorials/ex70.c.html