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
andj
indices start with 1 usePETSC_TRUE
otherwise usePETSC_FALSE
Output Parameter#
mat - the matrix
Example#
For the following matrix, the input data expected is as shown (using 0 based indexing)
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}
Note#
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#
Matrices, Mat
, MatCreate()
, MatCreateAIJ()
, MatCreateSeqAIJ()
, MatCreateSeqAIJWithArrays()
, MatMPIAIJSetPreallocationCSR()
, MatSetValuesCOO()
, MatSetPreallocationCOO()
Level#
intermediate
Location#
Examples#
src/ksp/ksp/tutorials/ex83f.F90
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages