/* ========================================================================= */1/* === AMD_dump ============================================================ */2/* ========================================================================= */34/* ------------------------------------------------------------------------- */5/* AMD Version 1.1 (Jan. 21, 2004), Copyright (c) 2004 by Timothy A. Davis, */6/* Patrick R. Amestoy, and Iain S. Duff. See ../README for License. */7/* email: [email protected] CISE Department, Univ. of Florida. */8/* web: http://www.cise.ufl.edu/research/sparse/amd */9/* ------------------------------------------------------------------------- */1011/* Debugging routines for AMD. Not used if NDEBUG is not defined at compile-12* time (the default). See comments in amd_internal.h on how to enable13* debugging. Not user-callable.14*/1516#include "amd_internal.h"1718#ifndef NDEBUG1920/* This global variable is present only when debugging */21GLOBAL Int AMD_debug = -999 ; /* default is no debug printing */2223/* ========================================================================= */24/* === AMD_debug_init ====================================================== */25/* ========================================================================= */2627/* Sets the debug print level, by reading the file debug.amd (if it exists) */2829GLOBAL void AMD_debug_init ( char *s )30{31FILE *f ;32f = fopen ("debug.amd", "r") ;33if (f == (FILE *) NULL)34{35AMD_debug = -999 ;36}37else38{39fscanf (f, ID, &AMD_debug) ;40fclose (f) ;41}42if (AMD_debug >= 0) printf ("%s: AMD_debug_init, D= "ID"\n", s, AMD_debug);43}4445/* ========================================================================= */46/* === AMD_dump ============================================================ */47/* ========================================================================= */4849/* Dump AMD's data structure, except for the hash buckets. This routine50* cannot be called when the hash buckets are non-empty.51*/5253GLOBAL void AMD_dump (54Int n, /* A is n-by-n */55Int Pe [ ], /* pe [0..n-1]: index in iw of start of row i */56Int Iw [ ], /* workspace of size iwlen, iwlen [0..pfree-1]57* holds the matrix on input */58Int Len [ ], /* len [0..n-1]: length for row i */59Int iwlen, /* length of iw */60Int pfree, /* iw [pfree ... iwlen-1] is empty on input */61Int Nv [ ], /* nv [0..n-1] */62Int Next [ ], /* next [0..n-1] */63Int Last [ ], /* last [0..n-1] */64Int Head [ ], /* head [0..n-1] */65Int Elen [ ], /* size n */66Int Degree [ ], /* size n */67Int W [ ], /* size n */68Int nel69)70{71Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ;7273if (AMD_debug < 0) return ;74ASSERT (pfree <= iwlen) ;75for (i = 0 ; i < n ; i++)76{77pe = Pe [i] ;78elen = Elen [i] ;79nv = Nv [i] ;80len = Len [i] ;81w = W [i] ;8283if (elen >= EMPTY)84{85if (nv == 0)86{87AMD_DEBUG3 (("\nI "ID": nonprincipal: ", i)) ;88ASSERT (elen == EMPTY) ;89if (pe == EMPTY)90{91AMD_DEBUG3 ((" dense node\n")) ;92ASSERT (w == 1) ;93}94else95{96ASSERT (pe < EMPTY) ;97AMD_DEBUG3 ((" i "ID" -> parent "ID"\n", i, FLIP (Pe[i])));98}99}100else101{102AMD_DEBUG3 (("\nI "ID": active principal supervariable:\n",i));103AMD_DEBUG3 ((" nv(i): "ID" Flag: %d\n", nv, (nv < 0))) ;104ASSERT (elen >= 0) ;105ASSERT (nv > 0 && pe >= 0) ;106p = pe ;107AMD_DEBUG3 ((" e/s: ")) ;108if (elen == 0) AMD_DEBUG3 ((" : ")) ;109ASSERT (pe < pfree) ;110for (k = 0 ; k < len ; k++)111{112j = Iw [p] ;113AMD_DEBUG3 ((" "ID"", j)) ;114ASSERT (j >= 0 && j < n) ;115if (k == elen-1) AMD_DEBUG3 ((" : ")) ;116p++ ;117}118AMD_DEBUG3 (("\n")) ;119}120}121else122{123e = i ;124if (w == 0)125{126AMD_DEBUG3 (("\nE "ID": absorbed element: w "ID"\n", e, w)) ;127ASSERT (nv > 0 && pe < 0) ;128AMD_DEBUG3 ((" e "ID" -> parent "ID"\n", e, FLIP (Pe [e]))) ;129}130else131{132AMD_DEBUG3 (("\nE "ID": unabsorbed element: w "ID"\n", e, w)) ;133ASSERT (nv > 0 && pe >= 0) ;134p = pe ;135AMD_DEBUG3 ((" : ")) ;136ASSERT (pe < pfree) ;137for (k = 0 ; k < len ; k++)138{139j = Iw [p] ;140AMD_DEBUG3 ((" "ID"", j)) ;141ASSERT (j >= 0 && j < n) ;142p++ ;143}144AMD_DEBUG3 (("\n")) ;145}146}147}148149/* this routine cannot be called when the hash buckets are non-empty */150AMD_DEBUG3 (("\nDegree lists:\n")) ;151if (nel >= 0)152{153cnt = 0 ;154for (deg = 0 ; deg < n ; deg++)155{156if (Head [deg] == EMPTY) continue ;157ilast = EMPTY ;158AMD_DEBUG3 ((ID": ", deg)) ;159for (i = Head [deg] ; i != EMPTY ; i = Next [i])160{161AMD_DEBUG3 ((" "ID" : next "ID" last "ID" deg "ID"\n",162i, Next [i], Last [i], Degree [i])) ;163ASSERT (i >= 0 && i < n && ilast == Last [i] &&164deg == Degree [i]) ;165cnt += Nv [i] ;166ilast = i ;167}168AMD_DEBUG3 (("\n")) ;169}170ASSERT (cnt == n - nel) ;171}172173}174175#endif176177178