# MatSetValuesIS
Inserts or adds a block of values into a matrix using an `IS` to indicate the rows and columns These values may be cached, so `MatAssemblyBegin()` and `MatAssemblyEnd()` MUST be called after all calls to `MatSetValues()` have been completed. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatSetValuesIS(Mat mat, IS ism, IS isn, const PetscScalar v[], InsertMode addv)
```
Not Collective


## Input Parameters

- ***mat -*** the matrix
- ***v -*** a logically two-dimensional array of values
- ***ism -*** the rows to provide
- ***isn -*** the columns to provide
- ***addv -*** either `ADD_VALUES` to add values to any existing entries, or `INSERT_VALUES` to replace existing entries with new values





## Notes
If you create the matrix yourself (that is not with a call to `DMCreateMatrix()`) then you MUST call MatXXXXSetPreallocation() or
`MatSetUp()` before using this routine

By default the values, v, are row-oriented. See `MatSetOption()` for other options.

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

`MatSetValues()` uses 0-based row and column numbers in Fortran
as well as in C.

Negative indices may be passed in ism and isn, these rows and columns are
simply ignored. This allows easily inserting element stiffness matrices
with homogeneous Dirchlet boundary conditions that you don't want represented
in the matrix.


## Efficiency Alert
The routine `MatSetValuesBlocked()` may offer much better efficiency
for users of block sparse formats (`MATSEQBAIJ` and `MATMPIBAIJ`).

This is currently not optimized for any particular `ISType`


## Developer Notes
This is labeled with C so does not automatically generate Fortran stubs and interfaces
because it requires multiple Fortran interfaces depending on which arguments are scalar or arrays.


## See Also
 `MatSetOption()`, `MatSetValues()`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValuesBlocked()`, `MatSetValuesLocal()`,
`InsertMode`, `INSERT_VALUES`, `ADD_VALUES`, `MatSetValues()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/interface/matrix.c.html#MatSetValuesIS">src/mat/interface/matrix.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matrix.c)


[Index of all Mat routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
