MatCreateSeqAIJ#
Creates a sparse matrix in MATSEQAIJ
(compressed row) format (the default parallel PETSc format). For good matrix assembly performance the user should preallocate the matrix storage by setting the parameter nz
(or the array nnz
).
Synopsis#
#include "petscmat.h"
PetscErrorCode MatCreateSeqAIJ(MPI_Comm comm, PetscInt m, PetscInt n, PetscInt nz, const PetscInt nnz[], Mat *A)
Collective
Input Parameters#
comm - MPI communicator, set to
PETSC_COMM_SELF
m - number of rows
n - number of columns
nz - number of nonzeros per row (same for all rows)
nnz - array containing the number of nonzeros in the various rows (possibly different for each row) or NULL
Output Parameter#
A - the matrix
Options Database Keys#
-mat_no_inode - Do not use inodes
-mat_inode_limit
- Sets inode limit (max limit=5)
Notes#
It is recommend to use MatCreateFromOptions()
instead of this routine
If nnz
is given then nz
is ignored
The MATSEQAIJ
format, also called
compressed row storage, is fully compatible with standard Fortran
storage. That is, the stored row and column indices can begin at
either one (as in Fortran) or zero.
Specify the preallocated storage with either nz
or nnz
(not both).
Set nz
= PETSC_DEFAULT
and nnz
= NULL
for PETSc to control dynamic memory
allocation.
By default, this format uses inodes (identical nodes) when possible, to improve numerical efficiency of matrix-vector products and solves. We search for consecutive rows with the same nonzero structure, thereby reusing matrix information to achieve increased efficiency.
See Also#
Matrices, Mat
, Sparse Matrix Creation, MatCreate()
, MatCreateAIJ()
, MatSetValues()
, MatSeqAIJSetColumnIndices()
, MatCreateSeqAIJWithArrays()
Level#
intermediate
Location#
Examples#
src/tao/complementarity/tutorials/minsurf1.c
src/ksp/pc/tutorials/ex1.c
src/ksp/ksp/tutorials/ex13f90.F90
src/snes/tutorials/ex59.c
src/mat/tutorials/ex12.c
src/ksp/pc/tutorials/ex2.c
src/tao/unconstrained/tutorials/eptorsion3.c
src/tao/unconstrained/tutorials/minsurf1.c
src/tao/unconstrained/tutorials/eptorsion1.c
src/ksp/ksp/tutorials/ex61f.F90
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages