# MatSetValuesLocal

Inserts or adds values into certain locations of a matrix, using a local ordering of the nodes.

### Synopsis

    #include "petscmat.h"
    PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesLocal(Mat mat,PetscInt nrow,const PetscInt irow[],PetscInt ncol,const PetscInt icol[],const PetscScalar y[],InsertMode addv)

Not Collective

### Input Parameters

| x | - the matrix
| nrow, irow | - number of rows and their local indices
| ncol, icol | - number of columns and their local indices
| y | - a logically two-dimensional array of values
| addv | - either INSERT_VALUES or ADD_VALUES, where ADD_VALUES adds values to any existing entries, and INSERT_VALUES replaces existing entries with new values

### Notes

Before calling MatSetValuesLocal(), the user must first set the local-to-global mapping by calling MatSetLocalToGlobalMapping().

Calls to MatSetValuesLocal() with the INSERT_VALUES and ADD_VALUES options cannot be mixed without intervening calls to the assembly routines.

These values may be cached, so MatAssemblyBegin() and MatAssemblyEnd() MUST be called after all calls to MatSetValuesLocal() have been completed.

### See Also

MatAssemblyBegin(), MatAssemblyEnd(), MatSetValues(), MatSetLocalToGlobalMapping(),
MatSetValueLocal()

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/snes/examples/tutorials/ex5.c.html
src/snes/examples/tutorials/ex14.c.html
src/snes/examples/tutorials/ex26.c.html
src/snes/examples/tutorials/ex5f.F.html
src/snes/examples/tutorials/ex5f90.F.html
src/ts/examples/tutorials/ex2.c.html
src/ts/examples/tutorials/ex4.c.html
src/ts/examples/tutorials/ex2f.F.html