0
|
1 #ifndef __SUPERLU_SUPERMATRIX /* allow multiple inclusions */ |
|
2 #define __SUPERLU_SUPERMATRIX |
|
3 |
|
4 /******************************************** |
|
5 * The matrix types are defined as follows. * |
|
6 ********************************************/ |
|
7 typedef enum { |
|
8 NC, /* column-wise, no supernode */ |
|
9 NR, /* row-wize, no supernode */ |
|
10 SC, /* column-wise, supernode */ |
|
11 SR, /* row-wise, supernode */ |
|
12 NCP, /* column-wise, column-permuted, no supernode |
|
13 (The consecutive columns of nonzeros, after permutation, |
|
14 may not be stored contiguously.) */ |
|
15 DN /* Fortran style column-wise storage for dense matrix */ |
|
16 } Stype_t; |
|
17 |
|
18 typedef enum { |
|
19 _S, /* single */ |
|
20 _D, /* double */ |
|
21 _C, /* single complex */ |
|
22 _Z /* double complex */ |
|
23 } Dtype_t; |
|
24 |
|
25 typedef enum { |
|
26 GE, /* general */ |
|
27 TRLU, /* lower triangular, unit diagonal */ |
|
28 TRUU, /* upper triangular, unit diagonal */ |
|
29 TRL, /* lower triangular */ |
|
30 TRU, /* upper triangular */ |
|
31 SYL, /* symmetric, store lower half */ |
|
32 SYU, /* symmetric, store upper half */ |
|
33 HEL, /* Hermitian, store lower half */ |
|
34 HEU /* Hermitian, store upper half */ |
|
35 } Mtype_t; |
|
36 |
|
37 typedef struct { |
|
38 Stype_t Stype; /* Storage type: interprets the storage structure |
|
39 pointed to by *Store. */ |
|
40 Dtype_t Dtype; /* Data type. */ |
|
41 Mtype_t Mtype; /* Matrix type: describes the mathematical property of |
|
42 the matrix. */ |
|
43 int nrow; /* number of rows */ |
|
44 int ncol; /* number of columns */ |
|
45 void *Store; /* pointer to the actual storage of the matrix */ |
|
46 } SuperMatrix; |
|
47 |
|
48 /*********************************************** |
|
49 * The storage schemes are defined as follows. * |
|
50 ***********************************************/ |
|
51 |
|
52 /* Stype == NC (Also known as Harwell-Boeing sparse matrix format (CCS)) */ |
|
53 typedef struct { |
|
54 int nnz; /* number of nonzeros in the matrix */ |
|
55 void *nzval; /* pointer to array of nonzero values, packed by column */ |
|
56 int *rowind; /* pointer to array of row indices of the nonzeros */ |
|
57 int *colptr; /* pointer to array of beginning of columns in nzval[] |
|
58 and rowind[] */ |
|
59 /* Note: |
|
60 Zero-based indexing is used; |
|
61 colptr[] has ncol+1 entries, the last one pointing |
|
62 beyond the last column, so that colptr[ncol] = nnz. */ |
|
63 } NCformat; |
|
64 |
|
65 /* Stype == NR (Also known as row compressed storage (RCS). */ |
|
66 typedef struct { |
|
67 int nnz; /* number of nonzeros in the matrix */ |
|
68 void *nzval; /* pointer to array of nonzero values, packed by row */ |
|
69 int *colind; /* pointer to array of column indices of the nonzeros */ |
|
70 int *rowptr; /* pointer to array of beginning of rows in nzval[] |
|
71 and colind[] */ |
|
72 /* Note: |
|
73 Zero-based indexing is used; |
|
74 rowptr[] has nrow+1 entries, the last one pointing |
|
75 beyond the last column, so that rowptr[nrow] = nnz. */ |
|
76 } NRformat; |
|
77 |
|
78 /* Stype == SC */ |
|
79 typedef struct { |
|
80 int nnz; /* number of nonzeros in the matrix */ |
|
81 int nsuper; /* number of supernodes, minus 1 */ |
|
82 void *nzval; /* pointer to array of nonzero values, packed by column */ |
|
83 int *nzval_colptr;/* pointer to array of beginning of columns in nzval[] */ |
|
84 int *rowind; /* pointer to array of compressed row indices of |
|
85 rectangular supernodes */ |
|
86 int *rowind_colptr;/* pointer to array of beginning of columns in rowind[] */ |
|
87 int *col_to_sup; /* col_to_sup[j] is the supernode number to which column |
|
88 j belongs; mapping from column to supernode number. */ |
|
89 int *sup_to_col; /* sup_to_col[s] points to the start of the s-th |
|
90 supernode; mapping from supernode number to column. |
|
91 e.g.: col_to_sup: 0 1 2 2 3 3 3 4 4 4 4 4 (ncol=12) |
|
92 sup_to_col: 0 1 2 4 7 12 (nsuper=4) */ |
|
93 /* Note: |
|
94 Zero-based indexing is used; |
|
95 nzval_colptr[], rowind_colptr[], col_to_sup and |
|
96 sup_to_col[] have ncol+1 entries, the last one |
|
97 pointing beyond the last column. */ |
|
98 } SCformat; |
|
99 |
|
100 /* Stype == NCP */ |
|
101 typedef struct { |
|
102 int nnz; /* number of nonzeros in the matrix */ |
|
103 void *nzval; /* pointer to array of nonzero values, packed by column */ |
|
104 int *rowind; /* pointer to array of row indices of the nonzeros */ |
|
105 /* Note: nzval[]/rowind[] always have the same length */ |
|
106 int *colbeg; /* colbeg[j] points to the beginning of column j in nzval[] |
|
107 and rowind[] */ |
|
108 int *colend; /* colend[j] points to one past the last element of column |
|
109 j in nzval[] and rowind[] */ |
|
110 /* Note: |
|
111 Zero-based indexing is used; |
|
112 The consecutive columns of the nonzeros may not be |
|
113 contiguous in storage, because the matrix has been |
|
114 postmultiplied by a column permutation matrix. */ |
|
115 } NCPformat; |
|
116 |
|
117 /* Stype == DN */ |
|
118 typedef struct { |
|
119 int lda; /* leading dimension */ |
|
120 void *nzval; /* array of size lda*ncol to represent a dense matrix */ |
|
121 } DNformat; |
|
122 |
|
123 |
|
124 |
|
125 /********************************************************* |
|
126 * Macros used for easy access of sparse matrix entries. * |
|
127 *********************************************************/ |
|
128 #define L_SUB_START(col) ( Lstore->rowind_colptr[col] ) |
|
129 #define L_SUB(ptr) ( Lstore->rowind[ptr] ) |
|
130 #define L_NZ_START(col) ( Lstore->nzval_colptr[col] ) |
|
131 #define L_FST_SUPC(superno) ( Lstore->sup_to_col[superno] ) |
|
132 #define U_NZ_START(col) ( Ustore->colptr[col] ) |
|
133 #define U_SUB(ptr) ( Ustore->rowind[ptr] ) |
|
134 |
|
135 |
|
136 #endif /* __SUPERLU_SUPERMATRIX */ |