What you need to know to use these subprograms

CSR - Compressed sparse row. Given a sparse m-by-kmatrix A with nnz nonzero entries, the CSR format stores each row of A as a sparse vector. Four arrays are required for the CSR representation:

val(*) - Scalar array of length max(nnz, pntre(k)-1)containing the nonzero matrix entries.

indx(*) - Integer array of length max(nnz, pntre(k)-1)containing column indices such that indx(i) corresponds to the column index of val(i).

pntrb(*) - Integer array of length m such that pntrb(j) points to location in val( ) of the first nonzero element in row j.

pntre(*) - Integer array of length m such that pntre(j)-1points to location in val( ) of the last nonzero element in row j.

Note that the above representation only requires each row of A to be stored in a contiguous portion of val( ). If matrix A is stored in the first nnz entries of val( ), a single array pntr( ) of length m+1 can be used instead of pntrb( ) and pntre( ) by having pntrb(i) = pntr(i) and pntre(i) = pntr(i+1).

The matrix in Table 4-4 could be represented in CSR format as:

Table 4-7 CSR Format Matrix

val=

11

13

15

21

22

31

33

35

41

44

45

indx=

1

3

5

1

2

1

3

5

1

4

5

pntrb=

1

4

6

9

 

 

 

 

 

 

 

pntre=

4

6

8

12

 

 

 

 

 

 

 

Optionally, a single array pntr( ) (instead of pntrb( ) and pntre( )) could be used:

pntr=

1

4

6

9

12

MSR - Modified sparse row. The MSR format is a variation of the CSR format obtained by storing the main diagonal of the matrix in a specific array. Given a sparse m-by-kmatrix A with nnz nonzero entries, the MSR representation requires five arrays:

diag(*) - Scalar array of length d containing the main diagonal of A, where d=min(m, k) is the number of elements in the main diagonal.

val(*) - Scalar array of length max(nnz, pntre(k)-1)containing the nonzero matrix entries that do not belong to the main diagonal.

indx(*) - Integer array of length max(nnz, pntre(k)-1)containing column indices such that indx(i) corresponds to the column index of val(i).

Chapter 4 Sparse BLAS Operations 427