Amesos Package Browser (Single Doxygen Collection) Development
amesos_amd_internal.h
Go to the documentation of this file.
00001 /* ========================================================================= */
00002 /* === amesos_amd_internal.h ====================================================== */
00003 /* ========================================================================= */
00004 
00005 /* ------------------------------------------------------------------------- */
00006 /* AMD, Copyright (c) Timothy A. Davis,              */
00007 /* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
00008 /* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
00009 /* web: http://www.cise.ufl.edu/research/sparse/amd                          */
00010 /* ------------------------------------------------------------------------- */
00011 
00012 /* This file is for internal use in AMD itself, and does not normally need to
00013  * be included in user code (it is included in UMFPACK, however).   All others
00014  * should use amd.h instead.
00015  *
00016  * The following compile-time definitions affect how AMD is compiled.
00017  *
00018  *  -DNPRINT
00019  *
00020  *      Disable all printing.  stdio.h will not be included.  Printing can
00021  *      be re-enabled at run-time by setting the global pointer amesos_amd_printf
00022  *      to printf (or mexPrintf for a MATLAB mexFunction).
00023  *
00024  *  -DNMALLOC
00025  *
00026  *      No memory manager is defined at compile-time.  You MUST define the
00027  *      function pointers amesos_amd_malloc, amesos_amd_free, amesos_amd_realloc, and
00028  *      amesos_amd_calloc at run-time for AMD to work properly.
00029  */
00030 
00031 /* ========================================================================= */
00032 /* === NDEBUG ============================================================== */
00033 /* ========================================================================= */
00034 
00035 /*
00036  * Turning on debugging takes some work (see below).   If you do not edit this
00037  * file, then debugging is always turned off, regardless of whether or not
00038  * -DNDEBUG is specified in your compiler options.
00039  *
00040  * If AMD is being compiled as a mexFunction, then MATLAB_MEX_FILE is defined,
00041  * and mxAssert is used instead of assert.  If debugging is not enabled, no
00042  * MATLAB include files or functions are used.  Thus, the AMD library libamd.a
00043  * can be safely used in either a stand-alone C program or in another
00044  * mexFunction, without any change.
00045  */
00046 
00047 /*
00048     AMD will be exceedingly slow when running in debug mode.  The next three
00049     lines ensure that debugging is turned off.
00050 */
00051 #ifndef NDEBUG
00052 #define NDEBUG
00053 #endif
00054 
00055 /*
00056     To enable debugging, uncomment the following line:
00057 #undef NDEBUG
00058 */
00059 
00060 /* ------------------------------------------------------------------------- */
00061 /* ANSI include files */
00062 /* ------------------------------------------------------------------------- */
00063 
00064 /* from stdlib.h:  size_t, malloc, free, realloc, and calloc */
00065 #include <stdlib.h>
00066 
00067 #if !defined(NPRINT) || !defined(NDEBUG)
00068 /* from stdio.h:  printf.  Not included if NPRINT is defined at compile time.
00069  * fopen and fscanf are used when debugging. */
00070 #include <stdio.h>
00071 #endif
00072 
00073 /* from limits.h:  INT_MAX and LONG_MAX */
00074 #include <limits.h>
00075 
00076 /* from math.h: sqrt */
00077 #include <math.h>
00078 
00079 /* ------------------------------------------------------------------------- */
00080 /* MATLAB include files (only if being used in or via MATLAB) */
00081 /* ------------------------------------------------------------------------- */
00082 
00083 #ifdef MATLAB_MEX_FILE
00084 #include "matrix.h"
00085 #include "mex.h"
00086 #endif
00087 
00088 /* ------------------------------------------------------------------------- */
00089 /* basic definitions */
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 /* FLIP is a "negation about -1", and is used to mark an integer i that is
00117  * normally non-negative.  FLIP (EMPTY) is EMPTY.  FLIP of a number > EMPTY
00118  * is negative, and FLIP of a number < EMTPY is positive.  FLIP (FLIP (i)) = i
00119  * for all integers i.  UNFLIP (i) is >= EMPTY. */
00120 #define EMPTY (-1)
00121 #define FLIP(i) (-(i)-2)
00122 #define UNFLIP(i) ((i < EMPTY) ? FLIP (i) : (i))
00123 
00124 /* for integer MAX/MIN, or for doubles when we don't care how NaN's behave: */
00125 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
00126 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
00127 
00128 /* logical expression of p implies q: */
00129 #define IMPLIES(p,q) (!(p) || (q))
00130 
00131 /* Note that the IBM RS 6000 xlc predefines TRUE and FALSE in <types.h>. */
00132 /* The Compaq Alpha also predefines TRUE and FALSE. */
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 /* Note that Linux's gcc 2.96 defines NULL as ((void *) 0), but other */
00147 /* compilers (even gcc 2.95.2 on Solaris) define NULL as 0 or (0).  We */
00148 /* need to use the ANSI standard value of 0. */
00149 #ifdef NULL
00150 #undef NULL
00151 #endif
00152 
00153 #define NULL 0
00154 
00155 /* largest value of size_t */
00156 #ifndef SIZE_T_MAX
00157 #define SIZE_T_MAX ((size_t) (-1))
00158 #endif
00159 
00160 /* ------------------------------------------------------------------------- */
00161 /* integer type for AMD: int or UF_long */
00162 /* ------------------------------------------------------------------------- */
00163 
00164 /* define UF_long */
00165 #include "amesos_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 amesos_amd_l_order
00174 #define AMD_defaults amesos_amd_l_defaults
00175 #define AMD_control amesos_amd_l_control
00176 #define AMD_info amesos_amd_l_info
00177 #define AMD_1 amesos_amd_l1
00178 #define AMD_2 amesos_amd_l2
00179 #define AMD_valid amesos_amd_l_valid
00180 #define AMD_aat amesos_amd_l_aat
00181 #define AMD_postorder amesos_amd_l_postorder
00182 #define AMD_post_tree amesos_amd_l_post_tree
00183 #define AMD_dump amesos_amd_l_dump
00184 #define AMD_debug amesos_amd_l_debug
00185 #define AMD_debug_init amesos_amd_l_debug_init
00186 #define AMD_preprocess amesos_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 amesos_amd_order
00195 #define AMD_defaults amesos_amd_defaults
00196 #define AMD_control amesos_amd_control
00197 #define AMD_info amesos_amd_info
00198 #define AMD_1 amesos_amd_1
00199 #define AMD_2 amesos_amd_2
00200 #define AMD_valid amesos_amd_valid
00201 #define AMD_aat amesos_amd_aat
00202 #define AMD_postorder amesos_amd_postorder
00203 #define AMD_post_tree amesos_amd_post_tree
00204 #define AMD_dump amesos_amd_dump
00205 #define AMD_debug amesos_amd_debug
00206 #define AMD_debug_init amesos_amd_debug_init
00207 #define AMD_preprocess amesos_amd_preprocess
00208 
00209 #endif
00210 
00211 /* ========================================================================= */
00212 /* === PRINTF macro ======================================================== */
00213 /* ========================================================================= */
00214 
00215 /* All output goes through the PRINTF macro.  */
00216 #define PRINTF(params) { if (amesos_amd_printf != NULL) (void) amesos_amd_printf params ; }
00217 
00218 /* ------------------------------------------------------------------------- */
00219 /* AMD routine definitions (user-callable) */
00220 /* ------------------------------------------------------------------------- */
00221 
00222 #include "amesos_amd.h"
00223 
00224 /* ------------------------------------------------------------------------- */
00225 /* AMD routine definitions (not user-callable) */
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 /* debugging definitions */
00290 /* ------------------------------------------------------------------------- */
00291 
00292 #ifndef NDEBUG
00293 
00294 /* from assert.h:  assert macro */
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 /* Use mxAssert if AMD is compiled into a mexFunction */
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 /* no debugging */
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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines