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