Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
amesos_camd_dump.c
Go to the documentation of this file.
1 /* ========================================================================= */
2 /* === CAMD_dump =========================================================== */
3 /* ========================================================================= */
4 
5 /* ------------------------------------------------------------------------- */
6 /* CAMD, Copyright (c) Timothy A. Davis, Yanqing Chen, */
7 /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8 /* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
9 /* web: http://www.cise.ufl.edu/research/sparse/camd */
10 /* ------------------------------------------------------------------------- */
11 
12 /* Debugging routines for CAMD. Not used if NDEBUG is not defined at compile-
13  * time (the default). See comments in camd_internal.h on how to enable
14  * debugging. Not user-callable.
15  */
16 
17 #include "amesos_camd_internal.h"
18 
19 #ifndef NDEBUG
20 
21 /* This global variable is present only when debugging */
22 GLOBAL Int CAMD_debug = -999 ; /* default is no debug printing */
23 
24 /* ========================================================================= */
25 /* === CAMD_debug_init ===================================================== */
26 /* ========================================================================= */
27 
28 /* Sets the debug print level, by reading the file debug.camd (if it exists) */
29 
30 GLOBAL void CAMD_debug_init ( char *s )
31 {
32  FILE *f ;
33  f = fopen ("debug.camd", "r") ;
34  if (f == (FILE *) NULL)
35  {
36  CAMD_debug = -999 ;
37  }
38  else
39  {
40  fscanf (f, ID, &CAMD_debug) ;
41  fclose (f) ;
42  }
43  if (CAMD_debug >= 0)
44  {
45  printf ("%s: CAMD_debug_init, D= "ID"\n", s, CAMD_debug) ;
46  }
47 }
48 
49 /* ========================================================================= */
50 /* === CAMD_dump =========================================================== */
51 /* ========================================================================= */
52 
53 /* Dump CAMD's data structure, except for the hash buckets. This routine
54  * cannot be called when the hash buckets are non-empty.
55  */
56 
58  Int n, /* A is n-by-n */
59  Int Pe [ ], /* pe [0..n-1]: index in iw of start of row i */
60  Int Iw [ ], /* workspace of size iwlen, iwlen [0..pfree-1]
61  * holds the matrix on input */
62  Int Len [ ], /* len [0..n-1]: length for row i */
63  Int iwlen, /* length of iw */
64  Int pfree, /* iw [pfree ... iwlen-1] is empty on input */
65  Int Nv [ ], /* nv [0..n-1] */
66  Int Next [ ], /* next [0..n-1] */
67  Int Last [ ], /* last [0..n-1] */
68  Int Head [ ], /* head [0..n-1] */
69  Int Elen [ ], /* size n */
70  Int Degree [ ], /* size n */
71  Int W [ ], /* size n */
72  Int nel,
73  Int BucketSet [ ],
74  const Int C [ ],
75  Int CurC
76 )
77 {
78  Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ;
79 
80  if (CAMD_debug < 0) return ;
81  ASSERT (pfree <= iwlen) ;
82  CAMD_DEBUG3 (("\nCAMD dump, pfree: "ID"\n", pfree)) ;
83  for (i = 0 ; i < n ; i++)
84  {
85  pe = Pe [i] ;
86  elen = Elen [i] ;
87  nv = Nv [i] ;
88  len = Len [i] ;
89  w = W [i] ;
90 
91  if (elen >= EMPTY)
92  {
93  if (nv == 0)
94  {
95  CAMD_DEBUG4 (("\nI "ID": nonprincipal: ", i)) ;
96  ASSERT (elen == EMPTY) ;
97  if (pe == FLIP(n))
98  {
99  CAMD_DEBUG4 ((" dense node\n")) ;
100  ASSERT (w == 1) ;
101  }
102  else
103  {
104  ASSERT (pe < EMPTY) ;
105  CAMD_DEBUG4 ((" i "ID" -> parent "ID"\n", i, FLIP (Pe[i])));
106  }
107  }
108  else
109  {
110  CAMD_DEBUG4 (("\nI "ID": active principal supervariable:\n",i));
111  CAMD_DEBUG4 ((" nv(i): "ID" Flag: %d\n", nv, (nv < 0))) ;
112  ASSERT (elen >= 0) ;
113  ASSERT (nv > 0 && pe >= 0) ;
114  p = pe ;
115  CAMD_DEBUG4 ((" e/s: ")) ;
116  if (elen == 0) CAMD_DEBUG4 ((" : ")) ;
117  ASSERT (pe + len <= pfree) ;
118  for (k = 0 ; k < len ; k++)
119  {
120  j = Iw [p] ;
121  CAMD_DEBUG4 ((" "ID"", j)) ;
122  ASSERT (j >= 0 && j < n) ;
123  if (k == elen-1) CAMD_DEBUG4 ((" : ")) ;
124  p++ ;
125  }
126  CAMD_DEBUG4 (("\n")) ;
127  }
128  }
129  else
130  {
131  e = i ;
132  if (w == 0)
133  {
134  CAMD_DEBUG4 (("\nE "ID": absorbed element: w "ID"\n", e, w)) ;
135  ASSERT (nv > 0 && pe < 0) ;
136  CAMD_DEBUG4 ((" e "ID" -> parent "ID"\n", e, FLIP (Pe [e]))) ;
137  }
138  else
139  {
140  CAMD_DEBUG4 (("\nE "ID": unabsorbed element: w "ID"\n", e, w)) ;
141  ASSERT (nv > 0 && pe >= 0) ;
142  p = pe ;
143  CAMD_DEBUG4 ((" : ")) ;
144  ASSERT (pe + len <= pfree) ;
145  for (k = 0 ; k < len ; k++)
146  {
147  j = Iw [p] ;
148  CAMD_DEBUG4 ((" "ID"", j)) ;
149  ASSERT (j >= 0 && j < n) ;
150  p++ ;
151  }
152  CAMD_DEBUG4 (("\n")) ;
153  }
154  }
155  CAMD_DEBUG4 (("C[i] is :"ID"\n", (C == NULL) ? 0 : C [i]));
156  }
157 
158  /* this routine cannot be called when the hash buckets are non-empty */
159  CAMD_DEBUG4 (("\nDegree lists:\n")) ;
160  if (nel >= 0)
161  {
162  cnt = 0 ;
163  for (deg = 0 ; deg < n ; deg++)
164  {
165  if (Head [deg] == EMPTY) continue ;
166  ilast = EMPTY ;
167  CAMD_DEBUG4 ((ID": \n", deg)) ;
168  for (i = Head [deg] ; i != EMPTY ; i = Next [i])
169  {
170  CAMD_DEBUG4 ((" "ID" : next "ID" last "ID" deg "ID"\n",
171  i, Next [i], Last [i], Degree [i])) ;
172  ASSERT (i >= 0 && i < n && ilast == Last [i] &&
173  deg == Degree [i]) ;
174  cnt += Nv [i] ;
175  ilast = i ;
176  }
177  CAMD_DEBUG4 (("\n")) ;
178  }
179  }
180 
181  CAMD_DEBUG4(("\nCurrent C[i] is "ID". current Buckets are:\n", CurC)) ;
182  for (i = 0 ; i < n ; i++)
183  {
184  if ((C == NULL) ? 1 : (C [BucketSet [i]] <= CurC))
185  CAMD_DEBUG4((ID",",BucketSet [i]));
186  }
187  CAMD_DEBUG4 (("\n")) ;
188 }
189 
190 #endif
void f()
#define EMPTY
#define GLOBAL
#define Int
GLOBAL void CAMD_debug_init(char *s)
GLOBAL void CAMD_dump(Int n, Int Pe[], Int Iw[], Int Len[], Int iwlen, Int pfree, Int Nv[], Int Next[], Int Last[], Int Head[], Int Elen[], Int Degree[], Int W[], Int nel, Int BucketSet[], const Int C[], Int CurC)
#define CAMD_DEBUG3(params)
#define NULL
#define ASSERT(expression)
#define FLIP(i)
#define ID
#define CAMD_DEBUG4(params)
GLOBAL Int CAMD_debug