Amesos Package Browser (Single Doxygen Collection) Development
amesos_camd_internal.h
Go to the documentation of this file.
00001 /* ========================================================================= */
00002 /* === camd_internal.h ===================================================== */
00003 /* ========================================================================= */
00004 
00005 /* ------------------------------------------------------------------------- */
00006 /* CAMD, Copyright (c) Timothy A. Davis, Yanqing Chen,           */
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/camd                         */
00010 /* ------------------------------------------------------------------------- */
00011 
00012 /* This file is for internal use in CAMD itself, and does not normally need to
00013  * be included in user code (it is included in UMFPACK, however).   All others
00014  * should use camd.h instead.
00015  *
00016  * The following compile-time definitions affect how CAMD 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 camd_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 camd_malloc, camd_free, camd_realloc, and
00028  *      camd_calloc at run-time for CAMD 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 CAMD 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 CAMD library libcamd.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     CAMD 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 /* ------------------------------------------------------------------------- */
00062 /* ANSI include files */
00063 /* ------------------------------------------------------------------------- */
00064 
00065 /* from stdlib.h:  size_t, malloc, free, realloc, and calloc */
00066 #include <stdlib.h>
00067 
00068 #if !defined(NPRINT) || !defined(NDEBUG)
00069 /* from stdio.h:  printf.  Not included if NPRINT is defined at compile time.
00070  * fopen and fscanf are used when debugging. */
00071 #include <stdio.h>
00072 #endif
00073 
00074 /* from limits.h:  INT_MAX and LONG_MAX */
00075 #include <limits.h>
00076 
00077 /* from math.h: sqrt */
00078 #include <math.h>
00079 
00080 /* ------------------------------------------------------------------------- */
00081 /* MATLAB include files (only if being used in or via MATLAB) */
00082 /* ------------------------------------------------------------------------- */
00083 
00084 #ifdef MATLAB_MEX_FILE
00085 #include "matrix.h"
00086 #include "mex.h"
00087 #endif
00088 
00089 /* ------------------------------------------------------------------------- */
00090 /* basic definitions */
00091 /* ------------------------------------------------------------------------- */
00092 
00093 #ifdef FLIP
00094 #undef FLIP
00095 #endif
00096 
00097 #ifdef MAX
00098 #undef MAX
00099 #endif
00100 
00101 #ifdef MIN
00102 #undef MIN
00103 #endif
00104 
00105 #ifdef EMPTY
00106 #undef EMPTY
00107 #endif
00108 
00109 #ifdef GLOBAL
00110 #undef GLOBAL
00111 #endif
00112 
00113 #ifdef PRIVATE
00114 #undef PRIVATE
00115 #endif
00116 
00117 /* FLIP is a "negation about -1", and is used to mark an integer i that is
00118  * normally non-negative.  FLIP (EMPTY) is EMPTY.  FLIP of a number > EMPTY
00119  * is negative, and FLIP of a number < EMTPY is positive.  FLIP (FLIP (i)) = i
00120  * for all integers i.  UNFLIP (i) is >= EMPTY. */
00121 #define EMPTY (-1)
00122 #define FLIP(i) (-(i)-2)
00123 #define UNFLIP(i) ((i < EMPTY) ? FLIP (i) : (i))
00124 
00125 /* for integer MAX/MIN, or for doubles when we don't care how NaN's behave: */
00126 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
00127 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
00128 
00129 /* logical expression of p implies q: */
00130 #define IMPLIES(p,q) (!(p) || (q))
00131 
00132 /* Note that the IBM RS 6000 xlc predefines TRUE and FALSE in <types.h>. */
00133 /* The Compaq Alpha also predefines TRUE and FALSE. */
00134 #ifdef TRUE
00135 #undef TRUE
00136 #endif
00137 #ifdef FALSE
00138 #undef FALSE
00139 #endif
00140 
00141 #define TRUE (1)
00142 #define FALSE (0)
00143 #define PRIVATE static
00144 #define GLOBAL
00145 #define EMPTY (-1)
00146 
00147 /* Note that Linux's gcc 2.96 defines NULL as ((void *) 0), but other */
00148 /* compilers (even gcc 2.95.2 on Solaris) define NULL as 0 or (0).  We */
00149 /* need to use the ANSI standard value of 0. */
00150 #ifdef NULL
00151 #undef NULL
00152 #endif
00153 
00154 #define NULL 0
00155 
00156 /* largest value of size_t */
00157 #ifndef SIZE_T_MAX
00158 #define SIZE_T_MAX ((size_t) (-1))
00159 #endif
00160 
00161 /* ------------------------------------------------------------------------- */
00162 /* integer type for CAMD: int or UF_long */
00163 /* ------------------------------------------------------------------------- */
00164 
00165 /* define UF_long */
00166 #include "amesos_UFconfig.h"
00167 
00168 #if defined (DLONG) || defined (ZLONG)
00169 
00170 #define Int UF_long
00171 #define ID  UF_long_id
00172 #define Int_MAX UF_long_max
00173 
00174 #define CAMD_order amesos_camd_l_order
00175 #define CAMD_defaults amesos_camd_l_defaults
00176 #define CAMD_control amesos_camd_l_control
00177 #define CAMD_info amesos_camd_l_info
00178 #define CAMD_1 amesos_camd_l1
00179 #define CAMD_2 amesos_camd_l2
00180 #define CAMD_valid amesos_camd_l_valid
00181 #define CAMD_cvalid amesos_camd_l_cvalid
00182 #define CAMD_aat amesos_camd_l_aat
00183 #define CAMD_postorder amesos_camd_l_postorder
00184 #define CAMD_post_tree amesos_camd_l_post_tree
00185 #define CAMD_dump amesos_camd_l_dump
00186 #define CAMD_debug amesos_camd_l_debug
00187 #define CAMD_debug_init amesos_camd_l_debug_init
00188 #define CAMD_preprocess amesos_camd_l_preprocess
00189 
00190 #else
00191 
00192 #define Int int
00193 #define ID "%d"
00194 #define Int_MAX INT_MAX
00195 
00196 #define CAMD_order amesos_camd_order
00197 #define CAMD_defaults amesos_camd_defaults
00198 #define CAMD_control amesos_camd_control
00199 #define CAMD_info amesos_camd_info
00200 #define CAMD_1 amesos_camd_1
00201 #define CAMD_2 amesos_camd_2
00202 #define CAMD_valid amesos_camd_valid
00203 #define CAMD_cvalid amesos_camd_cvalid
00204 #define CAMD_aat amesos_camd_aat
00205 #define CAMD_postorder amesos_camd_postorder
00206 #define CAMD_post_tree amesos_camd_post_tree
00207 #define CAMD_dump amesos_camd_dump
00208 #define CAMD_debug amesos_camd_debug
00209 #define CAMD_debug_init amesos_camd_debug_init
00210 #define CAMD_preprocess amesos_camd_preprocess
00211 
00212 #endif
00213 
00214 /* ========================================================================= */
00215 /* === PRINTF macro ======================================================== */
00216 /* ========================================================================= */
00217 
00218 /* All output goes through the PRINTF macro.  */
00219 #define PRINTF(params) { if (amesos_camd_printf != NULL) (void) amesos_camd_printf params ; }
00220 
00221 /* ------------------------------------------------------------------------- */
00222 /* CAMD routine definitions (user-callable) */
00223 /* ------------------------------------------------------------------------- */
00224 
00225 #include "amesos_camd.h"
00226 
00227 /* ------------------------------------------------------------------------- */
00228 /* CAMD routine definitions (not user-callable) */
00229 /* ------------------------------------------------------------------------- */
00230 
00231 GLOBAL size_t CAMD_aat
00232 (
00233     Int n,
00234     const Int Ap [ ],
00235     const Int Ai [ ],
00236     Int Len [ ],
00237     Int Tp [ ],
00238     double Info [ ]
00239 ) ;
00240 
00241 GLOBAL void CAMD_1
00242 (
00243     Int n,
00244     const Int Ap [ ],
00245     const Int Ai [ ],
00246     Int P [ ],
00247     Int Pinv [ ],
00248     Int Len [ ],
00249     Int slen,
00250     Int S [ ],
00251     double Control [ ],
00252     double Info [ ],
00253     const Int C [ ]
00254 ) ;
00255 
00256 GLOBAL Int CAMD_postorder
00257 (
00258     Int j, Int k, Int n, Int head [], Int next [], Int post [], Int stack []
00259 ) ;
00260 
00261 GLOBAL void CAMD_preprocess
00262 (
00263     Int n,
00264     const Int Ap [ ],
00265     const Int Ai [ ],
00266     Int Rp [ ],
00267     Int Ri [ ],
00268     Int W [ ],
00269     Int Flag [ ]
00270 ) ;
00271 
00272 /* ------------------------------------------------------------------------- */
00273 /* debugging definitions */
00274 /* ------------------------------------------------------------------------- */
00275 
00276 #ifndef NDEBUG
00277 
00278 /* from assert.h:  assert macro */
00279 #include <assert.h>
00280 
00281 #ifndef EXTERN
00282 #define EXTERN extern
00283 #endif
00284 
00285 EXTERN Int CAMD_debug ;
00286 
00287 GLOBAL void CAMD_debug_init ( char *s ) ;
00288 
00289 GLOBAL void CAMD_dump
00290 (
00291     Int n,
00292     Int Pe [ ],
00293     Int Iw [ ],
00294     Int Len [ ],
00295     Int iwlen,
00296     Int pfree,
00297     Int Nv [ ],
00298     Int Next [ ],
00299     Int Last [ ],
00300     Int Head [ ],
00301     Int Elen [ ],
00302     Int Degree [ ],
00303     Int W [ ],
00304     Int nel,
00305     Int BucketSet [],
00306     const Int C [],
00307     Int Curc
00308 ) ;
00309 
00310 #ifdef ASSERT
00311 #undef ASSERT
00312 #endif
00313 
00314 /* Use mxAssert if CAMD is compiled into a mexFunction */
00315 #ifdef MATLAB_MEX_FILE
00316 #define ASSERT(expression) (mxAssert ((expression), ""))
00317 #else
00318 #define ASSERT(expression) (assert (expression))
00319 #endif
00320 
00321 #define CAMD_DEBUG0(params) { PRINTF (params) ; }
00322 #define CAMD_DEBUG1(params) { if (CAMD_debug >= 1) PRINTF (params) ; }
00323 #define CAMD_DEBUG2(params) { if (CAMD_debug >= 2) PRINTF (params) ; }
00324 #define CAMD_DEBUG3(params) { if (CAMD_debug >= 3) PRINTF (params) ; }
00325 #define CAMD_DEBUG4(params) { if (CAMD_debug >= 4) PRINTF (params) ; }
00326 
00327 #else
00328 
00329 /* no debugging */
00330 #define ASSERT(expression)
00331 #define CAMD_DEBUG0(params)
00332 #define CAMD_DEBUG1(params)
00333 #define CAMD_DEBUG2(params)
00334 #define CAMD_DEBUG3(params)
00335 #define CAMD_DEBUG4(params)
00336 
00337 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines