1 /* ========================================================================== */ 2 /* === CCOLAMD/ccolamd.h ==================================================== */ 3 /* ========================================================================== */ 4 5 /* ---------------------------------------------------------------------------- 6 * CCOLAMD Copyright (C), Univ. of Florida. Authors: Timothy A. Davis, 7 * Sivasankaran Rajamanickam, and Stefan Larimore 8 * See License.txt for the Version 2.1 of the GNU Lesser General Public License 9 * -------------------------------------------------------------------------- */ 10 11 /* 12 * You must include this file (ccolamd.h) in any routine that uses ccolamd, 13 * csymamd, or the related macros and definitions. 14 */ 15 16 #ifndef CCOLAMD_H 17 #define CCOLAMD_H 18 19 /* make it easy for C++ programs to include CCOLAMD */ 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /* for size_t definition: */ 25 #include <stdlib.h> 26 27 /* ========================================================================== */ 28 /* === CCOLAMD version ====================================================== */ 29 /* ========================================================================== */ 30 31 /* All versions of CCOLAMD will include the following definitions. 32 * As an example, to test if the version you are using is 1.3 or later: 33 * 34 * if (CCOLAMD_VERSION >= CCOLAMD_VERSION_CODE (1,3)) ... 35 * 36 * This also works during compile-time: 37 * 38 * #if CCOLAMD_VERSION >= CCOLAMD_VERSION_CODE (1,3) 39 * printf ("This is version 1.3 or later\n") ; 40 * #else 41 * printf ("This is an early version\n") ; 42 * #endif 43 */ 44 45 #define CCOLAMD_DATE "Feb 1, 2016" 46 #define CCOLAMD_VERSION_CODE(main,sub) ((main) * 1000 + (sub)) 47 #define CCOLAMD_MAIN_VERSION 2 48 #define CCOLAMD_SUB_VERSION 9 49 #define CCOLAMD_SUBSUB_VERSION 4 50 #define CCOLAMD_VERSION \ 51 CCOLAMD_VERSION_CODE(CCOLAMD_MAIN_VERSION,CCOLAMD_SUB_VERSION) 52 53 /* ========================================================================== */ 54 /* === Knob and statistics definitions ====================================== */ 55 /* ========================================================================== */ 56 57 /* size of the knobs [ ] array. Only knobs [0..3] are currently used. */ 58 #define CCOLAMD_KNOBS 20 59 60 /* number of output statistics. Only stats [0..10] are currently used. */ 61 #define CCOLAMD_STATS 20 62 63 /* knobs [0] and stats [0]: dense row knob and output statistic. */ 64 #define CCOLAMD_DENSE_ROW 0 65 66 /* knobs [1] and stats [1]: dense column knob and output statistic. */ 67 #define CCOLAMD_DENSE_COL 1 68 69 /* knobs [2]: aggressive absorption option */ 70 #define CCOLAMD_AGGRESSIVE 2 71 72 /* knobs [3]: LU or Cholesky factorization option */ 73 #define CCOLAMD_LU 3 74 75 /* stats [2]: memory defragmentation count output statistic */ 76 #define CCOLAMD_DEFRAG_COUNT 2 77 78 /* stats [3]: ccolamd status: zero OK, > 0 warning or notice, < 0 error */ 79 #define CCOLAMD_STATUS 3 80 81 /* stats [4..6]: error info, or info on jumbled columns */ 82 #define CCOLAMD_INFO1 4 83 #define CCOLAMD_INFO2 5 84 #define CCOLAMD_INFO3 6 85 86 /* stats [7]: number of originally empty rows */ 87 #define CCOLAMD_EMPTY_ROW 7 88 /* stats [8]: number of originally empty cols */ 89 #define CCOLAMD_EMPTY_COL 8 90 /* stats [9]: number of rows with entries only in dense cols */ 91 #define CCOLAMD_NEWLY_EMPTY_ROW 9 92 /* stats [10]: number of cols with entries only in dense rows */ 93 #define CCOLAMD_NEWLY_EMPTY_COL 10 94 95 /* error codes returned in stats [3]: */ 96 #define CCOLAMD_OK (0) 97 #define CCOLAMD_OK_BUT_JUMBLED (1) 98 #define CCOLAMD_ERROR_A_not_present (-1) 99 #define CCOLAMD_ERROR_p_not_present (-2) 100 #define CCOLAMD_ERROR_nrow_negative (-3) 101 #define CCOLAMD_ERROR_ncol_negative (-4) 102 #define CCOLAMD_ERROR_nnz_negative (-5) 103 #define CCOLAMD_ERROR_p0_nonzero (-6) 104 #define CCOLAMD_ERROR_A_too_small (-7) 105 #define CCOLAMD_ERROR_col_length_negative (-8) 106 #define CCOLAMD_ERROR_row_index_out_of_bounds (-9) 107 #define CCOLAMD_ERROR_out_of_memory (-10) 108 #define CCOLAMD_ERROR_invalid_cmember (-11) 109 #define CCOLAMD_ERROR_internal_error (-999) 110 111 /* ========================================================================== */ 112 /* === Prototypes of user-callable routines ================================= */ 113 /* ========================================================================== */ 114 115 #include "SuiteSparse_config.h" 116 117 size_t ccolamd_recommended /* returns recommended value of Alen, */ 118 /* or 0 if input arguments are erroneous */ 119 ( 120 int nnz, /* nonzeros in A */ 121 int n_row, /* number of rows in A */ 122 int n_col /* number of columns in A */ 123 ) ; 124 125 size_t ccolamd_l_recommended /* returns recommended value of Alen, */ 126 /* or 0 if input arguments are erroneous */ 127 ( 128 SuiteSparse_long nnz, /* nonzeros in A */ 129 SuiteSparse_long n_row, /* number of rows in A */ 130 SuiteSparse_long n_col /* number of columns in A */ 131 ) ; 132 133 void ccolamd_set_defaults /* sets default parameters */ 134 ( /* knobs argument is modified on output */ 135 double knobs [CCOLAMD_KNOBS] /* parameter settings for ccolamd */ 136 ) ; 137 138 void ccolamd_l_set_defaults /* sets default parameters */ 139 ( /* knobs argument is modified on output */ 140 double knobs [CCOLAMD_KNOBS] /* parameter settings for ccolamd */ 141 ) ; 142 143 int ccolamd /* returns (1) if successful, (0) otherwise*/ 144 ( /* A and p arguments are modified on output */ 145 int n_row, /* number of rows in A */ 146 int n_col, /* number of columns in A */ 147 int Alen, /* size of the array A */ 148 int A [ ], /* row indices of A, of size Alen */ 149 int p [ ], /* column pointers of A, of size n_col+1 */ 150 double knobs [CCOLAMD_KNOBS],/* parameter settings for ccolamd */ 151 int stats [CCOLAMD_STATS], /* ccolamd output statistics and error codes */ 152 int cmember [ ] /* Constraint set of A, of size n_col */ 153 ) ; 154 155 SuiteSparse_long ccolamd_l /* as ccolamd w/ SuiteSparse_long integers */ 156 ( 157 SuiteSparse_long n_row, 158 SuiteSparse_long n_col, 159 SuiteSparse_long Alen, 160 SuiteSparse_long A [ ], 161 SuiteSparse_long p [ ], 162 double knobs [CCOLAMD_KNOBS], 163 SuiteSparse_long stats [CCOLAMD_STATS], 164 SuiteSparse_long cmember [ ] 165 ) ; 166 167 int csymamd /* return (1) if OK, (0) otherwise */ 168 ( 169 int n, /* number of rows and columns of A */ 170 int A [ ], /* row indices of A */ 171 int p [ ], /* column pointers of A */ 172 int perm [ ], /* output permutation, size n_col+1 */ 173 double knobs [CCOLAMD_KNOBS],/* parameters (uses defaults if NULL) */ 174 int stats [CCOLAMD_STATS], /* output statistics and error codes */ 175 void * (*allocate) (size_t, size_t), /* pointer to calloc (ANSI C) or */ 176 /* mxCalloc (for MATLAB mexFunction) */ 177 void (*release) (void *), /* pointer to free (ANSI C) or */ 178 /* mxFree (for MATLAB mexFunction) */ 179 int cmember [ ], /* Constraint set of A */ 180 int stype /* 0: use both parts, >0: upper, <0: lower */ 181 ) ; 182 183 SuiteSparse_long csymamd_l /* as csymamd, w/ SuiteSparse_long integers */ 184 ( 185 SuiteSparse_long n, 186 SuiteSparse_long A [ ], 187 SuiteSparse_long p [ ], 188 SuiteSparse_long perm [ ], 189 double knobs [CCOLAMD_KNOBS], 190 SuiteSparse_long stats [CCOLAMD_STATS], 191 void * (*allocate) (size_t, size_t), 192 void (*release) (void *), 193 SuiteSparse_long cmember [ ], 194 SuiteSparse_long stype 195 ) ; 196 197 void ccolamd_report 198 ( 199 int stats [CCOLAMD_STATS] 200 ) ; 201 202 void ccolamd_l_report 203 ( 204 SuiteSparse_long stats [CCOLAMD_STATS] 205 ) ; 206 207 void csymamd_report 208 ( 209 int stats [CCOLAMD_STATS] 210 ) ; 211 212 void csymamd_l_report 213 ( 214 SuiteSparse_long stats [CCOLAMD_STATS] 215 ) ; 216 217 218 /* ========================================================================== */ 219 /* === Prototypes of "expert" routines ====================================== */ 220 /* ========================================================================== */ 221 222 /* These routines are meant to be used internally, or in a future version of 223 * UMFPACK. They appear here so that UMFPACK can use them, but they should not 224 * be called directly by the user. 225 */ 226 227 int ccolamd2 228 ( /* A and p arguments are modified on output */ 229 int n_row, /* number of rows in A */ 230 int n_col, /* number of columns in A */ 231 int Alen, /* size of the array A */ 232 int A [ ], /* row indices of A, of size Alen */ 233 int p [ ], /* column pointers of A, of size n_col+1 */ 234 double knobs [CCOLAMD_KNOBS],/* parameter settings for ccolamd */ 235 int stats [CCOLAMD_STATS], /* ccolamd output statistics and error codes */ 236 /* each Front_ array is of size n_col+1: */ 237 int Front_npivcol [ ], /* # pivot cols in each front */ 238 int Front_nrows [ ], /* # of rows in each front (incl. pivot rows) */ 239 int Front_ncols [ ], /* # of cols in each front (incl. pivot cols) */ 240 int Front_parent [ ], /* parent of each front */ 241 int Front_cols [ ], /* link list of pivot columns for each front */ 242 int *p_nfr, /* total number of frontal matrices */ 243 int InFront [ ], /* InFront [row] = f if row in front f */ 244 int cmember [ ] /* Constraint set of A */ 245 ) ; 246 247 SuiteSparse_long ccolamd2_l /* as ccolamd2, w/ SuiteSparse_long integers */ 248 ( 249 SuiteSparse_long n_row, 250 SuiteSparse_long n_col, 251 SuiteSparse_long Alen, 252 SuiteSparse_long A [ ], 253 SuiteSparse_long p [ ], 254 double knobs [CCOLAMD_KNOBS], 255 SuiteSparse_long stats [CCOLAMD_STATS], 256 SuiteSparse_long Front_npivcol [ ], 257 SuiteSparse_long Front_nrows [ ], 258 SuiteSparse_long Front_ncols [ ], 259 SuiteSparse_long Front_parent [ ], 260 SuiteSparse_long Front_cols [ ], 261 SuiteSparse_long *p_nfr, 262 SuiteSparse_long InFront [ ], 263 SuiteSparse_long cmember [ ] 264 ) ; 265 266 void ccolamd_apply_order 267 ( 268 int Front [ ], 269 const int Order [ ], 270 int Temp [ ], 271 int nn, 272 int nfr 273 ) ; 274 275 void ccolamd_l_apply_order 276 ( 277 SuiteSparse_long Front [ ], 278 const SuiteSparse_long Order [ ], 279 SuiteSparse_long Temp [ ], 280 SuiteSparse_long nn, 281 SuiteSparse_long nfr 282 ) ; 283 284 285 void ccolamd_fsize 286 ( 287 int nn, 288 int MaxFsize [ ], 289 int Fnrows [ ], 290 int Fncols [ ], 291 int Parent [ ], 292 int Npiv [ ] 293 ) ; 294 295 void ccolamd_l_fsize 296 ( 297 SuiteSparse_long nn, 298 SuiteSparse_long MaxFsize [ ], 299 SuiteSparse_long Fnrows [ ], 300 SuiteSparse_long Fncols [ ], 301 SuiteSparse_long Parent [ ], 302 SuiteSparse_long Npiv [ ] 303 ) ; 304 305 void ccolamd_postorder 306 ( 307 int nn, 308 int Parent [ ], 309 int Npiv [ ], 310 int Fsize [ ], 311 int Order [ ], 312 int Child [ ], 313 int Sibling [ ], 314 int Stack [ ], 315 int Front_cols [ ], 316 int cmember [ ] 317 ) ; 318 319 void ccolamd_l_postorder 320 ( 321 SuiteSparse_long nn, 322 SuiteSparse_long Parent [ ], 323 SuiteSparse_long Npiv [ ], 324 SuiteSparse_long Fsize [ ], 325 SuiteSparse_long Order [ ], 326 SuiteSparse_long Child [ ], 327 SuiteSparse_long Sibling [ ], 328 SuiteSparse_long Stack [ ], 329 SuiteSparse_long Front_cols [ ], 330 SuiteSparse_long cmember [ ] 331 ) ; 332 333 int ccolamd_post_tree 334 ( 335 int root, 336 int k, 337 int Child [ ], 338 const int Sibling [ ], 339 int Order [ ], 340 int Stack [ ] 341 ) ; 342 343 SuiteSparse_long ccolamd_l_post_tree 344 ( 345 SuiteSparse_long root, 346 SuiteSparse_long k, 347 SuiteSparse_long Child [ ], 348 const SuiteSparse_long Sibling [ ], 349 SuiteSparse_long Order [ ], 350 SuiteSparse_long Stack [ ] 351 ) ; 352 353 #ifdef __cplusplus 354 } 355 #endif 356 357 #endif 358