alpar@1: /* ========================================================================= */ alpar@1: /* === AMD_dump ============================================================ */ alpar@1: /* ========================================================================= */ alpar@1: alpar@1: /* ------------------------------------------------------------------------- */ alpar@1: /* AMD, Copyright (c) Timothy A. Davis, */ alpar@1: /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */ alpar@1: /* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */ alpar@1: /* web: http://www.cise.ufl.edu/research/sparse/amd */ alpar@1: /* ------------------------------------------------------------------------- */ alpar@1: alpar@1: /* Debugging routines for AMD. Not used if NDEBUG is not defined at compile- alpar@1: * time (the default). See comments in amd_internal.h on how to enable alpar@1: * debugging. Not user-callable. alpar@1: */ alpar@1: alpar@1: #include "amd_internal.h" alpar@1: alpar@1: #ifndef NDEBUG alpar@1: alpar@1: /* This global variable is present only when debugging */ alpar@1: GLOBAL Int AMD_debug = -999 ; /* default is no debug printing */ alpar@1: alpar@1: /* ========================================================================= */ alpar@1: /* === AMD_debug_init ====================================================== */ alpar@1: /* ========================================================================= */ alpar@1: alpar@1: /* Sets the debug print level, by reading the file debug.amd (if it exists) */ alpar@1: alpar@1: GLOBAL void AMD_debug_init ( char *s ) alpar@1: { alpar@1: FILE *f ; alpar@1: f = fopen ("debug.amd", "r") ; alpar@1: if (f == (FILE *) NULL) alpar@1: { alpar@1: AMD_debug = -999 ; alpar@1: } alpar@1: else alpar@1: { alpar@1: fscanf (f, ID, &AMD_debug) ; alpar@1: fclose (f) ; alpar@1: } alpar@1: if (AMD_debug >= 0) alpar@1: { alpar@1: printf ("%s: AMD_debug_init, D= "ID"\n", s, AMD_debug) ; alpar@1: } alpar@1: } alpar@1: alpar@1: /* ========================================================================= */ alpar@1: /* === AMD_dump ============================================================ */ alpar@1: /* ========================================================================= */ alpar@1: alpar@1: /* Dump AMD's data structure, except for the hash buckets. This routine alpar@1: * cannot be called when the hash buckets are non-empty. alpar@1: */ alpar@1: alpar@1: GLOBAL void AMD_dump ( alpar@1: Int n, /* A is n-by-n */ alpar@1: Int Pe [ ], /* pe [0..n-1]: index in iw of start of row i */ alpar@1: Int Iw [ ], /* workspace of size iwlen, iwlen [0..pfree-1] alpar@1: * holds the matrix on input */ alpar@1: Int Len [ ], /* len [0..n-1]: length for row i */ alpar@1: Int iwlen, /* length of iw */ alpar@1: Int pfree, /* iw [pfree ... iwlen-1] is empty on input */ alpar@1: Int Nv [ ], /* nv [0..n-1] */ alpar@1: Int Next [ ], /* next [0..n-1] */ alpar@1: Int Last [ ], /* last [0..n-1] */ alpar@1: Int Head [ ], /* head [0..n-1] */ alpar@1: Int Elen [ ], /* size n */ alpar@1: Int Degree [ ], /* size n */ alpar@1: Int W [ ], /* size n */ alpar@1: Int nel alpar@1: ) alpar@1: { alpar@1: Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ; alpar@1: alpar@1: if (AMD_debug < 0) return ; alpar@1: ASSERT (pfree <= iwlen) ; alpar@1: AMD_DEBUG3 (("\nAMD dump, pfree: "ID"\n", pfree)) ; alpar@1: for (i = 0 ; i < n ; i++) alpar@1: { alpar@1: pe = Pe [i] ; alpar@1: elen = Elen [i] ; alpar@1: nv = Nv [i] ; alpar@1: len = Len [i] ; alpar@1: w = W [i] ; alpar@1: alpar@1: if (elen >= EMPTY) alpar@1: { alpar@1: if (nv == 0) alpar@1: { alpar@1: AMD_DEBUG3 (("\nI "ID": nonprincipal: ", i)) ; alpar@1: ASSERT (elen == EMPTY) ; alpar@1: if (pe == EMPTY) alpar@1: { alpar@1: AMD_DEBUG3 ((" dense node\n")) ; alpar@1: ASSERT (w == 1) ; alpar@1: } alpar@1: else alpar@1: { alpar@1: ASSERT (pe < EMPTY) ; alpar@1: AMD_DEBUG3 ((" i "ID" -> parent "ID"\n", i, FLIP (Pe[i]))); alpar@1: } alpar@1: } alpar@1: else alpar@1: { alpar@1: AMD_DEBUG3 (("\nI "ID": active principal supervariable:\n",i)); alpar@1: AMD_DEBUG3 ((" nv(i): "ID" Flag: %d\n", nv, (nv < 0))) ; alpar@1: ASSERT (elen >= 0) ; alpar@1: ASSERT (nv > 0 && pe >= 0) ; alpar@1: p = pe ; alpar@1: AMD_DEBUG3 ((" e/s: ")) ; alpar@1: if (elen == 0) AMD_DEBUG3 ((" : ")) ; alpar@1: ASSERT (pe + len <= pfree) ; alpar@1: for (k = 0 ; k < len ; k++) alpar@1: { alpar@1: j = Iw [p] ; alpar@1: AMD_DEBUG3 ((" "ID"", j)) ; alpar@1: ASSERT (j >= 0 && j < n) ; alpar@1: if (k == elen-1) AMD_DEBUG3 ((" : ")) ; alpar@1: p++ ; alpar@1: } alpar@1: AMD_DEBUG3 (("\n")) ; alpar@1: } alpar@1: } alpar@1: else alpar@1: { alpar@1: e = i ; alpar@1: if (w == 0) alpar@1: { alpar@1: AMD_DEBUG3 (("\nE "ID": absorbed element: w "ID"\n", e, w)) ; alpar@1: ASSERT (nv > 0 && pe < 0) ; alpar@1: AMD_DEBUG3 ((" e "ID" -> parent "ID"\n", e, FLIP (Pe [e]))) ; alpar@1: } alpar@1: else alpar@1: { alpar@1: AMD_DEBUG3 (("\nE "ID": unabsorbed element: w "ID"\n", e, w)) ; alpar@1: ASSERT (nv > 0 && pe >= 0) ; alpar@1: p = pe ; alpar@1: AMD_DEBUG3 ((" : ")) ; alpar@1: ASSERT (pe + len <= pfree) ; alpar@1: for (k = 0 ; k < len ; k++) alpar@1: { alpar@1: j = Iw [p] ; alpar@1: AMD_DEBUG3 ((" "ID"", j)) ; alpar@1: ASSERT (j >= 0 && j < n) ; alpar@1: p++ ; alpar@1: } alpar@1: AMD_DEBUG3 (("\n")) ; alpar@1: } alpar@1: } alpar@1: } alpar@1: alpar@1: /* this routine cannot be called when the hash buckets are non-empty */ alpar@1: AMD_DEBUG3 (("\nDegree lists:\n")) ; alpar@1: if (nel >= 0) alpar@1: { alpar@1: cnt = 0 ; alpar@1: for (deg = 0 ; deg < n ; deg++) alpar@1: { alpar@1: if (Head [deg] == EMPTY) continue ; alpar@1: ilast = EMPTY ; alpar@1: AMD_DEBUG3 ((ID": \n", deg)) ; alpar@1: for (i = Head [deg] ; i != EMPTY ; i = Next [i]) alpar@1: { alpar@1: AMD_DEBUG3 ((" "ID" : next "ID" last "ID" deg "ID"\n", alpar@1: i, Next [i], Last [i], Degree [i])) ; alpar@1: ASSERT (i >= 0 && i < n && ilast == Last [i] && alpar@1: deg == Degree [i]) ; alpar@1: cnt += Nv [i] ; alpar@1: ilast = i ; alpar@1: } alpar@1: AMD_DEBUG3 (("\n")) ; alpar@1: } alpar@1: ASSERT (cnt == n - nel) ; alpar@1: } alpar@1: alpar@1: } alpar@1: alpar@1: #endif