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


## Input Parameters

- ***comm -*** must be an MPI communicator of size 1
- ***m   -*** number of rows
- ***n   -*** number of columns
- ***i   -*** row indices
- ***j   -*** column indices
- ***a   -*** matrix values
- ***nz  -*** number of nonzeros
- ***idx -*** if the i and j indices start with 1 use `PETSC_TRUE` otherwise use `PETSC_FALSE`



## Output Parameter

- ***mat -*** the matrix





## Example
For the following matrix, the input data expected is as shown (using 0 based indexing)
```none
        1 0 0
        2 0 3
        4 5 6

        i =  {0,1,1,2,2,2}
        j =  {0,0,2,0,1,2}
        v =  {1,2,3,4,5,6}
```


## Notes
Instead of using this function, users should also consider `MatSetPreallocationCOO()` and `MatSetValuesCOO()`, which allow repeated or remote entries,
and are particularly useful in iterative applications.


## See Also
 `MatCreate()`, `MatCreateAIJ()`, `MatCreateSeqAIJ()`, `MatCreateSeqAIJWithArrays()`, `MatMPIAIJSetPreallocationCSR()`, `MatSetValuesCOO()`, `MatSetPreallocationCOO()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aij.c.html#MatCreateSeqAIJFromTriple">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)  
