SuperLU Distributed 8.2.1
Distributed memory sparse direct solver
colamd.h
Go to the documentation of this file.
1
65#ifndef COLAMD_H
66#define COLAMD_H
67
68/* ========================================================================== */
69/* === Include files ======================================================== */
70/* ========================================================================== */
71
72#include <stdlib.h>
73
74/* ========================================================================== */
75/* === Knob and statistics definitions ====================================== */
76/* ========================================================================== */
77
78/* size of the knobs [ ] array. Only knobs [0..1] are currently used. */
79#define COLAMD_KNOBS 20
80
81/* number of output statistics. Only stats [0..6] are currently used. */
82#define COLAMD_STATS 20
83
84/* knobs [0] and stats [0]: dense row knob and output statistic. */
85#define COLAMD_DENSE_ROW 0
86
87/* knobs [1] and stats [1]: dense column knob and output statistic. */
88#define COLAMD_DENSE_COL 1
89
90/* stats [2]: memory defragmentation count output statistic */
91#define COLAMD_DEFRAG_COUNT 2
92
93/* stats [3]: colamd status: zero OK, > 0 warning or notice, < 0 error */
94#define COLAMD_STATUS 3
95
96/* stats [4..6]: error info, or info on jumbled columns */
97#define COLAMD_INFO1 4
98#define COLAMD_INFO2 5
99#define COLAMD_INFO3 6
100
101/* error codes returned in stats [3]: */
102#define COLAMD_OK (0)
103#define COLAMD_OK_BUT_JUMBLED (1)
104#define COLAMD_ERROR_A_not_present (-1)
105#define COLAMD_ERROR_p_not_present (-2)
106#define COLAMD_ERROR_nrow_negative (-3)
107#define COLAMD_ERROR_ncol_negative (-4)
108#define COLAMD_ERROR_nnz_negative (-5)
109#define COLAMD_ERROR_p0_nonzero (-6)
110#define COLAMD_ERROR_A_too_small (-7)
111#define COLAMD_ERROR_col_length_negative (-8)
112#define COLAMD_ERROR_row_index_out_of_bounds (-9)
113#define COLAMD_ERROR_out_of_memory (-10)
114#define COLAMD_ERROR_internal_error (-999)
115
116/* ========================================================================== */
117/* === Row and Column structures ============================================ */
118/* ========================================================================== */
119
120/* User code that makes use of the colamd/symamd routines need not directly */
121/* reference these structures. They are used only for the COLAMD_RECOMMENDED */
122/* macro. */
123
124typedef struct Colamd_Col_struct
125{
126 int start ; /* index for A of first row in this column, or DEAD */
127 /* if column is dead */
128 int length ; /* number of rows in this column */
129 union
130 {
131 int thickness ; /* number of original columns represented by this */
132 /* col, if the column is alive */
133 int parent ; /* parent in parent tree super-column structure, if */
134 /* the column is dead */
136 union
137 {
138 int score ; /* the score used to maintain heap, if col is alive */
139 int order ; /* pivot ordering of this column, if col is dead */
141 union
142 {
143 int headhash ; /* head of a hash bucket, if col is at the head of */
144 /* a degree list */
145 int hash ; /* hash value, if col is not in a degree list */
146 int prev ; /* previous column in degree list, if col is in a */
147 /* degree list (but not at the head of a degree list) */
149 union
150 {
151 int degree_next ; /* next column, if col is in a degree list */
152 int hash_next ; /* next column, if col is in a hash list */
154
156
157typedef struct Colamd_Row_struct
158{
159 int start ; /* index for A of first col in this row */
160 int length ; /* number of principal columns in this row */
161 union
162 {
163 int degree ; /* number of principal & non-principal columns in row */
164 int p ; /* used as a row pointer in init_rows_cols () */
166 union
167 {
168 int mark ; /* for computing set differences and marking dead rows*/
169 int first_column ;/* first column in row (used in garbage collection) */
171
173
174/* ========================================================================== */
175/* === Colamd recommended memory size ======================================= */
176/* ========================================================================== */
177
178/*
179 The recommended length Alen of the array A passed to colamd is given by
180 the COLAMD_RECOMMENDED (nnz, n_row, n_col) macro. It returns -1 if any
181 argument is negative. 2*nnz space is required for the row and column
182 indices of the matrix. COLAMD_C (n_col) + COLAMD_R (n_row) space is
183 required for the Col and Row arrays, respectively, which are internal to
184 colamd. An additional n_col space is the minimal amount of "elbow room",
185 and nnz/5 more space is recommended for run time efficiency.
186
187 This macro is not needed when using symamd.
188
189 Explicit typecast to int added Sept. 23, 2002, COLAMD version 2.2, to avoid
190 gcc -pedantic warning messages.
191*/
192
193#define COLAMD_C(n_col) ((int) (((n_col) + 1) * sizeof (Colamd_Col) / sizeof (int)))
194#define COLAMD_R(n_row) ((int) (((n_row) + 1) * sizeof (Colamd_Row) / sizeof (int)))
195
196#define COLAMD_RECOMMENDED(nnz, n_row, n_col) \
197( \
198((nnz) < 0 || (n_row) < 0 || (n_col) < 0) \
199? \
200 (-1) \
201: \
202 (2 * (nnz) + COLAMD_C (n_col) + COLAMD_R (n_row) + (n_col) + ((nnz) / 5)) \
203)
204
205/* ========================================================================== */
206/* === Prototypes of user-callable routines ================================= */
207/* ========================================================================== */
208
209int colamd_recommended /* returns recommended value of Alen, */
210 /* or (-1) if input arguments are erroneous */
211(
212 int nnz, /* nonzeros in A */
213 int n_row, /* number of rows in A */
214 int n_col /* number of columns in A */
215) ;
216
217void colamd_set_defaults /* sets default parameters */
218( /* knobs argument is modified on output */
219 double knobs [COLAMD_KNOBS] /* parameter settings for colamd */
220) ;
221
222int colamd /* returns (1) if successful, (0) otherwise*/
223( /* A and p arguments are modified on output */
224 int n_row, /* number of rows in A */
225 int n_col, /* number of columns in A */
226 int Alen, /* size of the array A */
227 int A [], /* row indices of A, of size Alen */
228 int p [], /* column pointers of A, of size n_col+1 */
229 double knobs [COLAMD_KNOBS],/* parameter settings for colamd */
230 int stats [COLAMD_STATS] /* colamd output statistics and error codes */
231) ;
232
233int symamd /* return (1) if OK, (0) otherwise */
234(
235 int n, /* number of rows and columns of A */
236 int A [], /* row indices of A */
237 int p [], /* column pointers of A */
238 int perm [], /* output permutation, size n_col+1 */
239 double knobs [COLAMD_KNOBS], /* parameters (uses defaults if NULL) */
240 int stats [COLAMD_STATS], /* output statistics and error codes */
241 void * (*allocate) (size_t, size_t),
242 /* pointer to calloc (ANSI C) or */
243 /* mxCalloc (for MATLAB mexFunction) */
244 void (*release) (void *)
245 /* pointer to free (ANSI C) or */
246 /* mxFree (for MATLAB mexFunction) */
247) ;
248
249void colamd_report
250(
251 int stats [COLAMD_STATS]
252) ;
253
254void symamd_report
255(
256 int stats [COLAMD_STATS]
257) ;
258
259#endif /* COLAMD_H */
struct Colamd_Row_struct Colamd_Row
struct Colamd_Col_struct Colamd_Col
void colamd_report(int stats[COLAMD_STATS])
Definition: colamd.c:1476
void symamd_report(int stats[COLAMD_STATS])
Definition: colamd.c:1489
int colamd_recommended(int nnz, int n_row, int n_col)
Definition: colamd.c:910
int symamd(int n, int A[], int p[], int perm[], double knobs[COLAMD_KNOBS], int stats[COLAMD_STATS], void *(*allocate)(size_t, size_t), void(*release)(void *))
Definition: colamd.c:972
void colamd_set_defaults(double knobs[COLAMD_KNOBS])
Definition: colamd.c:944
int colamd(int n_row, int n_col, int Alen, int A[], int p[], double knobs[COLAMD_KNOBS], int stats[COLAMD_STATS])
Definition: colamd.c:1317
#define COLAMD_STATS
Definition: colamd.h:82
#define COLAMD_KNOBS
Definition: colamd.h:79
Definition: colamd.h:125
int headhash
Definition: colamd.h:143
int order
Definition: colamd.h:139
int prev
Definition: colamd.h:146
int degree_next
Definition: colamd.h:151
int start
Definition: colamd.h:126
int hash_next
Definition: colamd.h:152
union Colamd_Col_struct::@0 shared1
int score
Definition: colamd.h:138
int thickness
Definition: colamd.h:131
union Colamd_Col_struct::@2 shared3
int parent
Definition: colamd.h:133
int hash
Definition: colamd.h:145
int length
Definition: colamd.h:128
union Colamd_Col_struct::@1 shared2
union Colamd_Col_struct::@3 shared4
Definition: colamd.h:158
int mark
Definition: colamd.h:168
int degree
Definition: colamd.h:163
int start
Definition: colamd.h:159
int length
Definition: colamd.h:160
union Colamd_Row_struct::@4 shared1
int p
Definition: colamd.h:164
union Colamd_Row_struct::@5 shared2
int first_column
Definition: colamd.h:169