MatCreateSeqAIJ

Creates a sparse matrix in AIJ (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 nzz). By setting these parameters accurately, performance during matrix assembly can be increased by more than a factor of 50.

Synopsis

int MatCreateSeqAIJ(MPI_Comm comm,int m,int n,int nz,int *nnz, Mat *A)
Collective on MPI_Comm

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)
nzz - array containing the number of nonzeros in the various rows (possibly different for each row) or PETSC_NULL

Output Parameter

A -the matrix

Notes

The AIJ format (also called the Yale sparse matrix format orcompressed row storage), is fully compatible with standard Fortran 77storage. That is, the stored row and column indices can begin ateither one (as in Fortran) or zero. See the users' manual for details.

Specify the preallocated storage with either nz or nnz (not both). Set nz=PETSC_DEFAULT and nnz=PETSC_NULL for PETSc to control dynamic memoryallocation. For large problems you MUST preallocate memory or youwill get TERRIBLE performance, see the users' manual chapter on matrices.

By default, this format uses inodes (identical nodes) when possible, toimprove numerical efficiency of matrix-vector products and solves. Wesearch for consecutive rows with the same nonzero structure, therebyreusing matrix information to achieve increased efficiency.

Options Database Keys

-mat_aij_no_inode - Do not use inodes
-mat_aij_inode_limit <limit> - Sets inode limit (max limit=5)
-mat_aij_oneindex - Internally use indexing starting at 1 rather than 0. Note that when calling MatSetValues(), the user still MUST index entries starting at 0!

See Also

MatCreate(), MatCreateMPIAIJ(), MatSetValues()

Examples

src/sles/examples/tutorials/ex13f.F
src/sles/examples/tutorials/ex13.c

Location: src/mat/impls/aij/seq/aij.c
Matrix Index
Table of Contents