Amesos Package Browser (Single Doxygen Collection) Development
amesos_camd_dump.c
Go to the documentation of this file.
00001 /* ========================================================================= */
00002 /* === CAMD_dump =========================================================== */
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 /* Debugging routines for CAMD.  Not used if NDEBUG is not defined at compile-
00013  * time (the default).  See comments in camd_internal.h on how to enable
00014  * debugging.  Not user-callable.
00015  */
00016 
00017 #include "amesos_camd_internal.h"
00018 
00019 #ifndef NDEBUG
00020 
00021 /* This global variable is present only when debugging */
00022 GLOBAL Int CAMD_debug = -999 ;    /* default is no debug printing */
00023 
00024 /* ========================================================================= */
00025 /* === CAMD_debug_init ===================================================== */
00026 /* ========================================================================= */
00027 
00028 /* Sets the debug print level, by reading the file debug.camd (if it exists) */
00029 
00030 GLOBAL void CAMD_debug_init ( char *s )
00031 {
00032     FILE *f ;
00033     f = fopen ("debug.camd", "r") ;
00034     if (f == (FILE *) NULL)
00035     {
00036   CAMD_debug = -999 ;
00037     }
00038     else
00039     {
00040   fscanf (f, ID, &CAMD_debug) ;
00041   fclose (f) ;
00042     }
00043     if (CAMD_debug >= 0)
00044     {
00045   printf ("%s: CAMD_debug_init, D= "ID"\n", s, CAMD_debug) ;
00046     }
00047 }
00048 
00049 /* ========================================================================= */
00050 /* === CAMD_dump =========================================================== */
00051 /* ========================================================================= */
00052 
00053 /* Dump CAMD's data structure, except for the hash buckets.  This routine
00054  * cannot be called when the hash buckets are non-empty.
00055  */
00056 
00057 GLOBAL void CAMD_dump (
00058     Int n,      /* A is n-by-n */
00059     Int Pe [ ],     /* pe [0..n-1]: index in iw of start of row i */
00060     Int Iw [ ],     /* workspace of size iwlen, iwlen [0..pfree-1]
00061          * holds the matrix on input */
00062     Int Len [ ],    /* len [0..n-1]: length for row i */
00063     Int iwlen,      /* length of iw */
00064     Int pfree,      /* iw [pfree ... iwlen-1] is empty on input */
00065     Int Nv [ ],     /* nv [0..n-1] */
00066     Int Next [ ],   /* next [0..n-1] */
00067     Int Last [ ],   /* last [0..n-1] */
00068     Int Head [ ],   /* head [0..n-1] */
00069     Int Elen [ ],   /* size n */
00070     Int Degree [ ], /* size n */
00071     Int W [ ],      /* size n */
00072     Int nel,
00073     Int BucketSet [ ],
00074     const Int C [ ],
00075     Int CurC
00076 )
00077 {
00078     Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ;
00079 
00080     if (CAMD_debug < 0) return ;
00081     ASSERT (pfree <= iwlen) ;
00082     CAMD_DEBUG3 (("\nCAMD dump, pfree: "ID"\n", pfree)) ;
00083     for (i = 0 ; i < n ; i++)
00084     {
00085   pe = Pe [i] ;
00086   elen = Elen [i] ;
00087   nv = Nv [i] ;
00088   len = Len [i] ;
00089   w = W [i] ;
00090 
00091   if (elen >= EMPTY)
00092   {
00093       if (nv == 0)
00094       {
00095     CAMD_DEBUG4 (("\nI "ID": nonprincipal:    ", i)) ;
00096     ASSERT (elen == EMPTY) ;
00097     if (pe == FLIP(n))
00098     {
00099         CAMD_DEBUG4 ((" dense node\n")) ;
00100         ASSERT (w == 1) ;
00101     }
00102     else
00103     {
00104         ASSERT (pe < EMPTY) ;
00105         CAMD_DEBUG4 ((" i "ID" -> parent "ID"\n", i, FLIP (Pe[i])));
00106     }
00107       }
00108       else
00109       {
00110     CAMD_DEBUG4 (("\nI "ID": active principal supervariable:\n",i));
00111     CAMD_DEBUG4 (("   nv(i): "ID"  Flag: %d\n", nv, (nv < 0))) ;
00112     ASSERT (elen >= 0) ;
00113     ASSERT (nv > 0 && pe >= 0) ;
00114     p = pe ;
00115     CAMD_DEBUG4 (("   e/s: ")) ;
00116     if (elen == 0) CAMD_DEBUG4 ((" : ")) ;
00117     ASSERT (pe + len <= pfree) ;
00118     for (k = 0 ; k < len ; k++)
00119     {
00120         j = Iw [p] ;
00121         CAMD_DEBUG4 (("  "ID"", j)) ;
00122         ASSERT (j >= 0 && j < n) ;
00123         if (k == elen-1) CAMD_DEBUG4 ((" : ")) ;
00124         p++ ;
00125     }
00126     CAMD_DEBUG4 (("\n")) ;
00127       }
00128   }
00129   else
00130   {
00131       e = i ;
00132       if (w == 0)
00133       {
00134     CAMD_DEBUG4 (("\nE "ID": absorbed element: w "ID"\n", e, w)) ;
00135     ASSERT (nv > 0 && pe < 0) ;
00136     CAMD_DEBUG4 ((" e "ID" -> parent "ID"\n", e, FLIP (Pe [e]))) ;
00137       }
00138       else
00139       {
00140     CAMD_DEBUG4 (("\nE "ID": unabsorbed element: w "ID"\n", e, w)) ;
00141     ASSERT (nv > 0 && pe >= 0) ;
00142     p = pe ;
00143     CAMD_DEBUG4 ((" : ")) ;
00144     ASSERT (pe + len <= pfree) ;
00145     for (k = 0 ; k < len ; k++)
00146     {
00147         j = Iw [p] ;
00148         CAMD_DEBUG4 (("  "ID"", j)) ;
00149         ASSERT (j >= 0 && j < n) ;
00150         p++ ;
00151     }
00152     CAMD_DEBUG4 (("\n")) ;
00153       }
00154   }
00155   CAMD_DEBUG4 (("C[i] is :"ID"\n", (C == NULL) ? 0 : C [i]));
00156     }
00157 
00158     /* this routine cannot be called when the hash buckets are non-empty */
00159     CAMD_DEBUG4 (("\nDegree lists:\n")) ;
00160     if (nel >= 0)
00161     {
00162   cnt = 0 ;
00163   for (deg = 0 ; deg < n ; deg++)
00164   {
00165       if (Head [deg] == EMPTY) continue ;
00166       ilast = EMPTY ;
00167       CAMD_DEBUG4 ((ID": \n", deg)) ;
00168       for (i = Head [deg] ; i != EMPTY ; i = Next [i])
00169       {
00170     CAMD_DEBUG4 (("   "ID" : next "ID" last "ID" deg "ID"\n",
00171         i, Next [i], Last [i], Degree [i])) ;
00172     ASSERT (i >= 0 && i < n && ilast == Last [i] &&
00173         deg == Degree [i]) ;
00174     cnt += Nv [i] ;
00175     ilast = i ;
00176       }
00177       CAMD_DEBUG4 (("\n")) ;
00178   }
00179     }
00180     
00181     CAMD_DEBUG4(("\nCurrent C[i] is "ID". current Buckets are:\n", CurC)) ;
00182     for (i = 0 ; i < n ; i++)
00183     {
00184   if ((C == NULL) ? 1 : (C [BucketSet [i]] <= CurC))
00185             CAMD_DEBUG4((ID",",BucketSet [i]));
00186     }
00187     CAMD_DEBUG4 (("\n")) ;
00188 }
00189 
00190 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines