# MatSetValuesBatch
Adds (`ADD_VALUES`) many blocks of values into a matrix at once. The blocks must all be square and the same size. Currently, this can only be called once and creates the given matrix. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatSetValuesBatch(Mat mat, PetscInt nb, PetscInt bs, PetscInt rows[], const PetscScalar v[])
```
Not Collective


## Input Parameters

- ***mat -*** the matrix
- ***nb -*** the number of blocks
- ***bs -*** the number of rows (and columns) in each block
- ***rows -*** a concatenation of the rows for each block
- ***v -*** a concatenation of logically two-dimensional arrays of values



## Note
`MatSetPreallocationCOO()` and `MatSetValuesCOO()` may be a better way to provide the values

In the future, we will extend this routine to handle rectangular blocks, and to allow multiple calls for a given matrix.




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

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/interface/matrix.c.html#MatSetValuesBatch">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)  
