# MatCreateSeqAIJWithArrays
Creates an sequential `MATSEQAIJ` matrix using matrix elements (in CSR format) provided by the user. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm comm, PetscInt m, PetscInt n, PetscInt i[], PetscInt j[], PetscScalar a[], Mat *mat)
```
Collective


## Input Parameters

- ***comm -*** must be an MPI communicator of size 1
- ***m -*** number of rows
- ***n -*** number of columns
- ***i -*** row indices; that is i[0] = 0, i[row] = i[row-1] + number of elements in that row of the matrix
- ***j -*** column indices
- ***a -*** matrix values



## Output Parameter

- ***mat -*** the matrix





## Notes
The i, j, and a arrays are not copied by this routine, the user must free these arrays
once the matrix is destroyed and not before

You cannot set new nonzero locations into this matrix, that will generate an error.

The i and j indices are 0 based

The format which is used for the sparse matrix input, is equivalent to a
row-major ordering.. i.e for the following matrix, the input data expected is
as shown

```none
1 0 0
```
```none
2 0 3
```
```none
4 5 6
```
```none
```
```none
i =  {0,1,3,6}  [size = nrow+1  = 3+1]
```
```none
j =  {0,0,2,0,1,2}  [size = 6]; values must be sorted for each row
```
```none
v =  {1,2,3,4,5,6}  [size = 6]
```


## See Also
 `MatCreate()`, `MatCreateAIJ()`, `MatCreateSeqAIJ()`, `MatCreateMPIAIJWithArrays()`, `MatMPIAIJSetPreallocationCSR()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aij.c.html#MatCreateSeqAIJWithArrays">src/mat/impls/aij/seq/aij.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex83f.F90.html">src/ksp/ksp/tutorials/ex83f.F90.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/impls/aij/seq/aij.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)  
