00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef NDEBUG
00052 #define NDEBUG
00053 #endif
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #include <stdlib.h>
00066
00067 #if !defined(NPRINT) || !defined(NDEBUG)
00068
00069
00070 #include <stdio.h>
00071 #endif
00072
00073
00074 #include <limits.h>
00075
00076
00077 #include <math.h>
00078
00079
00080
00081
00082
00083 #ifdef MATLAB_MEX_FILE
00084 #include "matrix.h"
00085 #include "mex.h"
00086 #endif
00087
00088
00089
00090
00091
00092 #ifdef FLIP
00093 #undef FLIP
00094 #endif
00095
00096 #ifdef MAX
00097 #undef MAX
00098 #endif
00099
00100 #ifdef MIN
00101 #undef MIN
00102 #endif
00103
00104 #ifdef EMPTY
00105 #undef EMPTY
00106 #endif
00107
00108 #ifdef GLOBAL
00109 #undef GLOBAL
00110 #endif
00111
00112 #ifdef PRIVATE
00113 #undef PRIVATE
00114 #endif
00115
00116
00117
00118
00119
00120 #define EMPTY (-1)
00121 #define FLIP(i) (-(i)-2)
00122 #define UNFLIP(i) ((i < EMPTY) ? FLIP (i) : (i))
00123
00124
00125 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
00126 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
00127
00128
00129 #define IMPLIES(p,q) (!(p) || (q))
00130
00131
00132
00133 #ifdef TRUE
00134 #undef TRUE
00135 #endif
00136 #ifdef FALSE
00137 #undef FALSE
00138 #endif
00139
00140 #define TRUE (1)
00141 #define FALSE (0)
00142 #define PRIVATE static
00143 #define GLOBAL
00144 #define EMPTY (-1)
00145
00146
00147
00148
00149 #ifdef NULL
00150 #undef NULL
00151 #endif
00152
00153 #define NULL 0
00154
00155
00156 #ifndef SIZE_T_MAX
00157 #define SIZE_T_MAX ((size_t) (-1))
00158 #endif
00159
00160
00161
00162
00163
00164
00165 #include "UFconfig.h"
00166
00167 #if defined (DLONG) || defined (ZLONG)
00168
00169 #define Int UF_long
00170 #define ID UF_long_id
00171 #define Int_MAX UF_long_max
00172
00173 #define AMD_order amd_l_order
00174 #define AMD_defaults amd_l_defaults
00175 #define AMD_control amd_l_control
00176 #define AMD_info amd_l_info
00177 #define AMD_1 amd_l1
00178 #define AMD_2 amd_l2
00179 #define AMD_valid amd_l_valid
00180 #define AMD_aat amd_l_aat
00181 #define AMD_postorder amd_l_postorder
00182 #define AMD_post_tree amd_l_post_tree
00183 #define AMD_dump amd_l_dump
00184 #define AMD_debug amd_l_debug
00185 #define AMD_debug_init amd_l_debug_init
00186 #define AMD_preprocess amd_l_preprocess
00187
00188 #else
00189
00190 #define Int int
00191 #define ID "%d"
00192 #define Int_MAX INT_MAX
00193
00194 #define AMD_order amd_order
00195 #define AMD_defaults amd_defaults
00196 #define AMD_control amd_control
00197 #define AMD_info amd_info
00198 #define AMD_1 amd_1
00199 #define AMD_2 amd_2
00200 #define AMD_valid amd_valid
00201 #define AMD_aat amd_aat
00202 #define AMD_postorder amd_postorder
00203 #define AMD_post_tree amd_post_tree
00204 #define AMD_dump amd_dump
00205 #define AMD_debug amd_debug
00206 #define AMD_debug_init amd_debug_init
00207 #define AMD_preprocess amd_preprocess
00208
00209 #endif
00210
00211
00212
00213
00214
00215
00216 #define PRINTF(params) { if (amd_printf != NULL) (void) amd_printf params ; }
00217
00218
00219
00220
00221
00222 #include "amd.h"
00223
00224
00225
00226
00227
00228 GLOBAL size_t AMD_aat
00229 (
00230 Int n,
00231 const Int Ap [ ],
00232 const Int Ai [ ],
00233 Int Len [ ],
00234 Int Tp [ ],
00235 double Info [ ]
00236 ) ;
00237
00238 GLOBAL void AMD_1
00239 (
00240 Int n,
00241 const Int Ap [ ],
00242 const Int Ai [ ],
00243 Int P [ ],
00244 Int Pinv [ ],
00245 Int Len [ ],
00246 Int slen,
00247 Int S [ ],
00248 double Control [ ],
00249 double Info [ ]
00250 ) ;
00251
00252 GLOBAL void AMD_postorder
00253 (
00254 Int nn,
00255 Int Parent [ ],
00256 Int Npiv [ ],
00257 Int Fsize [ ],
00258 Int Order [ ],
00259 Int Child [ ],
00260 Int Sibling [ ],
00261 Int Stack [ ]
00262 ) ;
00263
00264 GLOBAL Int AMD_post_tree
00265 (
00266 Int root,
00267 Int k,
00268 Int Child [ ],
00269 const Int Sibling [ ],
00270 Int Order [ ],
00271 Int Stack [ ]
00272 #ifndef NDEBUG
00273 , Int nn
00274 #endif
00275 ) ;
00276
00277 GLOBAL void AMD_preprocess
00278 (
00279 Int n,
00280 const Int Ap [ ],
00281 const Int Ai [ ],
00282 Int Rp [ ],
00283 Int Ri [ ],
00284 Int W [ ],
00285 Int Flag [ ]
00286 ) ;
00287
00288
00289
00290
00291
00292 #ifndef NDEBUG
00293
00294
00295 #include <assert.h>
00296
00297 #ifndef EXTERN
00298 #define EXTERN extern
00299 #endif
00300
00301 EXTERN Int AMD_debug ;
00302
00303 GLOBAL void AMD_debug_init ( char *s ) ;
00304
00305 GLOBAL void AMD_dump
00306 (
00307 Int n,
00308 Int Pe [ ],
00309 Int Iw [ ],
00310 Int Len [ ],
00311 Int iwlen,
00312 Int pfree,
00313 Int Nv [ ],
00314 Int Next [ ],
00315 Int Last [ ],
00316 Int Head [ ],
00317 Int Elen [ ],
00318 Int Degree [ ],
00319 Int W [ ],
00320 Int nel
00321 ) ;
00322
00323 #ifdef ASSERT
00324 #undef ASSERT
00325 #endif
00326
00327
00328 #ifdef MATLAB_MEX_FILE
00329 #define ASSERT(expression) (mxAssert ((expression), ""))
00330 #else
00331 #define ASSERT(expression) (assert (expression))
00332 #endif
00333
00334 #define AMD_DEBUG0(params) { PRINTF (params) ; }
00335 #define AMD_DEBUG1(params) { if (AMD_debug >= 1) PRINTF (params) ; }
00336 #define AMD_DEBUG2(params) { if (AMD_debug >= 2) PRINTF (params) ; }
00337 #define AMD_DEBUG3(params) { if (AMD_debug >= 3) PRINTF (params) ; }
00338 #define AMD_DEBUG4(params) { if (AMD_debug >= 4) PRINTF (params) ; }
00339
00340 #else
00341
00342
00343 #define ASSERT(expression)
00344 #define AMD_DEBUG0(params)
00345 #define AMD_DEBUG1(params)
00346 #define AMD_DEBUG2(params)
00347 #define AMD_DEBUG3(params)
00348 #define AMD_DEBUG4(params)
00349
00350 #endif