Skip to main content
`Ctrl`+`K`

# MatDiagonalGetInverseDiagonal

Get the inverse diagonal of a `MATDIAGONAL`

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatDiagonalGetInverseDiagonal(Mat A, Vec *inv_diag)

## Input Parameter

- A - the `MATDIAGONAL`

## Output Parameter

- inv_diag - the `Vec` that defines the inverse diagonal

## Note

The user must call `MatDiagonalRestoreInverseDiagonal()` before using the matrix again.

If a matrix is created only to call `MatSolve()` (which happens for `MATLMVMDIAGBROYDEN`), using `MatDiagonalGetInverseDiagonal()` and `MatDiagonalRestoreInverseDiagonal()` avoids copies and avoids any call to `VecReciprocal()`.

## See Also

Matrices, `MATDIAGONAL`, `MatCreateDiagonal()`, `MatDiagonalRestoreInverseDiagonal()`, `MatDiagonalGetDiagonal()`, `MATLMVMBROYDEN`, `MatSolve()`

## Level

developer

## Location

src/mat/impls/diagonal/diagonal.c

## Implementations

MatDiagonalGetInverseDiagonal_Diagonal() in src/mat/impls/diagonal/diagonal.c

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