Sparse matrices are usually represented in formats that minimize storage requirements. By taking advantage of the sparsity and not storing zeros, considerable storage space can be saved. The storage format used by SPSOLVE and SuperLU is the compressed sparse column (CSC) format, also called the Harwell-Boeing format.
The CSC format represents a sparse matrix with two integer arrays and one floating point array. The integer arrays (colptr and rowind) specify the location of the nonzeros of the sparse matrix, and the floating point array (values) is used for the nonzero values.
The column pointer (colptr) array consists of n+1 elements where colptr(i) points to the beginning of the ith column, and colptr(i+1)-1 points to the end of the ith column. The row indices (rowind) array contains the row indices of the nonzero values. The values arrays contains the corresponding nonzero numerical values.
The following matrix data formats exist for a sparse matrix of neqns equations and nnz nonzeros:
Symmetric
Structurally symmetric
Unsymmetric
Currently, SuperLU only supports unsymmetric matrices. The most efficient data representation often depends on the specific problem. The following sections show examples of sparse matrix data formats.
A symmetric sparse matrix is a matrix where a(i, j) = a(j, i) for all i and j. Because of this symmetry, only the lower triangular values need to be passed to the solver routines. The upper triangle can be determined from the lower triangle.
An example of a symmetric matrix is shown below. This example is derived from A. George and J. W-H. Liu. “Computer Solution of Large Sparse Positive Definite Systems.”
To represent A in CSC format:
colptr: 1, 6, 7, 8, 9, 10
rowind: 1, 2, 3, 4, 5, 2, 3, 4, 5
values: 4.0, 1.0, 2.0, 0.5, 2.0, 0.5, 3.0, 0.625, 16.0
A structurally symmetric sparse matrix has nonzero values with the property that if a(i, j) ≠ 0, then a(j, i) ≠ 0 for all i and j. When solving a structurally symmetric system, the entire matrix must be passed to the solver routines.
An example of a structurally symmetric matrix is shown below.
To represent A in CSC format:
colptr: 1, 3, 6, 7, 9
rowind: 1, 2, 1, 2, 4, 3, 2, 4
values: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0
An unsymmetric sparse matrix does not have a(i, j) = a(j, i) for all i and j. The structure of the matrix does not have an apparent pattern. When solving an unsymmetric system, the entire matrix must be passed to the solver routines. An example of an unsymmetric matrix is shown below.
To represent A in CSC format:
One-based indexing:
colptr: 1, 6, 7, 8, 9, 11
rowind: 1, 2, 3, 4, 5, 2, 3, 4, 2, 5
values: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0
Zero-based indexing:
colptr: 0, 5, 6, 7, 8, 10
rowind: 0, 1, 2, 3, 4, 1, 2, 3, 1, 4
values: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0