Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/umfpack/src/amd/amd_dump.c
3203 views
1
/* ========================================================================= */
2
/* === AMD_dump ============================================================ */
3
/* ========================================================================= */
4
5
/* ------------------------------------------------------------------------- */
6
/* AMD Version 1.1 (Jan. 21, 2004), Copyright (c) 2004 by Timothy A. Davis, */
7
/* Patrick R. Amestoy, and Iain S. Duff. See ../README for License. */
8
/* email: [email protected] CISE Department, Univ. of Florida. */
9
/* web: http://www.cise.ufl.edu/research/sparse/amd */
10
/* ------------------------------------------------------------------------- */
11
12
/* Debugging routines for AMD. Not used if NDEBUG is not defined at compile-
13
* time (the default). See comments in amd_internal.h on how to enable
14
* debugging. Not user-callable.
15
*/
16
17
#include "amd_internal.h"
18
19
#ifndef NDEBUG
20
21
/* This global variable is present only when debugging */
22
GLOBAL Int AMD_debug = -999 ; /* default is no debug printing */
23
24
/* ========================================================================= */
25
/* === AMD_debug_init ====================================================== */
26
/* ========================================================================= */
27
28
/* Sets the debug print level, by reading the file debug.amd (if it exists) */
29
30
GLOBAL void AMD_debug_init ( char *s )
31
{
32
FILE *f ;
33
f = fopen ("debug.amd", "r") ;
34
if (f == (FILE *) NULL)
35
{
36
AMD_debug = -999 ;
37
}
38
else
39
{
40
fscanf (f, ID, &AMD_debug) ;
41
fclose (f) ;
42
}
43
if (AMD_debug >= 0) printf ("%s: AMD_debug_init, D= "ID"\n", s, AMD_debug);
44
}
45
46
/* ========================================================================= */
47
/* === AMD_dump ============================================================ */
48
/* ========================================================================= */
49
50
/* Dump AMD's data structure, except for the hash buckets. This routine
51
* cannot be called when the hash buckets are non-empty.
52
*/
53
54
GLOBAL void AMD_dump (
55
Int n, /* A is n-by-n */
56
Int Pe [ ], /* pe [0..n-1]: index in iw of start of row i */
57
Int Iw [ ], /* workspace of size iwlen, iwlen [0..pfree-1]
58
* holds the matrix on input */
59
Int Len [ ], /* len [0..n-1]: length for row i */
60
Int iwlen, /* length of iw */
61
Int pfree, /* iw [pfree ... iwlen-1] is empty on input */
62
Int Nv [ ], /* nv [0..n-1] */
63
Int Next [ ], /* next [0..n-1] */
64
Int Last [ ], /* last [0..n-1] */
65
Int Head [ ], /* head [0..n-1] */
66
Int Elen [ ], /* size n */
67
Int Degree [ ], /* size n */
68
Int W [ ], /* size n */
69
Int nel
70
)
71
{
72
Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ;
73
74
if (AMD_debug < 0) return ;
75
ASSERT (pfree <= iwlen) ;
76
for (i = 0 ; i < n ; i++)
77
{
78
pe = Pe [i] ;
79
elen = Elen [i] ;
80
nv = Nv [i] ;
81
len = Len [i] ;
82
w = W [i] ;
83
84
if (elen >= EMPTY)
85
{
86
if (nv == 0)
87
{
88
AMD_DEBUG3 (("\nI "ID": nonprincipal: ", i)) ;
89
ASSERT (elen == EMPTY) ;
90
if (pe == EMPTY)
91
{
92
AMD_DEBUG3 ((" dense node\n")) ;
93
ASSERT (w == 1) ;
94
}
95
else
96
{
97
ASSERT (pe < EMPTY) ;
98
AMD_DEBUG3 ((" i "ID" -> parent "ID"\n", i, FLIP (Pe[i])));
99
}
100
}
101
else
102
{
103
AMD_DEBUG3 (("\nI "ID": active principal supervariable:\n",i));
104
AMD_DEBUG3 ((" nv(i): "ID" Flag: %d\n", nv, (nv < 0))) ;
105
ASSERT (elen >= 0) ;
106
ASSERT (nv > 0 && pe >= 0) ;
107
p = pe ;
108
AMD_DEBUG3 ((" e/s: ")) ;
109
if (elen == 0) AMD_DEBUG3 ((" : ")) ;
110
ASSERT (pe < pfree) ;
111
for (k = 0 ; k < len ; k++)
112
{
113
j = Iw [p] ;
114
AMD_DEBUG3 ((" "ID"", j)) ;
115
ASSERT (j >= 0 && j < n) ;
116
if (k == elen-1) AMD_DEBUG3 ((" : ")) ;
117
p++ ;
118
}
119
AMD_DEBUG3 (("\n")) ;
120
}
121
}
122
else
123
{
124
e = i ;
125
if (w == 0)
126
{
127
AMD_DEBUG3 (("\nE "ID": absorbed element: w "ID"\n", e, w)) ;
128
ASSERT (nv > 0 && pe < 0) ;
129
AMD_DEBUG3 ((" e "ID" -> parent "ID"\n", e, FLIP (Pe [e]))) ;
130
}
131
else
132
{
133
AMD_DEBUG3 (("\nE "ID": unabsorbed element: w "ID"\n", e, w)) ;
134
ASSERT (nv > 0 && pe >= 0) ;
135
p = pe ;
136
AMD_DEBUG3 ((" : ")) ;
137
ASSERT (pe < pfree) ;
138
for (k = 0 ; k < len ; k++)
139
{
140
j = Iw [p] ;
141
AMD_DEBUG3 ((" "ID"", j)) ;
142
ASSERT (j >= 0 && j < n) ;
143
p++ ;
144
}
145
AMD_DEBUG3 (("\n")) ;
146
}
147
}
148
}
149
150
/* this routine cannot be called when the hash buckets are non-empty */
151
AMD_DEBUG3 (("\nDegree lists:\n")) ;
152
if (nel >= 0)
153
{
154
cnt = 0 ;
155
for (deg = 0 ; deg < n ; deg++)
156
{
157
if (Head [deg] == EMPTY) continue ;
158
ilast = EMPTY ;
159
AMD_DEBUG3 ((ID": ", deg)) ;
160
for (i = Head [deg] ; i != EMPTY ; i = Next [i])
161
{
162
AMD_DEBUG3 ((" "ID" : next "ID" last "ID" deg "ID"\n",
163
i, Next [i], Last [i], Degree [i])) ;
164
ASSERT (i >= 0 && i < n && ilast == Last [i] &&
165
deg == Degree [i]) ;
166
cnt += Nv [i] ;
167
ilast = i ;
168
}
169
AMD_DEBUG3 (("\n")) ;
170
}
171
ASSERT (cnt == n - nel) ;
172
}
173
174
}
175
176
#endif
177
178