**petsc-3.6.1 2015-07-22**

# MatDiagonalSet

Computes Y = Y + D, where D is a diagonal matrix that is represented as a vector. Or Y[i,i] = D[i] if InsertMode is INSERT_VALUES.
### Synopsis

#include "petscmat.h"
PetscErrorCode MatDiagonalSet(Mat Y,Vec D,InsertMode is)

### Input Parameters

Neighbor-wise Collective on Mat and Vec

### Keywords

matrix, add, shift, diagonal

### See Also

MatShift()

**Level:**intermediate

Location:src/mat/utils/axpy.c

Index of all Mat routines

Table of Contents for all manual pages

Index of all manual pages

### Examples

src/tao/pde_constrained/examples/tutorials/elliptic.c.html