Skip to main content
`Ctrl`+`K`

# MatDiagonalSetDiagonal

Sets the diagonal for a `MATDIAGONAL`

## Synopsis

    #include "petscmat.h"
    #include "petscvec.h"
    PetscErrorCode MatDiagonalSetDiagonal(Mat J, Vec diag)

Collective

## Input Parameter

- J - the `MATDIAGONAL` matrix

- diag - the vector for the diagonal

## Notes

The input vector `diag` will be referenced internally: any changes to `diag` will affect the matrix `J`.

This routine can only be called once for the given `J` matrix.

## See Also

Matrices, `Mat`, `MatDestroy()`, `MatCreateDiagonal()`, `MATDIAGONAL`, `MatScale()`, `MatShift()`, `MatMult()`, `MatGetDiagonal()`, `MatSolve()`, `MatDiagonalRestoreInverseDiagonal()`, `MatDiagonalGetDiagonal()`, `MatDiagonalRestoreDiagonal()`, `MatDiagonalGetInverseDiagonal()`, `MATCONSTANTDIAGONAL`

## Level

advanced

## Location

src/mat/impls/diagonal/diagonal.c

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