Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/umfpack/src/umfpack/umf_dump.c
3203 views
1
/* ========================================================================== */
2
/* === UMF_dump ============================================================= */
3
/* ========================================================================== */
4
5
/* -------------------------------------------------------------------------- */
6
/* UMFPACK Version 4.4, Copyright (c) 2005 by Timothy A. Davis. CISE Dept, */
7
/* Univ. of Florida. All Rights Reserved. See ../Doc/License for License. */
8
/* web: http://www.cise.ufl.edu/research/sparse/umfpack */
9
/* -------------------------------------------------------------------------- */
10
11
/* These routines, and external variables, are used only when debugging. */
12
/* If debugging is disabled (for normal operation) then this entire file */
13
/* becomes empty */
14
15
#include "umf_internal.h"
16
17
#ifndef NDEBUG
18
19
/* These global debugging variables and arrays do not exist if debugging */
20
/* is disabled at compile time (which is the default). */
21
GLOBAL Int UMF_debug = -999 ;
22
GLOBAL Int UMF_allocfail = FALSE ;
23
GLOBAL double UMF_gprob = -1.0 ;
24
25
/* static debugging arrays used only in UMF_dump_rowcol */
26
PRIVATE Int UMF_DBflag = 0 ;
27
PRIVATE Int UMF_DBpacked [UMF_DBMAX+1] ;
28
PRIVATE Int UMF_DBscatter [UMF_DBMAX+1] ;
29
30
/* ========================================================================== */
31
/* === UMF_DBinit =========================================================== */
32
/* ========================================================================== */
33
34
/* clear the debugging arrays */
35
36
PRIVATE void UMF_DBinit
37
(
38
void
39
)
40
{
41
Int i ;
42
43
/* Int_MAX is defined in umfpack.h */
44
if (UMF_DBflag < 1 || UMF_DBflag == Int_MAX)
45
{
46
/* clear the debugging arrays */
47
UMF_DBflag = 0 ;
48
for (i = 0 ; i <= UMF_DBMAX ; i++)
49
{
50
UMF_DBscatter [i] = 0 ;
51
UMF_DBpacked [i] = 0 ;
52
}
53
}
54
55
UMF_DBflag++ ;
56
57
/* UMF_DBflag > UMF_DBscatter [0...UMF_DBmax] is now true */
58
}
59
60
/* ========================================================================== */
61
/* === UMF_dump_dense ======================================================= */
62
/* ========================================================================== */
63
64
GLOBAL void UMF_dump_dense
65
(
66
Entry *C,
67
Int dim,
68
Int m,
69
Int n
70
)
71
{
72
73
/* dump C [1..m,1..n], with column dimenstion dim */
74
Int i, j;
75
76
if (UMF_debug < 7) return ;
77
if (C == (Entry *) NULL)
78
{
79
DEBUG7 (("No dense matrix allocated\n")) ;
80
return ;
81
}
82
DEBUG8 ((" dimension= "ID" rows= "ID" cols= "ID"\n", dim, m, n)) ;
83
84
for (i = 0 ; i < m ; i++)
85
{
86
DEBUG9 ((ID": ", i)) ;
87
for (j = 0 ; j < n ; j++)
88
{
89
EDEBUG9 (C [i+j*dim]) ;
90
if (j % 6 == 5) DEBUG9 (("\n ")) ;
91
}
92
DEBUG9 (("\n")) ;
93
}
94
95
for (i = 0 ; i < m ; i++)
96
{
97
for (j = 0 ; j < n ; j++)
98
{
99
if (IS_ZERO (C [i+j*dim]))
100
{
101
DEBUG8 ((".")) ;
102
}
103
else
104
{
105
DEBUG8 (("X")) ;
106
}
107
}
108
DEBUG8 (("\n")) ;
109
}
110
}
111
112
/* ========================================================================== */
113
/* === UMF_dump_element ===================================================== */
114
/* ========================================================================== */
115
116
GLOBAL void UMF_dump_element
117
(
118
NumericType *Numeric,
119
WorkType *Work,
120
Int e,
121
Int clean
122
)
123
{
124
125
Int i, j, k, *Rows, *Cols, nrows, ncols, *E, row, col,
126
*Row_degree, *Col_degree ;
127
Entry *C ;
128
Element *ep ;
129
Unit *p ;
130
131
if (UMF_debug < 7) return ;
132
133
if (e == 0)
134
{
135
UMF_dump_current_front (Numeric, Work, FALSE) ;
136
return ;
137
}
138
139
DEBUG7 (("\n====================ELEMENT: "ID" ", e)) ;
140
if (!Numeric || !Work || !Numeric->Memory)
141
{
142
DEBUG7 ((" No Numeric, Work\n")) ;
143
return ;
144
}
145
DEBUG7 ((" nel: "ID" of "ID, e, Work->nel)) ;
146
E = Work->E ;
147
if (!E)
148
{
149
DEBUG7 ((" No elements\n")) ;
150
return ;
151
}
152
if (e < 0 || e > Work->nel)
153
{
154
DEBUG7 (("e out of range!\n")) ;
155
return ;
156
}
157
if (!E [e])
158
{
159
DEBUG7 ((" deallocated\n")) ;
160
return ;
161
}
162
DEBUG7 (("\n")) ;
163
Col_degree = Numeric->Cperm ;
164
Row_degree = Numeric->Rperm ;
165
166
p = Numeric->Memory + E [e] ;
167
DEBUG7 (("ep "ID"\n", (Int) (p-Numeric->Memory))) ;
168
GET_ELEMENT (ep, p, Cols, Rows, ncols, nrows, C) ;
169
DEBUG7 (("nrows "ID" nrowsleft "ID"\n", nrows, ep->nrowsleft)) ;
170
DEBUG7 (("ncols "ID" ncolsleft "ID"\n", ncols, ep->ncolsleft)) ;
171
DEBUG7 (("cdeg-cdeg0 "ID" rdeg-rdeg0 "ID" next "ID"\n",
172
ep->cdeg - Work->cdeg0, ep->rdeg - Work->rdeg0, ep->next)) ;
173
174
DEBUG8 (("rows: ")) ;
175
k = 0 ;
176
for (i = 0 ; i < ep->nrows ; i++)
177
{
178
row = Rows [i] ;
179
if (row >= 0)
180
{
181
DEBUG8 ((" "ID, row)) ;
182
ASSERT (row < Work->n_row) ;
183
if ((k++ % 10) == 9) DEBUG8 (("\n")) ;
184
ASSERT (IMPLIES (clean, NON_PIVOTAL_ROW (row))) ;
185
}
186
}
187
188
DEBUG8 (("\ncols: ")) ;
189
k = 0 ;
190
for (j = 0 ; j < ep->ncols ; j++)
191
{
192
col = Cols [j] ;
193
if (col >= 0)
194
{
195
DEBUG8 ((" "ID, col)) ;
196
ASSERT (col < Work->n_col) ;
197
if ((k++ % 10) == 9) DEBUG8 (("\n")) ;
198
ASSERT (IMPLIES (clean, NON_PIVOTAL_COL (col))) ;
199
}
200
}
201
202
DEBUG8 (("\nvalues:\n")) ;
203
if (UMF_debug >= 9)
204
{
205
for (i = 0 ; i < ep->nrows ; i++)
206
{
207
row = Rows [i] ;
208
if (row >= 0)
209
{
210
DEBUG9 ((ID": ", row)) ;
211
k = 0 ;
212
for (j = 0 ; j < ep->ncols ; j++)
213
{
214
col = Cols [j] ;
215
if (col >= 0)
216
{
217
EDEBUG9 (C [i+j*ep->nrows]) ;
218
if (k++ % 6 == 5) DEBUG9 (("\n ")) ;
219
}
220
}
221
DEBUG9 (("\n")) ;
222
}
223
}
224
}
225
226
DEBUG7 (("====================\n")) ;
227
}
228
229
230
/* ========================================================================== */
231
/* === UMF_dump_rowcol ====================================================== */
232
/* ========================================================================== */
233
234
/* dump a row or a column, from one or more memory spaces */
235
/* return exact degree */
236
237
GLOBAL void UMF_dump_rowcol
238
(
239
Int dumpwhich, /* 0 for row, 1 for column */
240
NumericType *Numeric,
241
WorkType *Work,
242
Int dumpindex, /* row or column index to dump */
243
Int check_degree /* true if degree is to be checked */
244
)
245
{
246
Entry value ;
247
Entry *C ;
248
Int f, nrows, j, jj, len, e, deg, index, n_row, n_col, *Cols, *Rows, nn,
249
dumpdeg, ncols, preve, *E, tpi, *Pattern, approx_deg, not_in_use ;
250
Tuple *tp, *tend ;
251
Element *ep ;
252
Int *Row_tuples, *Row_degree, *Row_tlen ;
253
Int *Col_tuples, *Col_degree, *Col_tlen ;
254
Unit *p ;
255
Int is_there ;
256
257
/* clear the debugging arrays */
258
UMF_DBinit () ;
259
260
if (dumpwhich == 0)
261
{
262
DEBUG7 (("\n====================ROW: "ID, dumpindex)) ;
263
}
264
else
265
{
266
DEBUG7 (("\n====================COL: "ID, dumpindex)) ;
267
}
268
269
if (dumpindex == EMPTY)
270
{
271
DEBUG7 ((" (EMPTY)\n")) ;
272
return ;
273
}
274
275
deg = 0 ;
276
approx_deg = 0 ;
277
278
if (!Numeric || !Work)
279
{
280
DEBUG7 ((" No Numeric, Work\n")) ;
281
return ;
282
}
283
284
n_row = Work->n_row ;
285
n_col = Work->n_col ;
286
nn = MAX (n_row, n_col) ;
287
E = Work->E ;
288
289
Col_degree = Numeric->Cperm ;
290
Row_degree = Numeric->Rperm ;
291
292
Row_tuples = Numeric->Uip ;
293
Row_tlen = Numeric->Uilen ;
294
Col_tuples = Numeric->Lip ;
295
Col_tlen = Numeric->Lilen ;
296
297
if (!E
298
|| !Row_tuples || !Row_degree || !Row_tlen
299
|| !Col_tuples || !Col_degree || !Col_tlen)
300
{
301
DEBUG7 ((" No E, Rows, Cols\n")) ;
302
return ;
303
}
304
305
if (dumpwhich == 0)
306
{
307
/* dump a row */
308
ASSERT (dumpindex >= 0 && dumpindex < n_row) ;
309
if (!NON_PIVOTAL_ROW (dumpindex))
310
{
311
DEBUG7 ((" Pivotal\n")) ;
312
return ;
313
}
314
len = Row_tlen [dumpindex] ;
315
dumpdeg = Row_degree [dumpindex] ;
316
tpi = Row_tuples [dumpindex] ;
317
}
318
else
319
{
320
/* dump a column */
321
ASSERT (dumpindex >= 0 && dumpindex < n_col) ;
322
if (!NON_PIVOTAL_COL (dumpindex))
323
{
324
DEBUG7 ((" Pivotal\n")) ;
325
return ;
326
}
327
len = Col_tlen [dumpindex] ;
328
dumpdeg = Col_degree [dumpindex] ;
329
tpi = Col_tuples [dumpindex] ;
330
}
331
332
p = Numeric->Memory + tpi ;
333
tp = (Tuple *) p ;
334
if (!tpi)
335
{
336
DEBUG7 ((" Nonpivotal, No tuple list tuples "ID" tlen "ID"\n",
337
tpi, len)) ;
338
return ;
339
}
340
ASSERT (p >= Numeric->Memory + Numeric->itail) ;
341
ASSERT (p < Numeric->Memory + Numeric->size) ;
342
343
DEBUG7 ((" degree: "ID" len: "ID"\n", dumpdeg, len)) ;
344
not_in_use = (p-1)->header.size - UNITS (Tuple, len) ;
345
DEBUG7 ((" Tuple list: p+1: "ID" size: "ID" units, "ID" not in use\n",
346
(Int) (p-Numeric->Memory), (p-1)->header.size, not_in_use)) ;
347
ASSERT (not_in_use >= 0) ;
348
tend = tp + len ;
349
preve = 0 ;
350
for ( ; tp < tend ; tp++)
351
{
352
/* row/col of element e, offset is f: */
353
/* DEBUG8 ((" (tp="ID")\n", tp)) ; */
354
e = tp->e ;
355
f = tp->f ;
356
DEBUG8 ((" (e="ID", f="ID")\n", e, f)) ;
357
ASSERT (e > 0 && e <= Work->nel) ;
358
/* dump the pattern and values */
359
if (E [e])
360
{
361
p = Numeric->Memory + E [e] ;
362
GET_ELEMENT (ep, p, Cols, Rows, ncols, nrows, C) ;
363
if (dumpwhich == 0)
364
{
365
Pattern = Cols ;
366
jj = ep->ncols ;
367
is_there = Rows [f] >= 0 ;
368
if (is_there) approx_deg += ep->ncolsleft ;
369
}
370
else
371
{
372
Pattern = Rows ;
373
jj = ep->nrows ;
374
is_there = Cols [f] >= 0 ;
375
if (is_there) approx_deg += ep->nrowsleft ;
376
}
377
if (!is_there)
378
{
379
DEBUG8 (("\t\tnot present\n")) ;
380
}
381
else
382
{
383
for (j = 0 ; j < jj ; j++)
384
{
385
index = Pattern [j] ;
386
value =
387
C [ (dumpwhich == 0) ? (f+nrows*j) : (j+nrows*f) ] ;
388
if (index >= 0)
389
{
390
DEBUG8 (("\t\t"ID":", index)) ;
391
EDEBUG8 (value) ;
392
DEBUG8 (("\n")) ;
393
if (dumpwhich == 0)
394
{
395
/* col must be in the range 0..n_col-1 */
396
ASSERT (index < n_col) ;
397
}
398
else
399
{
400
/* row must be in the range 0..n_row-1 */
401
ASSERT (index < n_row) ;
402
}
403
404
if (nn <= UMF_DBMAX)
405
{
406
if (UMF_DBscatter [index] != UMF_DBflag)
407
{
408
UMF_DBpacked [deg++] = index ;
409
UMF_DBscatter [index] = UMF_DBflag ;
410
}
411
}
412
}
413
}
414
}
415
/* the (e,f) tuples should be in order of their creation */
416
/* this means that garbage collection will not jumble them */
417
ASSERT (preve < e) ;
418
preve = e ;
419
}
420
else
421
{
422
DEBUG8 (("\t\tdeallocated\n")) ;
423
}
424
}
425
426
if (nn <= UMF_DBMAX)
427
{
428
if (deg > 0)
429
{
430
DEBUG7 ((" Assembled, actual deg: "ID" : ", deg)) ;
431
for (j = 0 ; j < deg ; j++)
432
{
433
index = UMF_DBpacked [j] ;
434
DEBUG8 ((ID" ", index)) ;
435
if (j % 20 == 19) DEBUG8 (("\n ")) ;
436
ASSERT (UMF_DBscatter [index] == UMF_DBflag) ;
437
}
438
DEBUG7 (("\n")) ;
439
}
440
}
441
442
/* Col_degree is not maintained when fixQ is true */
443
if (check_degree)
444
{
445
DEBUG8 ((" approx_deg "ID" dumpdeg "ID"\n", approx_deg, dumpdeg)) ;
446
ASSERT (approx_deg == dumpdeg) ;
447
}
448
449
DEBUG7 (("====================\n")) ;
450
451
/* deg is now the exact degree */
452
/* if nn <= UMF_DBMAX, then UMF_DBscatter [i] == UMF_DBflag for every i */
453
/* in the row or col, and != UMF_DBflag if not */
454
455
return ;
456
}
457
458
459
/* ========================================================================== */
460
/* === UMF_dump_matrix ====================================================== */
461
/* ========================================================================== */
462
463
GLOBAL void UMF_dump_matrix
464
(
465
NumericType *Numeric,
466
WorkType *Work,
467
Int check_degree
468
)
469
{
470
471
Int e, row, col, intfrag, frag, n_row, n_col, *E, fullsize, actualsize ;
472
Element *ep ;
473
Unit *p ;
474
475
DEBUG6 (("=================================================== MATRIX:\n")) ;
476
if (!Numeric || !Work)
477
{
478
DEBUG6 (("No Numeric or Work allocated\n")) ;
479
return ;
480
}
481
if (!Numeric->Memory)
482
{
483
DEBUG6 (("No Numeric->Memory\n")) ;
484
return ;
485
}
486
487
n_row = Work->n_row ;
488
n_col = Work->n_col ;
489
DEBUG6 (("n_row "ID" n_col "ID" nz "ID"\n", n_row, n_col, Work->nz)) ;
490
DEBUG6 (("============================ ELEMENTS: "ID" \n", Work->nel)) ;
491
intfrag = 0 ;
492
E = Work->E ;
493
if (!E)
494
{
495
DEBUG6 (("No elements allocated\n")) ;
496
}
497
else
498
{
499
for (e = 0 ; e <= Work->nel ; e++)
500
{
501
UMF_dump_element (Numeric, Work, e, FALSE) ;
502
if (e > 0 && E [e])
503
{
504
p = Numeric->Memory + E [e] ;
505
ep = (Element *) p ;
506
ASSERT (ep->nrowsleft > 0 || ep->ncolsleft > 0) ;
507
fullsize = GET_BLOCK_SIZE (p) ;
508
actualsize = GET_ELEMENT_SIZE (ep->nrowsleft,ep->ncolsleft);
509
frag = fullsize - actualsize ;
510
intfrag += frag ;
511
DEBUG7 (("dump el: "ID", full "ID" actual "ID" frag: "ID
512
" intfrag: "ID"\n", e, fullsize, actualsize, frag,
513
intfrag)) ;
514
}
515
}
516
}
517
518
DEBUG6 (("CURRENT INTERNAL FRAG in elements: "ID" \n", intfrag)) ;
519
520
521
522
DEBUG6 (("======================================== ROWS: "ID"\n", n_row)) ;
523
UMF_debug -= 2 ;
524
for (row = 0 ; row < n_row ; row++)
525
{
526
UMF_dump_rowcol (0, Numeric, Work, row, check_degree) ;
527
}
528
UMF_debug += 2 ;
529
DEBUG6 (("======================================== COLS: "ID"\n", n_col)) ;
530
UMF_debug -= 2 ;
531
for (col = 0 ; col < n_col ; col++)
532
{
533
UMF_dump_rowcol (1, Numeric, Work, col, FALSE) ;
534
}
535
UMF_debug += 2 ;
536
DEBUG6 (("============================================= END OF MATRIX:\n"));
537
}
538
539
540
/* ========================================================================== */
541
/* === UMF_dump_current_front =============================================== */
542
/* ========================================================================== */
543
544
GLOBAL void UMF_dump_current_front
545
(
546
NumericType *Numeric,
547
WorkType *Work,
548
Int check
549
)
550
{
551
552
Entry *Flublock, *Flblock, *Fublock, *Fcblock ;
553
Int fnrows_max, fncols_max, fnrows, fncols, fnpiv, *Frows, *Fcols,
554
i, j, *Fcpos, *Frpos, fnr_curr, fnc_curr, *E ;
555
if (!Work) return ;
556
DEBUG7 (("\n\n========CURRENT FRONTAL MATRIX:\n")) ;
557
558
Flublock = Work->Flublock ;
559
Flblock = Work->Flblock ;
560
Fublock = Work->Fublock ;
561
Fcblock = Work->Fcblock ;
562
563
Frows = Work->Frows ;
564
Fcols = Work->Fcols ;
565
Frpos = Work->Frpos ;
566
Fcpos = Work->Fcpos ;
567
fnrows_max = Work->fnrows_max ;
568
fncols_max = Work->fncols_max ;
569
fnr_curr = Work->fnr_curr ;
570
fnc_curr = Work->fnc_curr ;
571
fnrows = Work->fnrows ;
572
fncols = Work->fncols ;
573
fnpiv = Work->fnpiv ;
574
E = Work->E ;
575
576
DEBUG6 (("=== fnpiv= "ID"\n", fnpiv)) ;
577
DEBUG6 (("fnrows_max fncols_max "ID" "ID"\n",fnrows_max, fncols_max)) ;
578
DEBUG6 (("fnr_curr fnc_curr "ID" "ID"\n",fnr_curr, fnc_curr)) ;
579
DEBUG6 (("fnrows fncols "ID" "ID"\n",fnrows, fncols)) ;
580
ASSERT ((fnr_curr % 2 == 1) || fnr_curr == 0) ;
581
DEBUG6 (("Pivot row pattern:\n")) ;
582
for (j = 0 ; j < fncols ; j++)
583
{
584
DEBUG7 ((ID" "ID" "ID" %d\n", j, Fcols [j], Fcpos [Fcols [j]],
585
j < fncols)) ;
586
if (check)
587
{
588
ASSERT (Fcols [j] >= 0 && Fcols [j] < Work->n_col) ;
589
ASSERT (Fcpos [Fcols [j]] == j * fnr_curr) ;
590
}
591
}
592
DEBUG6 (("Pivot col pattern:\n")) ;
593
for (i = 0 ; i < fnrows ; i++)
594
{
595
DEBUG7 ((ID" "ID" "ID" %d\n", i, Frows [i], Frpos [Frows [i]],
596
i < fnrows)) ;
597
if (check)
598
{
599
ASSERT (Frows [i] >= 0 && Frows [i] < Work->n_row) ;
600
ASSERT (Frpos [Frows [i]] == i) ;
601
}
602
}
603
if (UMF_debug < 7) return ;
604
605
if (!E [0])
606
{
607
DEBUG6 (("current front not allocated\n")) ;
608
ASSERT (!Work->Flublock) ;
609
return ;
610
}
611
612
ASSERT (Work->Flublock == (Entry *) (Numeric->Memory + E [0])) ;
613
DEBUG7 (("C block: ")) ;
614
UMF_dump_dense (Fcblock, fnr_curr, fnrows, fncols) ;
615
DEBUG7 (("L block: ")) ;
616
UMF_dump_dense (Flblock, fnr_curr, fnrows, fnpiv) ;
617
DEBUG7 (("U' block: ")) ;
618
UMF_dump_dense (Fublock, fnc_curr, fncols, fnpiv) ;
619
DEBUG7 (("LU block: ")) ;
620
UMF_dump_dense (Flublock, Work->nb, fnpiv, fnpiv) ;
621
if (fnpiv > 0)
622
{
623
DEBUG7 (("Pivot entry: ")) ;
624
EDEBUG7 (Flublock [(fnpiv-1)+(fnpiv-1)*Work->nb]) ;
625
DEBUG7 (("\n")) ;
626
}
627
}
628
629
/* ========================================================================== */
630
/* === UMF_dump_lu ========================================================== */
631
/* ========================================================================== */
632
633
GLOBAL void UMF_dump_lu
634
(
635
NumericType *Numeric
636
)
637
{
638
Int i, n_row, n_col, *Cperm, *Rperm ;
639
640
DEBUG6 (("=============================================== LU factors:\n")) ;
641
if (!Numeric)
642
{
643
DEBUG6 (("No LU factors allocated\n")) ;
644
return ;
645
}
646
n_row = Numeric->n_row ;
647
n_col = Numeric->n_col ;
648
DEBUG6 (("n_row: "ID" n_col: "ID"\n", n_row, n_col)) ;
649
DEBUG6 (("nLentries: "ID" nUentries: "ID"\n",
650
Numeric->nLentries, Numeric->nUentries)) ;
651
652
if (Numeric->Cperm)
653
{
654
Cperm = Numeric->Cperm ;
655
DEBUG7 (("Column permutations: (new: old)\n")) ;
656
for (i = 0 ; i < n_col ; i++)
657
{
658
if (Cperm [i] != EMPTY)
659
{
660
DEBUG7 ((ID": "ID"\n", i, Cperm [i])) ;
661
}
662
}
663
}
664
else
665
{
666
DEBUG7 (("No Numeric->Cperm allocatated\n")) ;
667
}
668
669
if (Numeric->Rperm)
670
{
671
Rperm = Numeric->Rperm ;
672
DEBUG7 (("row permutations: (new: old)\n")) ;
673
for (i = 0 ; i < n_row ; i++)
674
{
675
if (Rperm [i] != EMPTY)
676
{
677
DEBUG7 ((ID": "ID"\n", i, Rperm [i])) ;
678
}
679
}
680
}
681
else
682
{
683
DEBUG7 (("No Numeric->Rperm allocatated\n")) ;
684
}
685
686
DEBUG6 (("========================================= END OF LU factors:\n"));
687
}
688
689
690
/* ========================================================================== */
691
/* === UMF_dump_memory ====================================================== */
692
/* ========================================================================== */
693
694
GLOBAL void UMF_dump_memory
695
(
696
NumericType *Numeric
697
)
698
{
699
700
Unit *p ;
701
Int prevsize, s ;
702
Int found ;
703
704
if (!Numeric)
705
{
706
DEBUG6 (("No memory space S allocated\n")) ;
707
return ;
708
}
709
710
DEBUG6 (("\n ============================================== MEMORY:\n")) ;
711
if (!Numeric || !Numeric->Memory)
712
{
713
DEBUG6 (("No memory space Numeric allocated\n")) ;
714
return ;
715
}
716
717
DEBUG6 (("S: "ID"\n", (Int) Numeric)) ;
718
DEBUG6 (("S->ihead : "ID"\n", Numeric->ihead)) ;
719
DEBUG6 (("S->itail : "ID"\n", Numeric->itail)) ;
720
DEBUG6 (("S->size : "ID"\n", Numeric->size)) ;
721
DEBUG6 (("S->ngarbage : "ID"\n", Numeric->ngarbage)) ;
722
DEBUG6 (("S->nrealloc : "ID"\n", Numeric->nrealloc)) ;
723
DEBUG6 ((" in use at head : "ID"\n", Numeric->ihead)) ;
724
DEBUG6 ((" free space : "ID"\n",
725
Numeric->itail - Numeric->ihead)) ;
726
DEBUG6 ((" blocks in use at tail : "ID"\n",
727
Numeric->size - Numeric->itail)) ;
728
DEBUG6 ((" total in use : "ID"\n",
729
Numeric->size - (Numeric->itail - Numeric->ihead))) ;
730
731
prevsize = 0 ;
732
found = FALSE ;
733
734
ASSERT (0 <= Numeric->ihead) ;
735
ASSERT (Numeric->ihead <= Numeric->itail) ;
736
ASSERT (Numeric->itail <= Numeric->size) ;
737
738
p = Numeric->Memory + Numeric->itail ;
739
740
while (p < Numeric->Memory + Numeric->size)
741
{
742
DEBUG8 (("p: "ID" p+1: "ID" prevsize: "ID" size: "ID,
743
(Int) (p-Numeric->Memory), (Int) (p+1-Numeric->Memory),
744
p->header.prevsize, p->header.size)) ;
745
if (p->header.size < 0)
746
{
747
DEBUG8 ((" free")) ;
748
}
749
750
if (p == Numeric->Memory + Numeric->itail)
751
{
752
ASSERT (p->header.prevsize == 0) ;
753
}
754
else
755
{
756
ASSERT (p->header.prevsize > 0) ;
757
}
758
759
ASSERT (p->header.size != 0) ;
760
s = prevsize >= 0 ? prevsize : -prevsize ;
761
ASSERT (p->header.prevsize == s) ;
762
/* no adjacent free blocks */
763
ASSERT (p->header.size > 0 || prevsize > 0) ;
764
if (Numeric->ibig != EMPTY)
765
{
766
if (p == Numeric->Memory + Numeric->ibig)
767
{
768
ASSERT (p->header.size < 0) ;
769
DEBUG8 ((" <===== Numeric->ibig")) ;
770
found = TRUE ;
771
}
772
}
773
s = p->header.size ;
774
prevsize = s ;
775
s = s >= 0 ? s : -s ;
776
p = p + 1 + s ;
777
DEBUG8 (("\n")) ;
778
}
779
780
ASSERT (p == Numeric->Memory + Numeric->size) ;
781
ASSERT (IMPLIES (Numeric->ibig != EMPTY, found)) ;
782
DEBUG6 (("============================================= END OF MEMORY:\n"));
783
784
}
785
786
787
/* ========================================================================== */
788
/* === UMF_dump_packed_memory =============================================== */
789
/* ========================================================================== */
790
791
GLOBAL void UMF_dump_packed_memory
792
(
793
NumericType *Numeric,
794
WorkType *Work
795
)
796
{
797
Unit *p, *p3 ;
798
Int prevsize, col, row, *Rows, *Cols, ncols, nrows, k, esize,
799
*Row_tuples, *Row_degree, *Col_tuples, *Col_degree ;
800
Entry *C ;
801
Element *ep ;
802
803
Col_degree = Numeric->Cperm ; /* for NON_PIVOTAL_COL macro */
804
Row_degree = Numeric->Rperm ; /* for NON_PIVOTAL_ROW macro */
805
Row_tuples = Numeric->Uip ;
806
Col_tuples = Numeric->Lip ;
807
808
DEBUG6 (("============================================ PACKED MEMORY:\n")) ;
809
if (!Numeric || !Numeric->Memory)
810
{
811
DEBUG6 (("No memory space S allocated\n")) ;
812
return ;
813
}
814
DEBUG6 (("S: "ID"\n", (Int) Numeric)) ;
815
DEBUG6 (("S->ihead : "ID"\n", Numeric->ihead)) ;
816
DEBUG6 (("S->itail : "ID"\n", Numeric->itail)) ;
817
DEBUG6 (("S->size : "ID"\n", Numeric->size)) ;
818
DEBUG6 (("S->ngarbage : "ID"\n", Numeric->ngarbage)) ;
819
DEBUG6 (("S->nrealloc : "ID"\n", Numeric->nrealloc)) ;
820
DEBUG6 ((" in use at head : "ID"\n", Numeric->ihead)) ;
821
DEBUG6 ((" free space : "ID"\n",
822
Numeric->itail - Numeric->ihead)) ;
823
DEBUG6 ((" blocks in use at tail : "ID"\n",
824
Numeric->size - Numeric->itail)) ;
825
DEBUG6 ((" total in use : "ID"\n",
826
Numeric->size - (Numeric->itail - Numeric->ihead))) ;
827
828
ASSERT (0 <= Numeric->ihead) ;
829
ASSERT (Numeric->ihead <= Numeric->itail) ;
830
ASSERT (Numeric->itail <= Numeric->size) ;
831
832
for (row = 0 ; row < Work->n_row ; row++)
833
{
834
ASSERT (IMPLIES (NON_PIVOTAL_ROW (row), !Row_tuples [row])) ;
835
}
836
for (col = 0 ; col < Work->n_col ; col++)
837
{
838
ASSERT (IMPLIES (NON_PIVOTAL_COL (col), !Col_tuples [col])) ;
839
}
840
841
prevsize = 0 ;
842
p = Numeric->Memory + Numeric->itail ;
843
while (p < Numeric->Memory + Numeric->size)
844
{
845
DEBUG9 (("====================\n")) ;
846
DEBUG7 (("p: "ID" p+1: "ID" prevsize: "ID" size: "ID"\n",
847
(Int) (p-Numeric->Memory), (Int) (p+1-Numeric->Memory),
848
p->header.prevsize, p->header.size)) ;
849
ASSERT (p->header.size > 0) ;
850
851
if (p == Numeric->Memory + Numeric->itail)
852
{
853
ASSERT (p->header.prevsize == 0) ;
854
}
855
else
856
{
857
ASSERT (p->header.prevsize > 0) ;
858
}
859
860
ASSERT (p->header.prevsize == prevsize) ;
861
prevsize = p->header.size ;
862
863
if (p != Numeric->Memory + Numeric->size - 2)
864
{
865
866
p3 = p + 1 ;
867
if (p3 == Numeric->Memory + Work->E [0])
868
{
869
/* this is the current frontal matrix */
870
UMF_dump_current_front (Numeric, Work, FALSE) ;
871
}
872
else
873
{
874
875
/* this is a packed element */
876
GET_ELEMENT (ep, p3, Cols, Rows, ncols, nrows, C) ;
877
DEBUG9 (("ep "ID"\n nrows "ID" ncols "ID"\n",
878
(Int) ((p+1)-Numeric->Memory), ep->nrows, ep->ncols)) ;
879
DEBUG9 (("rows:")) ;
880
for (k = 0 ; k < ep->nrows; k++)
881
{
882
row = Rows [k] ;
883
DEBUG9 ((" "ID, row)) ;
884
ASSERT (row >= 0 && row <= Work->n_row) ;
885
if ((k % 10) == 9) DEBUG9 (("\n")) ;
886
}
887
DEBUG9 (("\ncols:")) ;
888
for (k = 0 ; k < ep->ncols; k++)
889
{
890
col = Cols [k] ;
891
DEBUG9 ((" "ID, col)) ;
892
ASSERT (col >= 0 && col <= Work->n_col) ;
893
if ((k % 10) == 9) DEBUG9 (("\n")) ;
894
}
895
DEBUG9 (("\nvalues: ")) ;
896
if (UMF_debug >= 9)
897
{
898
UMF_dump_dense (C, ep->nrows, ep->nrows, ep->ncols) ;
899
}
900
esize = GET_ELEMENT_SIZE (ep->nrows, ep->ncols) ;
901
DEBUG9 (("esize: "ID"\n", esize)) ;
902
ASSERT (esize <= p->header.size) ;
903
}
904
905
}
906
else
907
{
908
/* this is the final marker block */
909
ASSERT (p->header.size == 1) ;
910
}
911
p = p + 1 + p->header.size ;
912
}
913
914
ASSERT (Numeric->ibig == EMPTY) ;
915
ASSERT (p == Numeric->Memory + Numeric->size) ;
916
DEBUG6 (("======================================END OF PACKED MEMORY:\n")) ;
917
918
}
919
920
/* ========================================================================== */
921
/* === UMF_dump_col_matrix ================================================== */
922
/* ========================================================================== */
923
924
/* This code is the same for real or complex matrices. */
925
926
GLOBAL void UMF_dump_col_matrix
927
(
928
const double Ax [ ], /* Ax [0..nz-1]: real values, in column order */
929
#ifdef COMPLEX
930
const double Az [ ], /* Az [0..nz-1]: imag values, in column order */
931
#endif
932
const Int Ai [ ], /* Ai [0..nz-1]: row indices, in column order */
933
const Int Ap [ ], /* Ap [0..n_col]: column pointers */
934
Int n_row, /* number of rows of A */
935
Int n_col, /* number of columns of A */
936
Int nz /* number of entries */
937
)
938
{
939
Int col, p, p1, p2, row ;
940
#ifdef COMPLEX
941
Int split = SPLIT (Az) ;
942
#endif
943
944
if (!Ai || !Ap) return ;
945
DEBUG6 (("============================================ COLUMN FORM:\n")) ;
946
947
ASSERT (n_col >= 0) ;
948
nz = Ap [n_col] ;
949
DEBUG2 (("UMF_dump_col: nz "ID"\n", nz)) ;
950
DEBUG2 (("n_row "ID" \n", n_row)) ;
951
DEBUG2 (("n_col "ID" \n", n_col)) ;
952
953
DEBUG6 ((" n_row = "ID", n_col ="ID" nz = "ID" Ap [0] "ID", Ap [n] "ID"\n",
954
n_row, n_col, nz, Ap [0], Ap [n_col])) ;
955
ASSERT (Ap [0] == 0) ;
956
ASSERT (Ap [n_col] == nz) ;
957
for (col = 0 ; col < n_col ; col++)
958
{
959
p1 = Ap [col] ;
960
p2 = Ap [col+1] ;
961
DEBUG6 (("col: "ID", length "ID"\n", col, p2 - p1)) ;
962
ASSERT (p2 >= p1) ;
963
for (p = p1 ; p < p2 ; p++)
964
{
965
row = Ai [p] ;
966
ASSERT (row >= 0 && row < n_row) ;
967
DEBUG6 (("\t"ID" ", row)) ;
968
if (Ax != (double *) NULL)
969
{
970
#ifdef COMPLEX
971
if (split)
972
{
973
DEBUG6 ((" (%e+%ei) ", Ax [p], Az [p])) ;
974
}
975
else
976
{
977
DEBUG6 ((" (%e+%ei) ", Ax [2*p], Ax [2*p+1])) ;
978
}
979
#else
980
DEBUG6 ((" %e", Ax [p])) ;
981
#endif
982
}
983
DEBUG6 (("\n")) ;
984
}
985
}
986
DEBUG6 (("========================================== COLUMN FORM done\n")) ;
987
}
988
989
990
/* ========================================================================== */
991
/* === UMF_dump_chain ======================================================= */
992
/* ========================================================================== */
993
994
GLOBAL void UMF_dump_chain
995
(
996
Int frontid,
997
Int Front_parent [ ],
998
Int Front_npivcol [ ],
999
Int Front_nrows [ ],
1000
Int Front_ncols [ ],
1001
Int nfr
1002
)
1003
{
1004
Int i, len = 0 ;
1005
1006
/* print a list of contiguous parents */
1007
i = frontid ;
1008
ASSERT (Front_parent [i] == EMPTY ||
1009
(Front_parent [i] > i && Front_parent [i] < nfr)) ;
1010
1011
len++ ;
1012
DEBUG3 (("Chain:\n "ID" ["ID","ID"]("ID"-by-"ID")\n", i,
1013
Front_npivcol [i],
1014
MIN (Front_npivcol [i], Front_nrows [i]),
1015
Front_nrows [i],
1016
Front_ncols [i])) ;
1017
1018
for (i = frontid ; i < nfr ; i++)
1019
{
1020
ASSERT (Front_parent [i] == EMPTY ||
1021
(Front_parent [i] > i && Front_parent [i] < nfr)) ;
1022
if (Front_parent [i] == i+1)
1023
{
1024
len++ ;
1025
DEBUG3 (("\t"ID" ["ID","ID"]("ID"-by-"ID")\n", i+1,
1026
Front_npivcol [i+1],
1027
MIN (Front_npivcol [i+1], Front_nrows [i+1]),
1028
Front_nrows [i+1],
1029
Front_ncols [i+1])) ;
1030
}
1031
else
1032
{
1033
DEBUG2 (("Length of chain: "ID"\n", len)) ;
1034
return ;
1035
}
1036
}
1037
}
1038
1039
1040
/* ========================================================================== */
1041
/* === UMF_dump_start ======================================================= */
1042
/* ========================================================================== */
1043
1044
GLOBAL void UMF_dump_start
1045
(
1046
void
1047
)
1048
{
1049
FILE *ff ;
1050
1051
AMD_debug_init ("from umfpack") ;
1052
1053
/* get the debug print level from the "debug.umf" file, if it exists */
1054
UMF_debug = -999 ;
1055
ff = fopen ("debug.umf", "r") ;
1056
if (ff)
1057
{
1058
(void) fscanf (ff, ID, &UMF_debug) ;
1059
(void) fclose (ff) ;
1060
}
1061
1062
DEBUG0 (("umfpack: debug version (SLOW!) ")) ;
1063
1064
DEBUG0 ((" BLAS: ")) ;
1065
1066
#if defined (USE_NO_BLAS)
1067
DEBUG0 (("none.")) ;
1068
#elif defined (USE_C_BLAS)
1069
DEBUG0 (("C-BLAS.")) ;
1070
#elif defined (USE_MATLAB_BLAS)
1071
DEBUG0 (("built-in MATLAB BLAS.")) ;
1072
#elif defined (USE_SUNPERF_BLAS)
1073
DEBUG0 (("Sun Performance Library BLAS.")) ;
1074
#elif defined (USE_SCSL_BLAS)
1075
DEBUG0 (("SGI SCSL BLAS.")) ;
1076
#elif defined (USE_FORTRAN_BLAS)
1077
DEBUG0 (("Fortran BLAS.")) ;
1078
#endif
1079
1080
DEBUG0 ((" MATLAB: ")) ;
1081
#ifdef MATLAB_MEX_FILE
1082
DEBUG0 (("mexFunction.\n")) ;
1083
#else
1084
#ifdef MATHWORKS
1085
DEBUG0 (("yes (uses MathWorks internal ut* routines).\n")) ;
1086
#else
1087
DEBUG0 (("no.\n")) ;
1088
#endif
1089
#endif
1090
1091
UMF_gprob = -1.0 ;
1092
ff = fopen ("gprob.umf", "r") ;
1093
if (ff)
1094
{
1095
(void) fscanf (ff, "%lg", &UMF_gprob) ;
1096
(void) fclose (ff) ;
1097
srand (1) ; /* restart the random number generator */
1098
}
1099
1100
if (UMF_gprob > 1.0) UMF_gprob = 1.0 ;
1101
DEBUG1 (("factor: UMF_gprob: %e UMF_debug "ID"\n", UMF_gprob, UMF_debug)) ;
1102
1103
DEBUG2 (("sizeof: (bytes / int / Units) \n")) ;
1104
DEBUG2 (("sizeof (Int) %u %u %u\n",
1105
sizeof (Int), sizeof (Int) / sizeof (int), UNITS (Int, 1) )) ;
1106
DEBUG2 (("sizeof (int) %u %u %u\n",
1107
sizeof (int), sizeof (int) / sizeof (int), UNITS (int, 1) )) ;
1108
DEBUG2 (("sizeof (size_t) %u %u %u\n",
1109
sizeof (size_t), sizeof (size_t) / sizeof (size_t), UNITS (size_t, 1) )) ;
1110
DEBUG2 (("sizeof (long) %u %u %u\n",
1111
sizeof (long), sizeof (long) / sizeof (long), UNITS (long, 1) )) ;
1112
DEBUG2 (("sizeof (double) %u %u %u\n",
1113
sizeof (double), sizeof (double) / sizeof (int), UNITS (double, 1) )) ;
1114
DEBUG2 (("sizeof (Unit) %u %u %u\n",
1115
sizeof (Unit), sizeof (Unit) / sizeof (int), UNITS (Unit, 1) )) ;
1116
DEBUG2 (("sizeof (Entry) %u %u %u\n",
1117
sizeof (Entry), sizeof (Entry) / sizeof (int), UNITS (Entry, 1) )) ;
1118
DEBUG2 (("sizeof (Tuple) %u %u %u\n",
1119
sizeof (Tuple), sizeof (Tuple) / sizeof (int), UNITS (Tuple, 1) )) ;
1120
DEBUG2 (("sizeof (Tuple *) %u %u %u\n",
1121
sizeof (Tuple *), sizeof (Tuple *) / sizeof (int), UNITS (Tuple *, 1) )) ;
1122
DEBUG2 (("sizeof (Element) %u %u %u\n",
1123
sizeof (Element), sizeof (Element) / sizeof (int), UNITS (Element, 1) )) ;
1124
DEBUG2 (("sizeof (Element *) %u %u %u\n",
1125
sizeof (Element *), sizeof (Element *) / sizeof (int),
1126
UNITS (Element *, 1) )) ;
1127
DEBUG2 (("sizeof (WorkType) %u %u %u\n",
1128
sizeof (WorkType), sizeof (WorkType) / sizeof (int),
1129
UNITS (WorkType, 1) )) ;
1130
DEBUG2 (("sizeof (NumericType) %u %u %u\n",
1131
sizeof (NumericType), sizeof (NumericType) / sizeof (int),
1132
UNITS (NumericType, 1) )) ;
1133
DEBUG2 (("sizeof (SymbolicType) %u %u %u\n",
1134
sizeof (SymbolicType), sizeof (SymbolicType) / sizeof (int),
1135
UNITS (SymbolicType, 1) )) ;
1136
1137
}
1138
1139
1140
/* ========================================================================== */
1141
/* === UMF_dump_rowmerge ==================================================== */
1142
/* ========================================================================== */
1143
1144
GLOBAL void UMF_dump_rowmerge
1145
(
1146
NumericType *Numeric,
1147
SymbolicType *Symbolic,
1148
WorkType *Work
1149
)
1150
{
1151
Int *Front_leftmostdesc, *Front_1strow, *Front_new1strow, row1, row2,
1152
fleftmost, nfr, n_row, *Row_degree, i, frontid, row ;
1153
1154
nfr = Symbolic->nfr ;
1155
DEBUG3 (("\n================== Row merge sets: nfr "ID"\n", nfr)) ;
1156
Front_leftmostdesc = Symbolic->Front_leftmostdesc ;
1157
Front_1strow = Symbolic->Front_1strow ;
1158
Front_new1strow = Work->Front_new1strow ;
1159
n_row = Symbolic->n_row ;
1160
Row_degree = Numeric->Rperm ;
1161
frontid = Work->frontid ;
1162
1163
for (i = frontid ; i <= nfr ; i++)
1164
{
1165
DEBUG3 (("----------------------\n")) ;
1166
if (i == nfr) DEBUG3 (("Dummy: ")) ;
1167
DEBUG3 (("Front "ID" 1strow "ID" new1strow "ID" leftmostdesc "ID,
1168
i, Front_1strow [i], Front_new1strow [i], Front_leftmostdesc [i])) ;
1169
DEBUG3 ((" parent "ID" pivcol "ID"\n", Symbolic->Front_parent [i],
1170
Symbolic->Front_npivcol [i])) ;
1171
1172
if (i == nfr)
1173
{
1174
fleftmost = -1 ;
1175
row1 = Front_new1strow [i] ;
1176
row2 = n_row-1 ;
1177
}
1178
else
1179
{
1180
fleftmost = Front_leftmostdesc [i] ;
1181
row1 = Front_new1strow [fleftmost] ;
1182
row2 = Front_1strow [i+1] - 1 ;
1183
}
1184
DEBUG3 (("Leftmost: "ID" Rows ["ID" to "ID"], search ["ID" to "ID"]\n",
1185
fleftmost, Front_1strow [i], row2, row1, row2)) ;
1186
1187
for (row = row1 ; row <= row2 ; row++)
1188
{
1189
ASSERT (row >= 0 && row < n_row) ;
1190
DEBUG3 ((" Row "ID" live: %d\n", row, NON_PIVOTAL_ROW (row))) ;
1191
}
1192
}
1193
}
1194
1195
/* ========================================================================== */
1196
/* === UMF_dump_diagonal_map ================================================ */
1197
/* ========================================================================== */
1198
1199
GLOBAL void UMF_dump_diagonal_map
1200
(
1201
Int Diagonal_map [ ],
1202
Int Diagonal_imap [ ],
1203
Int n1,
1204
Int nn,
1205
Int nempty
1206
)
1207
{
1208
Int row, col ;
1209
if (Diagonal_map != (Int *) NULL)
1210
{
1211
DEBUG2 (("\nDump the Diagonal_map: n1 "ID" nn "ID" nempty "ID"\n",
1212
n1, nn, nempty)) ;
1213
for (col = n1 ; col < nn - nempty ; col++)
1214
{
1215
row = Diagonal_map [col] ;
1216
DEBUG2 ((" Diagonal_map [col = "ID"] gives "ID": ",
1217
col, row)) ;
1218
row = UNFLIP (row) ;
1219
DEBUG2 ((" row "ID"\n", row)) ;
1220
ASSERT (Diagonal_imap [row] == col) ;
1221
}
1222
}
1223
}
1224
1225
#endif /* NDEBUG */
1226
1227