Debian Codegraph @

external/glpk/colamd.c

raw symbols SCIP
1 /* ========================================================================== */cxx . . $ `<file>/external/glpk/colamd.c`/
2 /* === colamd/symamd - a sparse matrix column ordering algorithm ============ */
3 /* ========================================================================== */
4
5 /* COLAMD / SYMAMD
6
7 colamd: an approximate minimum degree column ordering algorithm,
8 for LU factorization of symmetric or unsymmetric matrices,
9 QR factorization, least squares, interior point methods for
10 linear programming problems, and other related problems.
11
12 symamd: an approximate minimum degree ordering algorithm for Cholesky
13 factorization of symmetric matrices.
14
15 Purpose:
16
17 Colamd computes a permutation Q such that the Cholesky factorization of
18 (AQ)'(AQ) has less fill-in and requires fewer floating point operations
19 than A'A. This also provides a good ordering for sparse partial
20 pivoting methods, P(AQ) = LU, where Q is computed prior to numerical
21 factorization, and P is computed during numerical factorization via
22 conventional partial pivoting with row interchanges. Colamd is the
23 column ordering method used in SuperLU, part of the ScaLAPACK library.
24 It is also available as built-in function in MATLAB Version 6,
25 available from MathWorks, Inc. (http://www.mathworks.com). This
26 routine can be used in place of colmmd in MATLAB.
27
28 Symamd computes a permutation P of a symmetric matrix A such that the
29 Cholesky factorization of PAP' has less fill-in and requires fewer
30 floating point operations than A. Symamd constructs a matrix M such
31 that M'M has the same nonzero pattern of A, and then orders the columns
32 of M using colmmd. The column ordering of M is then returned as the
33 row and column ordering P of A.
34
35 Authors:
36
37 The authors of the code itself are Stefan I. Larimore and Timothy A.
38 Davis (davis at cise.ufl.edu), University of Florida. The algorithm was
39 developed in collaboration with John Gilbert, Xerox PARC, and Esmond
40 Ng, Oak Ridge National Laboratory.
41
42 Acknowledgements:
43
44 This work was supported by the National Science Foundation, under
45 grants DMS-9504974 and DMS-9803599.
46
47 Copyright and License:
48
49 Copyright (c) 1998-2007, Timothy A. Davis, All Rights Reserved.
50 COLAMD is also available under alternate licenses, contact T. Davis
51 for details.
52
53 This library is free software; you can redistribute it and/or
54 modify it under the terms of the GNU Lesser General Public
55 License as published by the Free Software Foundation; either
56 version 2.1 of the License, or (at your option) any later version.
57
58 This library is distributed in the hope that it will be useful,
59 but WITHOUT ANY WARRANTY; without even the implied warranty of
60 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
61 Lesser General Public License for more details.
62
63 You should have received a copy of the GNU Lesser General Public
64 License along with this library; if not, write to the Free Software
65 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
66 USA
67
68 Permission is hereby granted to use or copy this program under the
69 terms of the GNU LGPL, provided that the Copyright, this License,
70 and the Availability of the original version is retained on all copies.
71 User documentation of any code that uses this code or any modified
72 version of this code must cite the Copyright, this License, the
73 Availability note, and "Used by permission." Permission to modify
74 the code and to distribute modified code is granted, provided the
75 Copyright, this License, and the Availability note are retained,
76 and a notice that the code was modified is included.
77
78 Availability:
79
80 The colamd/symamd library is available at
81
82 http://www.cise.ufl.edu/research/sparse/colamd/
83
84 This is the http://www.cise.ufl.edu/research/sparse/colamd/colamd.c
85 file. It requires the colamd.h file. It is required by the colamdmex.c
86 and symamdmex.c files, for the MATLAB interface to colamd and symamd.
87 Appears as ACM Algorithm 836.
88
89 See the ChangeLog file for changes since Version 1.0.
90
91 References:
92
93 T. A. Davis, J. R. Gilbert, S. Larimore, E. Ng, An approximate column
94 minimum degree ordering algorithm, ACM Transactions on Mathematical
95 Software, vol. 30, no. 3., pp. 353-376, 2004.
96
97 T. A. Davis, J. R. Gilbert, S. Larimore, E. Ng, Algorithm 836: COLAMD,
98 an approximate column minimum degree ordering algorithm, ACM
99 Transactions on Mathematical Software, vol. 30, no. 3., pp. 377-380,
100 2004.
101
102 */
103
104 /* ========================================================================== */
105 /* === Description of user-callable routines ================================ */
106 /* ========================================================================== */
107
108 /* COLAMD includes both int and UF_long versions of all its routines. The
109 * description below is for the int version. For UF_long, all int arguments
110 * become UF_long. UF_long is normally defined as long, except for WIN64.
111
112 ----------------------------------------------------------------------------
113 colamd_recommended:
114 ----------------------------------------------------------------------------
115
116 C syntax:
117
118 #include "colamd.h"
119 size_t colamd_recommended (int nnz, int n_row, int n_col) ;
120 size_t colamd_l_recommended (UF_long nnz, UF_long n_row,
121 UF_long n_col) ;
122
123 Purpose:
124
125 Returns recommended value of Alen for use by colamd. Returns 0
126 if any input argument is negative. The use of this routine
127 is optional. Not needed for symamd, which dynamically allocates
128 its own memory.
129
130 Note that in v2.4 and earlier, these routines returned int or long.
131 They now return a value of type size_t.
132
133 Arguments (all input arguments):
134
135 int nnz ; Number of nonzeros in the matrix A. This must
136 be the same value as p [n_col] in the call to
137 colamd - otherwise you will get a wrong value
138 of the recommended memory to use.
139
140 int n_row ; Number of rows in the matrix A.
141
142 int n_col ; Number of columns in the matrix A.
143
144 ----------------------------------------------------------------------------
145 colamd_set_defaults:
146 ----------------------------------------------------------------------------
147
148 C syntax:
149
150 #include "colamd.h"
151 colamd_set_defaults (double knobs [COLAMD_KNOBS]) ;
152 colamd_l_set_defaults (double knobs [COLAMD_KNOBS]) ;
153
154 Purpose:
155
156 Sets the default parameters. The use of this routine is optional.
157
158 Arguments:
159
160 double knobs [COLAMD_KNOBS] ; Output only.
161
162 NOTE: the meaning of the dense row/col knobs has changed in v2.4
163
164 knobs [0] and knobs [1] control dense row and col detection:
165
166 Colamd: rows with more than
167 max (16, knobs [COLAMD_DENSE_ROW] * sqrt (n_col))
168 entries are removed prior to ordering. Columns with more than
169 max (16, knobs [COLAMD_DENSE_COL] * sqrt (MIN (n_row,n_col)))
170 entries are removed prior to
171 ordering, and placed last in the output column ordering.
172
173 Symamd: uses only knobs [COLAMD_DENSE_ROW], which is knobs [0].
174 Rows and columns with more than
175 max (16, knobs [COLAMD_DENSE_ROW] * sqrt (n))
176 entries are removed prior to ordering, and placed last in the
177 output ordering.
178
179 COLAMD_DENSE_ROW and COLAMD_DENSE_COL are defined as 0 and 1,
180 respectively, in colamd.h. Default values of these two knobs
181 are both 10. Currently, only knobs [0] and knobs [1] are
182 used, but future versions may use more knobs. If so, they will
183 be properly set to their defaults by the future version of
184 colamd_set_defaults, so that the code that calls colamd will
185 not need to change, assuming that you either use
186 colamd_set_defaults, or pass a (double *) NULL pointer as the
187 knobs array to colamd or symamd.
188
189 knobs [2]: aggressive absorption
190
191 knobs [COLAMD_AGGRESSIVE] controls whether or not to do
192 aggressive absorption during the ordering. Default is TRUE.
193
194
195 ----------------------------------------------------------------------------
196 colamd:
197 ----------------------------------------------------------------------------
198
199 C syntax:
200
201 #include "colamd.h"
202 int colamd (int n_row, int n_col, int Alen, int *A, int *p,
203 double knobs [COLAMD_KNOBS], int stats [COLAMD_STATS]) ;
204 UF_long colamd_l (UF_long n_row, UF_long n_col, UF_long Alen,
205 UF_long *A, UF_long *p, double knobs [COLAMD_KNOBS],
206 UF_long stats [COLAMD_STATS]) ;
207
208 Purpose:
209
210 Computes a column ordering (Q) of A such that P(AQ)=LU or
211 (AQ)'AQ=LL' have less fill-in and require fewer floating point
212 operations than factorizing the unpermuted matrix A or A'A,
213 respectively.
214
215 Returns:
216
217 TRUE (1) if successful, FALSE (0) otherwise.
218
219 Arguments:
220
221 int n_row ; Input argument.
222
223 Number of rows in the matrix A.
224 Restriction: n_row >= 0.
225 Colamd returns FALSE if n_row is negative.
226
227 int n_col ; Input argument.
228
229 Number of columns in the matrix A.
230 Restriction: n_col >= 0.
231 Colamd returns FALSE if n_col is negative.
232
233 int Alen ; Input argument.
234
235 Restriction (see note):
236 Alen >= 2*nnz + 6*(n_col+1) + 4*(n_row+1) + n_col
237 Colamd returns FALSE if these conditions are not met.
238
239 Note: this restriction makes an modest assumption regarding
240 the size of the two typedef's structures in colamd.h.
241 We do, however, guarantee that
242
243 Alen >= colamd_recommended (nnz, n_row, n_col)
244
245 will be sufficient. Note: the macro version does not check
246 for integer overflow, and thus is not recommended. Use
247 the colamd_recommended routine instead.
248
249 int A [Alen] ; Input argument, undefined on output.
250
251 A is an integer array of size Alen. Alen must be at least as
252 large as the bare minimum value given above, but this is very
253 low, and can result in excessive run time. For best
254 performance, we recommend that Alen be greater than or equal to
255 colamd_recommended (nnz, n_row, n_col), which adds
256 nnz/5 to the bare minimum value given above.
257
258 On input, the row indices of the entries in column c of the
259 matrix are held in A [(p [c]) ... (p [c+1]-1)]. The row indices
260 in a given column c need not be in ascending order, and
261 duplicate row indices may be be present. However, colamd will
262 work a little faster if both of these conditions are met
263 (Colamd puts the matrix into this format, if it finds that the
264 the conditions are not met).
265
266 The matrix is 0-based. That is, rows are in the range 0 to
267 n_row-1, and columns are in the range 0 to n_col-1. Colamd
268 returns FALSE if any row index is out of range.
269
270 The contents of A are modified during ordering, and are
271 undefined on output.
272
273 int p [n_col+1] ; Both input and output argument.
274
275 p is an integer array of size n_col+1. On input, it holds the
276 "pointers" for the column form of the matrix A. Column c of
277 the matrix A is held in A [(p [c]) ... (p [c+1]-1)]. The first
278 entry, p [0], must be zero, and p [c] <= p [c+1] must hold
279 for all c in the range 0 to n_col-1. The value p [n_col] is
280 thus the total number of entries in the pattern of the matrix A.
281 Colamd returns FALSE if these conditions are not met.
282
283 On output, if colamd returns TRUE, the array p holds the column
284 permutation (Q, for P(AQ)=LU or (AQ)'(AQ)=LL'), where p [0] is
285 the first column index in the new ordering, and p [n_col-1] is
286 the last. That is, p [k] = j means that column j of A is the
287 kth pivot column, in AQ, where k is in the range 0 to n_col-1
288 (p [0] = j means that column j of A is the first column in AQ).
289
290 If colamd returns FALSE, then no permutation is returned, and
291 p is undefined on output.
292
293 double knobs [COLAMD_KNOBS] ; Input argument.
294
295 See colamd_set_defaults for a description.
296
297 int stats [COLAMD_STATS] ; Output argument.
298
299 Statistics on the ordering, and error status.
300 See colamd.h for related definitions.
301 Colamd returns FALSE if stats is not present.
302
303 stats [0]: number of dense or empty rows ignored.
304
305 stats [1]: number of dense or empty columns ignored (and
306 ordered last in the output permutation p)
307 Note that a row can become "empty" if it
308 contains only "dense" and/or "empty" columns,
309 and similarly a column can become "empty" if it
310 only contains "dense" and/or "empty" rows.
311
312 stats [2]: number of garbage collections performed.
313 This can be excessively high if Alen is close
314 to the minimum required value.
315
316 stats [3]: status code. < 0 is an error code.
317 > 1 is a warning or notice.
318
319 0 OK. Each column of the input matrix contained
320 row indices in increasing order, with no
321 duplicates.
322
323 1 OK, but columns of input matrix were jumbled
324 (unsorted columns or duplicate entries). Colamd
325 had to do some extra work to sort the matrix
326 first and remove duplicate entries, but it
327 still was able to return a valid permutation
328 (return value of colamd was TRUE).
329
330 stats [4]: highest numbered column that
331 is unsorted or has duplicate
332 entries.
333 stats [5]: last seen duplicate or
334 unsorted row index.
335 stats [6]: number of duplicate or
336 unsorted row indices.
337
338 -1 A is a null pointer
339
340 -2 p is a null pointer
341
342 -3 n_row is negative
343
344 stats [4]: n_row
345
346 -4 n_col is negative
347
348 stats [4]: n_col
349
350 -5 number of nonzeros in matrix is negative
351
352 stats [4]: number of nonzeros, p [n_col]
353
354 -6 p [0] is nonzero
355
356 stats [4]: p [0]
357
358 -7 A is too small
359
360 stats [4]: required size
361 stats [5]: actual size (Alen)
362
363 -8 a column has a negative number of entries
364
365 stats [4]: column with < 0 entries
366 stats [5]: number of entries in col
367
368 -9 a row index is out of bounds
369
370 stats [4]: column with bad row index
371 stats [5]: bad row index
372 stats [6]: n_row, # of rows of matrx
373
374 -10 (unused; see symamd.c)
375
376 -999 (unused; see symamd.c)
377
378 Future versions may return more statistics in the stats array.
379
380 Example:
381
382 See http://www.cise.ufl.edu/research/sparse/colamd/example.c
383 for a complete example.
384
385 To order the columns of a 5-by-4 matrix with 11 nonzero entries in
386 the following nonzero pattern
387
388 x 0 x 0
389 x 0 x x
390 0 x x 0
391 0 0 x x
392 x x 0 0
393
394 with default knobs and no output statistics, do the following:
395
396 #include "colamd.h"
397 #define ALEN 100
398 int A [ALEN] = {0, 1, 4, 2, 4, 0, 1, 2, 3, 1, 3} ;
399 int p [ ] = {0, 3, 5, 9, 11} ;
400 int stats [COLAMD_STATS] ;
401 colamd (5, 4, ALEN, A, p, (double *) NULL, stats) ;
402
403 The permutation is returned in the array p, and A is destroyed.
404
405 ----------------------------------------------------------------------------
406 symamd:
407 ----------------------------------------------------------------------------
408
409 C syntax:
410
411 #include "colamd.h"
412 int symamd (int n, int *A, int *p, int *perm,
413 double knobs [COLAMD_KNOBS], int stats [COLAMD_STATS],
414 void (*allocate) (size_t, size_t), void (*release) (void *)) ;
415 UF_long symamd_l (UF_long n, UF_long *A, UF_long *p, UF_long *perm,
416 double knobs [COLAMD_KNOBS], UF_long stats [COLAMD_STATS],
417 void (*allocate) (size_t, size_t), void (*release) (void *)) ;
418
419 Purpose:
420
421 The symamd routine computes an ordering P of a symmetric sparse
422 matrix A such that the Cholesky factorization PAP' = LL' remains
423 sparse. It is based on a column ordering of a matrix M constructed
424 so that the nonzero pattern of M'M is the same as A. The matrix A
425 is assumed to be symmetric; only the strictly lower triangular part
426 is accessed. You must pass your selected memory allocator (usually
427 calloc/free or mxCalloc/mxFree) to symamd, for it to allocate
428 memory for the temporary matrix M.
429
430 Returns:
431
432 TRUE (1) if successful, FALSE (0) otherwise.
433
434 Arguments:
435
436 int n ; Input argument.
437
438 Number of rows and columns in the symmetrix matrix A.
439 Restriction: n >= 0.
440 Symamd returns FALSE if n is negative.
441
442 int A [nnz] ; Input argument.
443
444 A is an integer array of size nnz, where nnz = p [n].
445
446 The row indices of the entries in column c of the matrix are
447 held in A [(p [c]) ... (p [c+1]-1)]. The row indices in a
448 given column c need not be in ascending order, and duplicate
449 row indices may be present. However, symamd will run faster
450 if the columns are in sorted order with no duplicate entries.
451
452 The matrix is 0-based. That is, rows are in the range 0 to
453 n-1, and columns are in the range 0 to n-1. Symamd
454 returns FALSE if any row index is out of range.
455
456 The contents of A are not modified.
457
458 int p [n+1] ; Input argument.
459
460 p is an integer array of size n+1. On input, it holds the
461 "pointers" for the column form of the matrix A. Column c of
462 the matrix A is held in A [(p [c]) ... (p [c+1]-1)]. The first
463 entry, p [0], must be zero, and p [c] <= p [c+1] must hold
464 for all c in the range 0 to n-1. The value p [n] is
465 thus the total number of entries in the pattern of the matrix A.
466 Symamd returns FALSE if these conditions are not met.
467
468 The contents of p are not modified.
469
470 int perm [n+1] ; Output argument.
471
472 On output, if symamd returns TRUE, the array perm holds the
473 permutation P, where perm [0] is the first index in the new
474 ordering, and perm [n-1] is the last. That is, perm [k] = j
475 means that row and column j of A is the kth column in PAP',
476 where k is in the range 0 to n-1 (perm [0] = j means
477 that row and column j of A are the first row and column in
478 PAP'). The array is used as a workspace during the ordering,
479 which is why it must be of length n+1, not just n.
480
481 double knobs [COLAMD_KNOBS] ; Input argument.
482
483 See colamd_set_defaults for a description.
484
485 int stats [COLAMD_STATS] ; Output argument.
486
487 Statistics on the ordering, and error status.
488 See colamd.h for related definitions.
489 Symamd returns FALSE if stats is not present.
490
491 stats [0]: number of dense or empty row and columns ignored
492 (and ordered last in the output permutation
493 perm). Note that a row/column can become
494 "empty" if it contains only "dense" and/or
495 "empty" columns/rows.
496
497 stats [1]: (same as stats [0])
498
499 stats [2]: number of garbage collections performed.
500
501 stats [3]: status code. < 0 is an error code.
502 > 1 is a warning or notice.
503
504 0 OK. Each column of the input matrix contained
505 row indices in increasing order, with no
506 duplicates.
507
508 1 OK, but columns of input matrix were jumbled
509 (unsorted columns or duplicate entries). Symamd
510 had to do some extra work to sort the matrix
511 first and remove duplicate entries, but it
512 still was able to return a valid permutation
513 (return value of symamd was TRUE).
514
515 stats [4]: highest numbered column that
516 is unsorted or has duplicate
517 entries.
518 stats [5]: last seen duplicate or
519 unsorted row index.
520 stats [6]: number of duplicate or
521 unsorted row indices.
522
523 -1 A is a null pointer
524
525 -2 p is a null pointer
526
527 -3 (unused, see colamd.c)
528
529 -4 n is negative
530
531 stats [4]: n
532
533 -5 number of nonzeros in matrix is negative
534
535 stats [4]: # of nonzeros (p [n]).
536
537 -6 p [0] is nonzero
538
539 stats [4]: p [0]
540
541 -7 (unused)
542
543 -8 a column has a negative number of entries
544
545 stats [4]: column with < 0 entries
546 stats [5]: number of entries in col
547
548 -9 a row index is out of bounds
549
550 stats [4]: column with bad row index
551 stats [5]: bad row index
552 stats [6]: n_row, # of rows of matrx
553
554 -10 out of memory (unable to allocate temporary
555 workspace for M or count arrays using the
556 "allocate" routine passed into symamd).
557
558 Future versions may return more statistics in the stats array.
559
560 void * (*allocate) (size_t, size_t)
561
562 A pointer to a function providing memory allocation. The
563 allocated memory must be returned initialized to zero. For a
564 C application, this argument should normally be a pointer to
565 calloc. For a MATLAB mexFunction, the routine mxCalloc is
566 passed instead.
567
568 void (*release) (size_t, size_t)
569
570 A pointer to a function that frees memory allocated by the
571 memory allocation routine above. For a C application, this
572 argument should normally be a pointer to free. For a MATLAB
573 mexFunction, the routine mxFree is passed instead.
574
575
576 ----------------------------------------------------------------------------
577 colamd_report:
578 ----------------------------------------------------------------------------
579
580 C syntax:
581
582 #include "colamd.h"
583 colamd_report (int stats [COLAMD_STATS]) ;
584 colamd_l_report (UF_long stats [COLAMD_STATS]) ;
585
586 Purpose:
587
588 Prints the error status and statistics recorded in the stats
589 array on the standard error output (for a standard C routine)
590 or on the MATLAB output (for a mexFunction).
591
592 Arguments:
593
594 int stats [COLAMD_STATS] ; Input only. Statistics from colamd.
595
596
597 ----------------------------------------------------------------------------
598 symamd_report:
599 ----------------------------------------------------------------------------
600
601 C syntax:
602
603 #include "colamd.h"
604 symamd_report (int stats [COLAMD_STATS]) ;
605 symamd_l_report (UF_long stats [COLAMD_STATS]) ;
606
607 Purpose:
608
609 Prints the error status and statistics recorded in the stats
610 array on the standard error output (for a standard C routine)
611 or on the MATLAB output (for a mexFunction).
612
613 Arguments:
614
615 int stats [COLAMD_STATS] ; Input only. Statistics from symamd.
616
617
618 */
619
620 /* ========================================================================== */
621 /* === Scaffolding code definitions ======================================== */
622 /* ========================================================================== */
623
624 /* Ensure that debugging is turned off: */
625 #ifndef NDEBUG
626 #define NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
627 #endif
628
629 /* turn on debugging by uncommenting the following line
630 #undef NDEBUG
631 */
632
633 /*
634 Our "scaffolding code" philosophy: In our opinion, well-written library
635 code should keep its "debugging" code, and just normally have it turned off
636 by the compiler so as not to interfere with performance. This serves
637 several purposes:
638
639 (1) assertions act as comments to the reader, telling you what the code
640 expects at that point. All assertions will always be true (unless
641 there really is a bug, of course).
642
643 (2) leaving in the scaffolding code assists anyone who would like to modify
644 the code, or understand the algorithm (by reading the debugging output,
645 one can get a glimpse into what the code is doing).
646
647 (3) (gasp!) for actually finding bugs. This code has been heavily tested
648 and "should" be fully functional and bug-free ... but you never know...
649
650 The code will become outrageously slow when debugging is
651 enabled. To control the level of debugging output, set an environment
652 variable D to 0 (little), 1 (some), 2, 3, or 4 (lots). When debugging,
653 you should see the following message on the standard output:
654
655 colamd: debug version, D = 1 (THIS WILL BE SLOW!)
656
657 or a similar message for symamd. If you don't, then debugging has not
658 been enabled.
659
660 */
661
662 /* ========================================================================== */
663 /* === Include files ======================================================== */
664 /* ========================================================================== */
665
666 #include "colamd.h"cxx . . $ `<file>/external/glpk/colamd.h`/
667
668 #if 0 /* by mao */
669 #include <limits.h>
670 #include <math.h>
671
672 #ifdef MATLAB_MEX_FILE
673 #include "mex.h"
674 #include "matrix.h"
675 #endif /* MATLAB_MEX_FILE */
676
677 #if !defined (NPRINT) || !defined (NDEBUG)
678 #include <stdio.h>
679 #endif
680
681 #ifndef NULL
682 #define NULL ((void *) 0)
683 #endif
684 #endif
685
686 /* ========================================================================== */
687 /* === int or UF_long ======================================================= */
688 /* ========================================================================== */
689
690 #if 0 /* by mao */
691 /* define UF_long */
692 #include "UFconfig.h"
693 #endif
694
695 #ifdef DLONG
696
697 #define Int UF_long
698 #define ID UF_long_id
699 #define Int_MAX UF_long_max
700
701 #define COLAMD_recommended colamd_l_recommended
702 #define COLAMD_set_defaults colamd_l_set_defaults
703 #define COLAMD_MAIN colamd_l
704 #define SYMAMD_MAIN symamd_l
705 #define COLAMD_report colamd_l_report
706 #define SYMAMD_report symamd_l_report
707
708 #else
709
710 #define Intcxx . . $ `external/glpk/colamd.c:710:9`! int
711 #define IDcxx . . $ `external/glpk/colamd.c:711:9`! "%d"
712 #define Int_MAXcxx . . $ `external/glpk/colamd.c:712:9`! INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!
713
714 #define COLAMD_recommendedcxx . . $ `external/glpk/colamd.c:714:9`! colamd_recommendedcxx . . $ `external/glpk/colamd.h:44:9`!
715 #define COLAMD_set_defaultscxx . . $ `external/glpk/colamd.c:715:9`! colamd_set_defaultscxx . . $ `external/glpk/colamd.h:47:9`!
716 #define COLAMD_MAINcxx . . $ `external/glpk/colamd.c:716:9`! colamdcxx . . $ `external/glpk/colamd.h:50:9`!
717 #define SYMAMD_MAINcxx . . $ `external/glpk/colamd.c:717:9`! symamdcxx . . $ `external/glpk/colamd.h:54:9`!
718 #define COLAMD_reportcxx . . $ `external/glpk/colamd.c:718:9`! colamd_reportcxx . . $ `external/glpk/colamd.h:59:9`!
719 #define SYMAMD_reportcxx . . $ `external/glpk/colamd.c:719:9`! symamd_reportcxx . . $ `external/glpk/colamd.h:62:9`!
720
721 #endif
722
723 /* ========================================================================== */
724 /* === Row and Column structures ============================================ */
725 /* ========================================================================== */
726
727 /* User code that makes use of the colamd/symamd routines need not directly */
728 /* reference these structures. They are used only for colamd_recommended. */
729
730 typedef struct Colamd_Col_structcxx . . $ Colamd_Col_struct#
731 {
732 Intcxx . . $ `external/glpk/colamd.c:710:9`! startcxx . . $ Colamd_Col_struct#start. ; /* index for A of first row in this column, or DEAD */
733 /* if column is dead */
734 Intcxx . . $ `external/glpk/colamd.c:710:9`! lengthcxx . . $ Colamd_Col_struct#length. ; /* number of rows in this column */
735 unioncxx . . $ Colamd_Col_struct#$anonymous_type_0#
736 {
737 Intcxx . . $ `external/glpk/colamd.c:710:9`! thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. ; /* number of original columns represented by this */
738 /* col, if the column is alive */
739 Intcxx . . $ `external/glpk/colamd.c:710:9`! parentcxx . . $ Colamd_Col_struct#$anonymous_type_0#parent. ; /* parent in parent tree super-column structure, if */
740 /* the column is dead */
741 } shared1cxx . . $ Colamd_Col_struct#shared1. ;
742 unioncxx . . $ Colamd_Col_struct#$anonymous_type_1#
743 {
744 Intcxx . . $ `external/glpk/colamd.c:710:9`! scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. ; /* the score used to maintain heap, if col is alive */
745 Intcxx . . $ `external/glpk/colamd.c:710:9`! ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. ; /* pivot ordering of this column, if col is dead */
746 } shared2cxx . . $ Colamd_Col_struct#shared2. ;
747 unioncxx . . $ Colamd_Col_struct#$anonymous_type_2#
748 {
749 Intcxx . . $ `external/glpk/colamd.c:710:9`! headhashcxx . . $ Colamd_Col_struct#$anonymous_type_2#headhash. ; /* head of a hash bucket, if col is at the head of */
750 /* a degree list */
751 Intcxx . . $ `external/glpk/colamd.c:710:9`! hashcxx . . $ Colamd_Col_struct#$anonymous_type_2#hash. ; /* hash value, if col is not in a degree list */
752 Intcxx . . $ `external/glpk/colamd.c:710:9`! prevcxx . . $ Colamd_Col_struct#$anonymous_type_2#prev. ; /* previous column in degree list, if col is in a */
753 /* degree list (but not at the head of a degree list) */
754 } shared3cxx . . $ Colamd_Col_struct#shared3. ;
755 unioncxx . . $ Colamd_Col_struct#$anonymous_type_3#
756 {
757 Intcxx . . $ `external/glpk/colamd.c:710:9`! degree_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#degree_next. ; /* next column, if col is in a degree list */
758 Intcxx . . $ `external/glpk/colamd.c:710:9`! hash_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#hash_next. ; /* next column, if col is in a hash list */
759 } shared4cxx . . $ Colamd_Col_struct#shared4. ;
760
761 } Colamd_Colcxx . . $ Colamd_Col# ;
762
763 typedef struct Colamd_Row_structcxx . . $ Colamd_Row_struct#
764 {
765 Intcxx . . $ `external/glpk/colamd.c:710:9`! startcxx . . $ Colamd_Row_struct#start. ; /* index for A of first col in this row */
766 Intcxx . . $ `external/glpk/colamd.c:710:9`! lengthcxx . . $ Colamd_Row_struct#length. ; /* number of principal columns in this row */
767 unioncxx . . $ Colamd_Row_struct#$anonymous_type_4#
768 {
769 Intcxx . . $ `external/glpk/colamd.c:710:9`! degreecxx . . $ Colamd_Row_struct#$anonymous_type_4#degree. ; /* number of principal & non-principal columns in row */
770 Intcxx . . $ `external/glpk/colamd.c:710:9`! pcxx . . $ Colamd_Row_struct#$anonymous_type_4#p. ; /* used as a row pointer in init_rows_cols () */
771 } shared1cxx . . $ Colamd_Row_struct#shared1. ;
772 unioncxx . . $ Colamd_Row_struct#$anonymous_type_5#
773 {
774 Intcxx . . $ `external/glpk/colamd.c:710:9`! markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. ; /* for computing set differences and marking dead rows*/
775 Intcxx . . $ `external/glpk/colamd.c:710:9`! first_columncxx . . $ Colamd_Row_struct#$anonymous_type_5#first_column. ;/* first column in row (used in garbage collection) */
776 } shared2cxx . . $ Colamd_Row_struct#shared2. ;
777
778 } Colamd_Rowcxx . . $ Colamd_Row# ;
779
780 /* ========================================================================== */
781 /* === Definitions ========================================================== */
782 /* ========================================================================== */
783
784 /* Routines are either PUBLIC (user-callable) or PRIVATE (not user-callable) */
785 #define PUBLICcxx . . $ `external/glpk/colamd.c:785:9`!
786 #define PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! static
787
788 #define DENSE_DEGREEcxx . . $ `external/glpk/colamd.c:788:9`!(alpha,n) \
789 ((Intcxx . . $ `external/glpk/colamd.c:710:9`!) MAXcxx . . $ `external/glpk/colamd.c:791:9`! (16.0, (alpha) * sqrt ((double) (n))))
790
791 #define MAXcxx . . $ `external/glpk/colamd.c:791:9`!(a,b) (((a) > (b)) ? (a) : (b))
792 #define MINcxx . . $ `external/glpk/colamd.c:792:9`!(a,b) (((a) < (b)) ? (a) : (b))
793
794 #define ONES_COMPLEMENTcxx . . $ `external/glpk/colamd.c:794:9`!(r) (-(r)-1)
795
796 /* -------------------------------------------------------------------------- */
797 /* Change for version 2.1: define TRUE and FALSE only if not yet defined */
798 /* -------------------------------------------------------------------------- */
799
800 #ifndef TRUE
801 #define TRUEcxx . . $ `external/glpk/colamd.c:801:9`! (1)
802 #endif
803
804 #ifndef FALSE
805 #define FALSEcxx . . $ `external/glpk/colamd.c:805:9`! (0)
806 #endif
807
808 /* -------------------------------------------------------------------------- */
809
810 #define EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! (-1)
811
812 /* Row and column status */
813 #define ALIVEcxx . . $ `external/glpk/colamd.c:813:9`! (0)
814 #define DEADcxx . . $ `external/glpk/colamd.c:814:9`! (-1)
815
816 /* Column status */
817 #define DEAD_PRINCIPALcxx . . $ `external/glpk/colamd.c:817:9`! (-1)
818 #define DEAD_NON_PRINCIPALcxx . . $ `external/glpk/colamd.c:818:9`! (-2)
819
820 /* Macros for row and column status update and checking. */
821 #define ROW_IS_DEADcxx . . $ `external/glpk/colamd.c:821:9`!(r) ROW_IS_MARKED_DEADcxx . . $ `external/glpk/colamd.c:822:9`! (Row[r].shared2.mark)
822 #define ROW_IS_MARKED_DEADcxx . . $ `external/glpk/colamd.c:822:9`!(row_mark) (row_mark < ALIVEcxx . . $ `external/glpk/colamd.c:813:9`!)
823 #define ROW_IS_ALIVEcxx . . $ `external/glpk/colamd.c:823:9`!(r) (Row [r].shared2.mark >= ALIVEcxx . . $ `external/glpk/colamd.c:813:9`!)
824 #define COL_IS_DEADcxx . . $ `external/glpk/colamd.c:824:9`!(c) (Col [c].start < ALIVEcxx . . $ `external/glpk/colamd.c:813:9`!)
825 #define COL_IS_ALIVEcxx . . $ `external/glpk/colamd.c:825:9`!(c) (Col [c].start >= ALIVEcxx . . $ `external/glpk/colamd.c:813:9`!)
826 #define COL_IS_DEAD_PRINCIPALcxx . . $ `external/glpk/colamd.c:826:9`!(c) (Col [c].start == DEAD_PRINCIPALcxx . . $ `external/glpk/colamd.c:817:9`!)
827 #define KILL_ROWcxx . . $ `external/glpk/colamd.c:827:9`!(r) { Row [r].shared2.mark = DEADcxx . . $ `external/glpk/colamd.c:814:9`! ; }
828 #define KILL_PRINCIPAL_COLcxx . . $ `external/glpk/colamd.c:828:9`!(c) { Col [c].start = DEAD_PRINCIPALcxx . . $ `external/glpk/colamd.c:817:9`! ; }
829 #define KILL_NON_PRINCIPAL_COLcxx . . $ `external/glpk/colamd.c:829:9`!(c) { Col [c].start = DEAD_NON_PRINCIPALcxx . . $ `external/glpk/colamd.c:818:9`! ; }
830
831 /* ========================================================================== */
832 /* === Colamd reporting mechanism =========================================== */
833 /* ========================================================================== */
834
835 #if defined (MATLAB_MEX_FILE) || defined (MATHWORKS)
836 /* In MATLAB, matrices are 1-based to the user, but 0-based internally */
837 #define INDEX(i) ((i)+1)
838 #else
839 /* In C, matrices are 0-based and indices are reported as such in *_report */
840 #define INDEXcxx . . $ `external/glpk/colamd.c:840:9`!(i) (i)
841 #endif
842
843 /* All output goes through the PRINTF macro. */
844 #define PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(params) { if (colamd_printfcxx . . $ `external/glpk/colamd.h:65:9`! != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) (void) colamd_printfcxx . . $ `external/glpk/colamd.h:65:9`! params ; }
845
846 /* ========================================================================== */
847 /* === Prototypes of PRIVATE routines ======================================= */
848 /* ========================================================================== */
849
850 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! init_rows_colscxx . . $ init_rows_cols(a85c37ca31396963).
851 (
852 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row,
853 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col,
854 Colamd_Rowcxx . . $ Colamd_Row# Row [],
855 Colamd_Colcxx . . $ Colamd_Col# Col [],
856 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [],
857 Intcxx . . $ `external/glpk/colamd.c:710:9`! p [],
858 Intcxx . . $ `external/glpk/colamd.c:710:9`! stats [COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`!]
859 ) ;
860
861 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! void init_scoringcxx . . $ init_scoring(d1029ecdd7227091).
862 (
863 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row,
864 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col,
865 Colamd_Rowcxx . . $ Colamd_Row# Row [],
866 Colamd_Colcxx . . $ Colamd_Col# Col [],
867 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [],
868 Intcxx . . $ `external/glpk/colamd.c:710:9`! head [],
869 double knobs [COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`!],
870 Intcxx . . $ `external/glpk/colamd.c:710:9`! *p_n_row2,
871 Intcxx . . $ `external/glpk/colamd.c:710:9`! *p_n_col2,
872 Intcxx . . $ `external/glpk/colamd.c:710:9`! *p_max_deg
873 ) ;
874
875 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! find_orderingcxx . . $ find_ordering(7f397f83d5f3a4b2).
876 (
877 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row,
878 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col,
879 Intcxx . . $ `external/glpk/colamd.c:710:9`! Alen,
880 Colamd_Rowcxx . . $ Colamd_Row# Row [],
881 Colamd_Colcxx . . $ Colamd_Col# Col [],
882 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [],
883 Intcxx . . $ `external/glpk/colamd.c:710:9`! head [],
884 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col2,
885 Intcxx . . $ `external/glpk/colamd.c:710:9`! max_deg,
886 Intcxx . . $ `external/glpk/colamd.c:710:9`! pfree,
887 Intcxx . . $ `external/glpk/colamd.c:710:9`! aggressive
888 ) ;
889
890 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! void order_childrencxx . . $ order_children(af26e60859f2017e).
891 (
892 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col,
893 Colamd_Colcxx . . $ Colamd_Col# Col [],
894 Intcxx . . $ `external/glpk/colamd.c:710:9`! p []
895 ) ;
896
897 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! void detect_super_colscxx . . $ detect_super_cols(e427314c50360653).
898 (
899
900 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
901 Int n_col,
902 Colamd_Row Row [],
903 #endif /* NDEBUG */
904
905 Colamd_Colcxx . . $ Colamd_Col# Col [],
906 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [],
907 Intcxx . . $ `external/glpk/colamd.c:710:9`! head [],
908 Intcxx . . $ `external/glpk/colamd.c:710:9`! row_start,
909 Intcxx . . $ `external/glpk/colamd.c:710:9`! row_length
910 ) ;
911
912 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! garbage_collectioncxx . . $ garbage_collection(59e400dca74828d0).
913 (
914 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row,
915 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col,
916 Colamd_Rowcxx . . $ Colamd_Row# Row [],
917 Colamd_Colcxx . . $ Colamd_Col# Col [],
918 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [],
919 Intcxx . . $ `external/glpk/colamd.c:710:9`! *pfree
920 ) ;
921
922 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! clear_markcxx . . $ clear_mark(a64fdf7fc08061e1).
923 (
924 Intcxx . . $ `external/glpk/colamd.c:710:9`! tag_mark,
925 Intcxx . . $ `external/glpk/colamd.c:710:9`! max_mark,
926 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row,
927 Colamd_Rowcxx . . $ Colamd_Row# Row []
928 ) ;
929
930 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! void print_reportcxx . . $ print_report(56561451ddc58846).
931 (
932 char *method,
933 Intcxx . . $ `external/glpk/colamd.c:710:9`! stats [COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`!]
934 ) ;
935
936 /* ========================================================================== */
937 /* === Debugging prototypes and definitions ================================= */
938 /* ========================================================================== */
939
940 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
941
942 #if 0 /* by mao */
943 #include <assert.h>
944 #endif
945
946 /* colamd_debug is the *ONLY* global variable, and is only */
947 /* present when debugging */
948
949 PRIVATE Int colamd_debug = 0 ; /* debug print level */
950
951 #define DEBUG0(params) { PRINTF (params) ; }
952 #define DEBUG1(params) { if (colamd_debug >= 1) PRINTF (params) ; }
953 #define DEBUG2(params) { if (colamd_debug >= 2) PRINTF (params) ; }
954 #define DEBUG3(params) { if (colamd_debug >= 3) PRINTF (params) ; }
955 #define DEBUG4(params) { if (colamd_debug >= 4) PRINTF (params) ; }
956
957 #if 0 /* by mao */
958 #ifdef MATLAB_MEX_FILE
959 #define ASSERT(expression) (mxAssert ((expression), ""))
960 #else
961 #define ASSERT(expression) (assert (expression))
962 #endif /* MATLAB_MEX_FILE */
963 #else
964 #define ASSERT xassert
965 #endif
966
967 PRIVATE void colamd_get_debug /* gets the debug print level from getenv */
968 (
969 char *method
970 ) ;
971
972 PRIVATE void debug_deg_lists
973 (
974 Int n_row,
975 Int n_col,
976 Colamd_Row Row [],
977 Colamd_Col Col [],
978 Int head [],
979 Int min_score,
980 Int should,
981 Int max_deg
982 ) ;
983
984 PRIVATE void debug_mark
985 (
986 Int n_row,
987 Colamd_Row Row [],
988 Int tag_mark,
989 Int max_mark
990 ) ;
991
992 PRIVATE void debug_matrix
993 (
994 Int n_row,
995 Int n_col,
996 Colamd_Row Row [],
997 Colamd_Col Col [],
998 Int A []
999 ) ;
1000
1001 PRIVATE void debug_structures
1002 (
1003 Int n_row,
1004 Int n_col,
1005 Colamd_Row Row [],
1006 Colamd_Col Col [],
1007 Int A [],
1008 Int n_col2
1009 ) ;
1010
1011 #else /* NDEBUG */
1012
1013 /* === No debugging ========================================================= */
1014
1015 #define DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`!(params) ;
1016 #define DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`!(params) ;
1017 #define DEBUG2cxx . . $ `external/glpk/colamd.c:1017:9`!(params) ;
1018 #define DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`!(params) ;
1019 #define DEBUG4cxx . . $ `external/glpk/colamd.c:1019:9`!(params) ;
1020
1021 #define ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`!(expression)
1022
1023 #endif /* NDEBUG */
1024
1025 /* ========================================================================== */
1026 /* === USER-CALLABLE ROUTINES: ============================================== */
1027 /* ========================================================================== */
1028
1029 /* ========================================================================== */
1030 /* === colamd_recommended =================================================== */
1031 /* ========================================================================== */
1032
1033 /*
1034 The colamd_recommended routine returns the suggested size for Alen. This
1035 value has been determined to provide good balance between the number of
1036 garbage collections and the memory requirements for colamd. If any
1037 argument is negative, or if integer overflow occurs, a 0 is returned as an
1038 error condition. 2*nnz space is required for the row and column
1039 indices of the matrix. COLAMD_C (n_col) + COLAMD_R (n_row) space is
1040 required for the Col and Row arrays, respectively, which are internal to
1041 colamd (roughly 6*n_col + 4*n_row). An additional n_col space is the
1042 minimal amount of "elbow room", and nnz/5 more space is recommended for
1043 run time efficiency.
1044
1045 Alen is approximately 2.2*nnz + 7*n_col + 4*n_row + 10.
1046
1047 This function is not needed when using symamd.
1048 */
1049
1050 /* add two values of type size_t, and check for integer overflow */
1051 static size_t t_addcxx . . $ t_add(650fbc31364c7391). (size_t a, size_t b, int *ok)
1052 {
1053 (*ok) = (*ok) && ((a + b) >= MAXcxx . . $ `external/glpk/colamd.c:791:9`! (a,b)) ;
1054 return ((*ok) ? (a + b) : 0) ;
1055 }
1056
1057 /* compute a*k where k is a small integer, and check for integer overflow */
1058 static size_t t_multcxx . . $ t_mult(650fbc31364c7391). (size_t a, size_t k, int *ok)
1059 {
1060 size_t i, s = 0 ;
1061 for (i = 0 ; i < k ; i++)
1062 {
1063 s = t_addcxx . . $ t_add(650fbc31364c7391). (s, a, ok) ;
1064 }
1065 return (s) ;
1066 }
1067
1068 /* size of the Col and Row structures */
1069 #define COLAMD_Ccxx . . $ `external/glpk/colamd.c:1069:9`!(n_col,ok) \
1070 ((t_mult (t_add (n_col, 1, ok), sizeof (Colamd_Col), ok) / sizeof (Intcxx . . $ `external/glpk/colamd.c:710:9`!)))
1071
1072 #define COLAMD_Rcxx . . $ `external/glpk/colamd.c:1072:9`!(n_row,ok) \
1073 ((t_mult (t_add (n_row, 1, ok), sizeof (Colamd_Row), ok) / sizeof (Intcxx . . $ `external/glpk/colamd.c:710:9`!)))
1074
1075
1076 PUBLICcxx . . $ `external/glpk/colamd.c:785:9`! size_t COLAMD_recommendedcxx . . $ `external/glpk/colamd.c:714:9`! /* returns recommended value of Alen. */
1077 (
1078 /* === Parameters ======================================================= */
1079
1080 Intcxx . . $ `external/glpk/colamd.c:710:9`! nnz, /* number of nonzeros in A */
1081 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row, /* number of rows in A */
1082 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col /* number of columns in A */
1083 )
1084 {
1085 size_t s, c, r ;
1086 int ok = TRUEcxx . . $ `external/glpk/colamd.c:801:9`! ;
1087 if (nnz < 0 || n_row < 0 || n_col < 0)
1088 {
1089 return (0) ;
1090 }
1091 s = t_multcxx . . $ t_mult(650fbc31364c7391). (nnz, 2, &ok) ; /* 2*nnz */
1092 c = COLAMD_Ccxx . . $ `external/glpk/colamd.c:1069:9`! (n_col, &ok) ; /* size of column structures */
1093 r = COLAMD_Rcxx . . $ `external/glpk/colamd.c:1072:9`! (n_row, &ok) ; /* size of row structures */
1094 s = t_addcxx . . $ t_add(650fbc31364c7391). (s, c, &ok) ;
1095 s = t_addcxx . . $ t_add(650fbc31364c7391). (s, r, &ok) ;
1096 s = t_addcxx . . $ t_add(650fbc31364c7391). (s, n_col, &ok) ; /* elbow room */
1097 s = t_addcxx . . $ t_add(650fbc31364c7391). (s, nnz/5, &ok) ; /* elbow room */
1098 ok = ok && (s < Int_MAXcxx . . $ `external/glpk/colamd.c:712:9`!) ;
1099 return (ok ? s : 0) ;
1100 }
1101
1102
1103 /* ========================================================================== */
1104 /* === colamd_set_defaults ================================================== */
1105 /* ========================================================================== */
1106
1107 /*
1108 The colamd_set_defaults routine sets the default values of the user-
1109 controllable parameters for colamd and symamd:
1110
1111 Colamd: rows with more than max (16, knobs [0] * sqrt (n_col))
1112 entries are removed prior to ordering. Columns with more than
1113 max (16, knobs [1] * sqrt (MIN (n_row,n_col))) entries are removed
1114 prior to ordering, and placed last in the output column ordering.
1115
1116 Symamd: Rows and columns with more than max (16, knobs [0] * sqrt (n))
1117 entries are removed prior to ordering, and placed last in the
1118 output ordering.
1119
1120 knobs [0] dense row control
1121
1122 knobs [1] dense column control
1123
1124 knobs [2] if nonzero, do aggresive absorption
1125
1126 knobs [3..19] unused, but future versions might use this
1127
1128 */
1129
1130 PUBLICcxx . . $ `external/glpk/colamd.c:785:9`! void COLAMD_set_defaultscxx . . $ `external/glpk/colamd.c:715:9`!
1131 (
1132 /* === Parameters ======================================================= */
1133
1134 double knobs [COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`!] /* knob array */
1135 )
1136 {
1137 /* === Local variables ================================================== */
1138
1139 Intcxx . . $ `external/glpk/colamd.c:710:9`! i ;
1140
1141 if (!knobs)
1142 {
1143 return ; /* no knobs to initialize */
1144 }
1145 for (i = 0 ; i < COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`! ; i++)
1146 {
1147 knobs [i] = 0 ;
1148 }
1149 knobs [COLAMD_DENSE_ROWcxx . . $ `external/glpk/colamd.h:21:9`!] = 10 ;
1150 knobs [COLAMD_DENSE_COLcxx . . $ `external/glpk/colamd.h:22:9`!] = 10 ;
1151 knobs [COLAMD_AGGRESSIVEcxx . . $ `external/glpk/colamd.h:23:9`!] = TRUEcxx . . $ `external/glpk/colamd.c:801:9`! ; /* default: do aggressive absorption*/
1152 }
1153
1154
1155 /* ========================================================================== */
1156 /* === symamd =============================================================== */
1157 /* ========================================================================== */
1158
1159 PUBLICcxx . . $ `external/glpk/colamd.c:785:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! SYMAMD_MAINcxx . . $ `external/glpk/colamd.c:717:9`! /* return TRUE if OK, FALSE otherwise */
1160 (
1161 /* === Parameters ======================================================= */
1162
1163 Intcxx . . $ `external/glpk/colamd.c:710:9`! n, /* number of rows and columns of A */
1164 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [], /* row indices of A */
1165 Intcxx . . $ `external/glpk/colamd.c:710:9`! p [], /* column pointers of A */
1166 Intcxx . . $ `external/glpk/colamd.c:710:9`! perm [], /* output permutation, size n+1 */
1167 double knobs [COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`!], /* parameters (uses defaults if NULL) */
1168 Intcxx . . $ `external/glpk/colamd.c:710:9`! stats [COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`!], /* output statistics and error codes */
1169 void * (*allocate) (size_t, size_t),
1170 /* pointer to calloc (ANSI C) or */
1171 /* mxCalloc (for MATLAB mexFunction) */
1172 void (*release) (void *)
1173 /* pointer to free (ANSI C) or */
1174 /* mxFree (for MATLAB mexFunction) */
1175 )
1176 {
1177 /* === Local variables ================================================== */
1178
1179 Intcxx . . $ `external/glpk/colamd.c:710:9`! *count ; /* length of each column of M, and col pointer*/
1180 Intcxx . . $ `external/glpk/colamd.c:710:9`! *mark ; /* mark array for finding duplicate entries */
1181 Intcxx . . $ `external/glpk/colamd.c:710:9`! *M ; /* row indices of matrix M */
1182 size_t Mlen ; /* length of M */
1183 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row ; /* number of rows in M */
1184 Intcxx . . $ `external/glpk/colamd.c:710:9`! nnz ; /* number of entries in A */
1185 Intcxx . . $ `external/glpk/colamd.c:710:9`! i ; /* row index of A */
1186 Intcxx . . $ `external/glpk/colamd.c:710:9`! j ; /* column index of A */
1187 Intcxx . . $ `external/glpk/colamd.c:710:9`! k ; /* row index of M */
1188 Intcxx . . $ `external/glpk/colamd.c:710:9`! mnz ; /* number of nonzeros in M */
1189 Intcxx . . $ `external/glpk/colamd.c:710:9`! pp ; /* index into a column of A */
1190 Intcxx . . $ `external/glpk/colamd.c:710:9`! last_row ; /* last row seen in the current column */
1191 Intcxx . . $ `external/glpk/colamd.c:710:9`! length ; /* number of nonzeros in a column */
1192
1193 double cknobs [COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`!] ; /* knobs for colamd */
1194 double default_knobs [COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`!] ; /* default knobs for colamd */
1195
1196 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
1197 colamd_get_debug ("symamd") ;
1198 #endif /* NDEBUG */
1199
1200 /* === Check the input arguments ======================================== */
1201
1202 if (!stats)
1203 {
1204 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: stats not present\n")) ;
1205 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1206 }
1207 for (i = 0 ; i < COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`! ; i++)
1208 {
1209 stats [i] = 0 ;
1210 }
1211 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_OKcxx . . $ `external/glpk/colamd.h:30:9`! ;
1212 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = -1 ;
1213 stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] = -1 ;
1214
1215 if (!A)
1216 {
1217 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_A_not_presentcxx . . $ `external/glpk/colamd.h:32:9`! ;
1218 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: A not present\n")) ;
1219 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1220 }
1221
1222 if (!p) /* p is not present */
1223 {
1224 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_p_not_presentcxx . . $ `external/glpk/colamd.h:33:9`! ;
1225 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: p not present\n")) ;
1226 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1227 }
1228
1229 if (n < 0) /* n must be >= 0 */
1230 {
1231 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_ncol_negativecxx . . $ `external/glpk/colamd.h:35:9`! ;
1232 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = n ;
1233 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: n negative %d\n", n)) ;
1234 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1235 }
1236
1237 nnz = p [n] ;
1238 if (nnz < 0) /* nnz must be >= 0 */
1239 {
1240 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_nnz_negativecxx . . $ `external/glpk/colamd.h:36:9`! ;
1241 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = nnz ;
1242 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: number of entries negative %d\n", nnz)) ;
1243 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1244 }
1245
1246 if (p [0] != 0)
1247 {
1248 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_p0_nonzerocxx . . $ `external/glpk/colamd.h:37:9`! ;
1249 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = p [0] ;
1250 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: p[0] not zero %d\n", p [0])) ;
1251 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1252 }
1253
1254 /* === If no knobs, set default knobs =================================== */
1255
1256 if (!knobs)
1257 {
1258 COLAMD_set_defaultscxx . . $ `external/glpk/colamd.c:715:9`! (default_knobs) ;
1259 knobs = default_knobs ;
1260 }
1261
1262 /* === Allocate count and mark ========================================== */
1263
1264 count = (Intcxx . . $ `external/glpk/colamd.c:710:9`! *) ((*allocate) (n+1, sizeof (Intcxx . . $ `external/glpk/colamd.c:710:9`!))) ;
1265 if (!count)
1266 {
1267 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_out_of_memorycxx . . $ `external/glpk/colamd.h:41:9`! ;
1268 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: allocate count (size %d) failed\n", n+1)) ;
1269 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1270 }
1271
1272 mark = (Intcxx . . $ `external/glpk/colamd.c:710:9`! *) ((*allocate) (n+1, sizeof (Intcxx . . $ `external/glpk/colamd.c:710:9`!))) ;
1273 if (!mark)
1274 {
1275 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_out_of_memorycxx . . $ `external/glpk/colamd.h:41:9`! ;
1276 (*release) ((void *) count) ;
1277 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: allocate mark (size %d) failed\n", n+1)) ;
1278 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1279 }
1280
1281 /* === Compute column counts of M, check if A is valid ================== */
1282
1283 stats [COLAMD_INFO3cxx . . $ `external/glpk/colamd.h:28:9`!] = 0 ; /* number of duplicate or unsorted row indices*/
1284
1285 for (i = 0 ; i < n ; i++)
1286 {
1287 mark [i] = -1 ;
1288 }
1289
1290 for (j = 0 ; j < n ; j++)
1291 {
1292 last_row = -1 ;
1293
1294 length = p [j+1] - p [j] ;
1295 if (length < 0)
1296 {
1297 /* column pointers must be non-decreasing */
1298 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_col_length_negativecxx . . $ `external/glpk/colamd.h:39:9`! ;
1299 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = j ;
1300 stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] = length ;
1301 (*release) ((void *) count) ;
1302 (*release) ((void *) mark) ;
1303 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: col %d negative length %d\n", j, length)) ;
1304 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1305 }
1306
1307 for (pp = p [j] ; pp < p [j+1] ; pp++)
1308 {
1309 i = A [pp] ;
1310 if (i < 0 || i >= n)
1311 {
1312 /* row index i, in column j, is out of bounds */
1313 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_row_index_out_of_boundscxx . . $ `external/glpk/colamd.h:40:9`! ;
1314 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = j ;
1315 stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] = i ;
1316 stats [COLAMD_INFO3cxx . . $ `external/glpk/colamd.h:28:9`!] = n ;
1317 (*release) ((void *) count) ;
1318 (*release) ((void *) mark) ;
1319 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: row %d col %d out of bounds\n", i, j)) ;
1320 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1321 }
1322
1323 if (i <= last_row || mark [i] == j)
1324 {
1325 /* row index is unsorted or repeated (or both), thus col */
1326 /* is jumbled. This is a notice, not an error condition. */
1327 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_OK_BUT_JUMBLEDcxx . . $ `external/glpk/colamd.h:31:9`! ;
1328 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = j ;
1329 stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] = i ;
1330 (stats [COLAMD_INFO3cxx . . $ `external/glpk/colamd.h:28:9`!]) ++ ;
1331 DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`! (("symamd: row %d col %d unsorted/duplicate\n", i, j)) ;
1332 }
1333
1334 if (i > j && mark [i] != j)
1335 {
1336 /* row k of M will contain column indices i and j */
1337 count [i]++ ;
1338 count [j]++ ;
1339 }
1340
1341 /* mark the row as having been seen in this column */
1342 mark [i] = j ;
1343
1344 last_row = i ;
1345 }
1346 }
1347
1348 /* v2.4: removed free(mark) */
1349
1350 /* === Compute column pointers of M ===================================== */
1351
1352 /* use output permutation, perm, for column pointers of M */
1353 perm [0] = 0 ;
1354 for (j = 1 ; j <= n ; j++)
1355 {
1356 perm [j] = perm [j-1] + count [j-1] ;
1357 }
1358 for (j = 0 ; j < n ; j++)
1359 {
1360 count [j] = perm [j] ;
1361 }
1362
1363 /* === Construct M ====================================================== */
1364
1365 mnz = perm [n] ;
1366 n_row = mnz / 2 ;
1367 Mlen = COLAMD_recommendedcxx . . $ `external/glpk/colamd.c:714:9`! (mnz, n_row, n) ;
1368 M = (Intcxx . . $ `external/glpk/colamd.c:710:9`! *) ((*allocate) (Mlen, sizeof (Intcxx . . $ `external/glpk/colamd.c:710:9`!))) ;
1369 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: M is %d-by-%d with %d entries, Mlen = %g\n",
1370 n_row, n, mnz, (double) Mlen)) ;
1371
1372 if (!M)
1373 {
1374 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_out_of_memorycxx . . $ `external/glpk/colamd.h:41:9`! ;
1375 (*release) ((void *) count) ;
1376 (*release) ((void *) mark) ;
1377 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: allocate M (size %g) failed\n", (double) Mlen)) ;
1378 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1379 }
1380
1381 k = 0 ;
1382
1383 if (stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] == COLAMD_OKcxx . . $ `external/glpk/colamd.h:30:9`!)
1384 {
1385 /* Matrix is OK */
1386 for (j = 0 ; j < n ; j++)
1387 {
1388 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (p [j+1] - p [j] >= 0) ;
1389 for (pp = p [j] ; pp < p [j+1] ; pp++)
1390 {
1391 i = A [pp] ;
1392 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (i >= 0 && i < n) ;
1393 if (i > j)
1394 {
1395 /* row k of M contains column indices i and j */
1396 M [count [i]++] = k ;
1397 M [count [j]++] = k ;
1398 k++ ;
1399 }
1400 }
1401 }
1402 }
1403 else
1404 {
1405 /* Matrix is jumbled. Do not add duplicates to M. Unsorted cols OK. */
1406 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: Duplicates in A.\n")) ;
1407 for (i = 0 ; i < n ; i++)
1408 {
1409 mark [i] = -1 ;
1410 }
1411 for (j = 0 ; j < n ; j++)
1412 {
1413 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (p [j+1] - p [j] >= 0) ;
1414 for (pp = p [j] ; pp < p [j+1] ; pp++)
1415 {
1416 i = A [pp] ;
1417 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (i >= 0 && i < n) ;
1418 if (i > j && mark [i] != j)
1419 {
1420 /* row k of M contains column indices i and j */
1421 M [count [i]++] = k ;
1422 M [count [j]++] = k ;
1423 k++ ;
1424 mark [i] = j ;
1425 }
1426 }
1427 }
1428 /* v2.4: free(mark) moved below */
1429 }
1430
1431 /* count and mark no longer needed */
1432 (*release) ((void *) count) ;
1433 (*release) ((void *) mark) ; /* v2.4: free (mark) moved here */
1434 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (k == n_row) ;
1435
1436 /* === Adjust the knobs for M =========================================== */
1437
1438 for (i = 0 ; i < COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`! ; i++)
1439 {
1440 cknobs [i] = knobs [i] ;
1441 }
1442
1443 /* there are no dense rows in M */
1444 cknobs [COLAMD_DENSE_ROWcxx . . $ `external/glpk/colamd.h:21:9`!] = -1 ;
1445 cknobs [COLAMD_DENSE_COLcxx . . $ `external/glpk/colamd.h:22:9`!] = knobs [COLAMD_DENSE_ROWcxx . . $ `external/glpk/colamd.h:21:9`!] ;
1446
1447 /* === Order the columns of M =========================================== */
1448
1449 /* v2.4: colamd cannot fail here, so the error check is removed */
1450 (void) COLAMD_MAINcxx . . $ `external/glpk/colamd.c:716:9`! (n_row, n, (Intcxx . . $ `external/glpk/colamd.c:710:9`!) Mlen, M, perm, cknobs, stats) ;
1451
1452 /* Note that the output permutation is now in perm */
1453
1454 /* === get the statistics for symamd from colamd ======================== */
1455
1456 /* a dense column in colamd means a dense row and col in symamd */
1457 stats [COLAMD_DENSE_ROWcxx . . $ `external/glpk/colamd.h:21:9`!] = stats [COLAMD_DENSE_COLcxx . . $ `external/glpk/colamd.h:22:9`!] ;
1458
1459 /* === Free M =========================================================== */
1460
1461 (*release) ((void *) M) ;
1462 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("symamd: done.\n")) ;
1463 return (TRUEcxx . . $ `external/glpk/colamd.c:801:9`!) ;
1464
1465 }
1466
1467 /* ========================================================================== */
1468 /* === colamd =============================================================== */
1469 /* ========================================================================== */
1470
1471 /*
1472 The colamd routine computes a column ordering Q of a sparse matrix
1473 A such that the LU factorization P(AQ) = LU remains sparse, where P is
1474 selected via partial pivoting. The routine can also be viewed as
1475 providing a permutation Q such that the Cholesky factorization
1476 (AQ)'(AQ) = LL' remains sparse.
1477 */
1478
1479 PUBLICcxx . . $ `external/glpk/colamd.c:785:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! COLAMD_MAINcxx . . $ `external/glpk/colamd.c:716:9`! /* returns TRUE if successful, FALSE otherwise*/
1480 (
1481 /* === Parameters ======================================================= */
1482
1483 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row, /* number of rows in A */
1484 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col, /* number of columns in A */
1485 Intcxx . . $ `external/glpk/colamd.c:710:9`! Alen, /* length of A */
1486 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [], /* row indices of A */
1487 Intcxx . . $ `external/glpk/colamd.c:710:9`! p [], /* pointers to columns in A */
1488 double knobs [COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`!],/* parameters (uses defaults if NULL) */
1489 Intcxx . . $ `external/glpk/colamd.c:710:9`! stats [COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`!] /* output statistics and error codes */
1490 )
1491 {
1492 /* === Local variables ================================================== */
1493
1494 Intcxx . . $ `external/glpk/colamd.c:710:9`! i ; /* loop index */
1495 Intcxx . . $ `external/glpk/colamd.c:710:9`! nnz ; /* nonzeros in A */
1496 size_t Row_size ; /* size of Row [], in integers */
1497 size_t Col_size ; /* size of Col [], in integers */
1498 size_t need ; /* minimum required length of A */
1499 Colamd_Rowcxx . . $ Colamd_Row# *Row ; /* pointer into A of Row [0..n_row] array */
1500 Colamd_Colcxx . . $ Colamd_Col# *Col ; /* pointer into A of Col [0..n_col] array */
1501 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col2 ; /* number of non-dense, non-empty columns */
1502 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row2 ; /* number of non-dense, non-empty rows */
1503 Intcxx . . $ `external/glpk/colamd.c:710:9`! ngarbage ; /* number of garbage collections performed */
1504 Intcxx . . $ `external/glpk/colamd.c:710:9`! max_deg ; /* maximum row degree */
1505 double default_knobs [COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`!] ; /* default knobs array */
1506 Intcxx . . $ `external/glpk/colamd.c:710:9`! aggressive ; /* do aggressive absorption */
1507 int ok ;
1508
1509 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
1510 colamd_get_debug ("colamd") ;
1511 #endif /* NDEBUG */
1512
1513 /* === Check the input arguments ======================================== */
1514
1515 if (!stats)
1516 {
1517 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: stats not present\n")) ;
1518 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1519 }
1520 for (i = 0 ; i < COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`! ; i++)
1521 {
1522 stats [i] = 0 ;
1523 }
1524 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_OKcxx . . $ `external/glpk/colamd.h:30:9`! ;
1525 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = -1 ;
1526 stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] = -1 ;
1527
1528 if (!A) /* A is not present */
1529 {
1530 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_A_not_presentcxx . . $ `external/glpk/colamd.h:32:9`! ;
1531 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: A not present\n")) ;
1532 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1533 }
1534
1535 if (!p) /* p is not present */
1536 {
1537 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_p_not_presentcxx . . $ `external/glpk/colamd.h:33:9`! ;
1538 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: p not present\n")) ;
1539 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1540 }
1541
1542 if (n_row < 0) /* n_row must be >= 0 */
1543 {
1544 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_nrow_negativecxx . . $ `external/glpk/colamd.h:34:9`! ;
1545 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = n_row ;
1546 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: nrow negative %d\n", n_row)) ;
1547 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1548 }
1549
1550 if (n_col < 0) /* n_col must be >= 0 */
1551 {
1552 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_ncol_negativecxx . . $ `external/glpk/colamd.h:35:9`! ;
1553 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = n_col ;
1554 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: ncol negative %d\n", n_col)) ;
1555 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1556 }
1557
1558 nnz = p [n_col] ;
1559 if (nnz < 0) /* nnz must be >= 0 */
1560 {
1561 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_nnz_negativecxx . . $ `external/glpk/colamd.h:36:9`! ;
1562 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = nnz ;
1563 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: number of entries negative %d\n", nnz)) ;
1564 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1565 }
1566
1567 if (p [0] != 0)
1568 {
1569 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_p0_nonzerocxx . . $ `external/glpk/colamd.h:37:9`! ;
1570 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = p [0] ;
1571 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: p[0] not zero %d\n", p [0])) ;
1572 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1573 }
1574
1575 /* === If no knobs, set default knobs =================================== */
1576
1577 if (!knobs)
1578 {
1579 COLAMD_set_defaultscxx . . $ `external/glpk/colamd.c:715:9`! (default_knobs) ;
1580 knobs = default_knobs ;
1581 }
1582
1583 aggressive = (knobs [COLAMD_AGGRESSIVEcxx . . $ `external/glpk/colamd.h:23:9`!] != FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1584
1585 /* === Allocate the Row and Col arrays from array A ===================== */
1586
1587 ok = TRUEcxx . . $ `external/glpk/colamd.c:801:9`! ;
1588 Col_size = COLAMD_Ccxx . . $ `external/glpk/colamd.c:1069:9`! (n_col, &ok) ; /* size of Col array of structs */
1589 Row_size = COLAMD_Rcxx . . $ `external/glpk/colamd.c:1072:9`! (n_row, &ok) ; /* size of Row array of structs */
1590
1591 /* need = 2*nnz + n_col + Col_size + Row_size ; */
1592 need = t_multcxx . . $ t_mult(650fbc31364c7391). (nnz, 2, &ok) ;
1593 need = t_addcxx . . $ t_add(650fbc31364c7391). (need, n_col, &ok) ;
1594 need = t_addcxx . . $ t_add(650fbc31364c7391). (need, Col_size, &ok) ;
1595 need = t_addcxx . . $ t_add(650fbc31364c7391). (need, Row_size, &ok) ;
1596
1597 if (!ok || need > (size_t) Alen || need > Int_MAXcxx . . $ `external/glpk/colamd.c:712:9`!)
1598 {
1599 /* not enough space in array A to perform the ordering */
1600 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_A_too_smallcxx . . $ `external/glpk/colamd.h:38:9`! ;
1601 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = need ;
1602 stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] = Alen ;
1603 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: Need Alen >= %d, given only Alen = %d\n", need,Alen));
1604 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1605 }
1606
1607 Alen -= Col_size + Row_size ;
1608 Col = (Colamd_Colcxx . . $ Colamd_Col# *) &A [Alen] ;
1609 Row = (Colamd_Rowcxx . . $ Colamd_Row# *) &A [Alen + Col_size] ;
1610
1611 /* === Construct the row and column data structures ===================== */
1612
1613 if (!init_rows_colscxx . . $ init_rows_cols(a85c37ca31396963). (n_row, n_col, Row, Col, A, p, stats))
1614 {
1615 /* input matrix is invalid */
1616 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: Matrix invalid\n")) ;
1617 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1618 }
1619
1620 /* === Initialize scores, kill dense rows/columns ======================= */
1621
1622 init_scoringcxx . . $ init_scoring(d1029ecdd7227091). (n_row, n_col, Row, Col, A, p, knobs,
1623 &n_row2, &n_col2, &max_deg) ;
1624
1625 /* === Order the supercolumns =========================================== */
1626
1627 ngarbage = find_orderingcxx . . $ find_ordering(7f397f83d5f3a4b2). (n_row, n_col, Alen, Row, Col, A, p,
1628 n_col2, max_deg, 2*nnz, aggressive) ;
1629
1630 /* === Order the non-principal columns ================================== */
1631
1632 order_childrencxx . . $ order_children(af26e60859f2017e). (n_col, Col, p) ;
1633
1634 /* === Return statistics in stats ======================================= */
1635
1636 stats [COLAMD_DENSE_ROWcxx . . $ `external/glpk/colamd.h:21:9`!] = n_row - n_row2 ;
1637 stats [COLAMD_DENSE_COLcxx . . $ `external/glpk/colamd.h:22:9`!] = n_col - n_col2 ;
1638 stats [COLAMD_DEFRAG_COUNTcxx . . $ `external/glpk/colamd.h:24:9`!] = ngarbage ;
1639 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: done.\n")) ;
1640 return (TRUEcxx . . $ `external/glpk/colamd.c:801:9`!) ;
1641 }
1642
1643
1644 /* ========================================================================== */
1645 /* === colamd_report ======================================================== */
1646 /* ========================================================================== */
1647
1648 PUBLICcxx . . $ `external/glpk/colamd.c:785:9`! void COLAMD_reportcxx . . $ `external/glpk/colamd.c:718:9`!
1649 (
1650 Intcxx . . $ `external/glpk/colamd.c:710:9`! stats [COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`!]
1651 )
1652 {
1653 print_reportcxx . . $ print_report(56561451ddc58846). ("colamd", stats) ;
1654 }
1655
1656
1657 /* ========================================================================== */
1658 /* === symamd_report ======================================================== */
1659 /* ========================================================================== */
1660
1661 PUBLICcxx . . $ `external/glpk/colamd.c:785:9`! void SYMAMD_reportcxx . . $ `external/glpk/colamd.c:719:9`!
1662 (
1663 Intcxx . . $ `external/glpk/colamd.c:710:9`! stats [COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`!]
1664 )
1665 {
1666 print_reportcxx . . $ print_report(56561451ddc58846). ("symamd", stats) ;
1667 }
1668
1669
1670
1671 /* ========================================================================== */
1672 /* === NON-USER-CALLABLE ROUTINES: ========================================== */
1673 /* ========================================================================== */
1674
1675 /* There are no user-callable routines beyond this point in the file */
1676
1677
1678 /* ========================================================================== */
1679 /* === init_rows_cols ======================================================= */
1680 /* ========================================================================== */
1681
1682 /*
1683 Takes the column form of the matrix in A and creates the row form of the
1684 matrix. Also, row and column attributes are stored in the Col and Row
1685 structs. If the columns are un-sorted or contain duplicate row indices,
1686 this routine will also sort and remove duplicate row indices from the
1687 column form of the matrix. Returns FALSE if the matrix is invalid,
1688 TRUE otherwise. Not user-callable.
1689 */
1690
1691 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! init_rows_colscxx . . $ init_rows_cols(a85c37ca31396963). /* returns TRUE if OK, or FALSE otherwise */
1692 (
1693 /* === Parameters ======================================================= */
1694
1695 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row, /* number of rows of A */
1696 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col, /* number of columns of A */
1697 Colamd_Rowcxx . . $ Colamd_Row# Row [], /* of size n_row+1 */
1698 Colamd_Colcxx . . $ Colamd_Col# Col [], /* of size n_col+1 */
1699 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [], /* row indices of A, of size Alen */
1700 Intcxx . . $ `external/glpk/colamd.c:710:9`! p [], /* pointers to columns in A, of size n_col+1 */
1701 Intcxx . . $ `external/glpk/colamd.c:710:9`! stats [COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`!] /* colamd statistics */
1702 )
1703 {
1704 /* === Local variables ================================================== */
1705
1706 Intcxx . . $ `external/glpk/colamd.c:710:9`! col ; /* a column index */
1707 Intcxx . . $ `external/glpk/colamd.c:710:9`! row ; /* a row index */
1708 Intcxx . . $ `external/glpk/colamd.c:710:9`! *cp ; /* a column pointer */
1709 Intcxx . . $ `external/glpk/colamd.c:710:9`! *cp_end ; /* a pointer to the end of a column */
1710 Intcxx . . $ `external/glpk/colamd.c:710:9`! *rp ; /* a row pointer */
1711 Intcxx . . $ `external/glpk/colamd.c:710:9`! *rp_end ; /* a pointer to the end of a row */
1712 Intcxx . . $ `external/glpk/colamd.c:710:9`! last_row ; /* previous row */
1713
1714 /* === Initialize columns, and check column pointers ==================== */
1715
1716 for (col = 0 ; col < n_col ; col++)
1717 {
1718 Col [col].startcxx . . $ Colamd_Col_struct#start. = p [col] ;
1719 Col [col].lengthcxx . . $ Colamd_Col_struct#length. = p [col+1] - p [col] ;
1720
1721 if (Col [col].lengthcxx . . $ Colamd_Col_struct#length. < 0)
1722 {
1723 /* column pointers must be non-decreasing */
1724 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_col_length_negativecxx . . $ `external/glpk/colamd.h:39:9`! ;
1725 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = col ;
1726 stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] = Col [col].lengthcxx . . $ Colamd_Col_struct#length. ;
1727 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: col %d length %d < 0\n", col, Col [col].length)) ;
1728 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1729 }
1730
1731 Col [col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. = 1 ;
1732 Col [col].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. = 0 ;
1733 Col [col].shared3cxx . . $ Colamd_Col_struct#shared3..prevcxx . . $ Colamd_Col_struct#$anonymous_type_2#prev. = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
1734 Col [col].shared4cxx . . $ Colamd_Col_struct#shared4..degree_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#degree_next. = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
1735 }
1736
1737 /* p [0..n_col] no longer needed, used as "head" in subsequent routines */
1738
1739 /* === Scan columns, compute row degrees, and check row indices ========= */
1740
1741 stats [COLAMD_INFO3cxx . . $ `external/glpk/colamd.h:28:9`!] = 0 ; /* number of duplicate or unsorted row indices*/
1742
1743 for (row = 0 ; row < n_row ; row++)
1744 {
1745 Row [row].lengthcxx . . $ Colamd_Row_struct#length. = 0 ;
1746 Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. = -1 ;
1747 }
1748
1749 for (col = 0 ; col < n_col ; col++)
1750 {
1751 last_row = -1 ;
1752
1753 cp = &A [p [col]] ;
1754 cp_end = &A [p [col+1]] ;
1755
1756 while (cp < cp_end)
1757 {
1758 row = *cp++ ;
1759
1760 /* make sure row indices within range */
1761 if (row < 0 || row >= n_row)
1762 {
1763 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_ERROR_row_index_out_of_boundscxx . . $ `external/glpk/colamd.h:40:9`! ;
1764 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = col ;
1765 stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] = row ;
1766 stats [COLAMD_INFO3cxx . . $ `external/glpk/colamd.h:28:9`!] = n_row ;
1767 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: row %d col %d out of bounds\n", row, col)) ;
1768 return (FALSEcxx . . $ `external/glpk/colamd.c:805:9`!) ;
1769 }
1770
1771 if (row <= last_row || Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. == col)
1772 {
1773 /* row index are unsorted or repeated (or both), thus col */
1774 /* is jumbled. This is a notice, not an error condition. */
1775 stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] = COLAMD_OK_BUT_JUMBLEDcxx . . $ `external/glpk/colamd.h:31:9`! ;
1776 stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] = col ;
1777 stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] = row ;
1778 (stats [COLAMD_INFO3cxx . . $ `external/glpk/colamd.h:28:9`!]) ++ ;
1779 DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`! (("colamd: row %d col %d unsorted/duplicate\n",row,col));
1780 }
1781
1782 if (Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. != col)
1783 {
1784 Row [row].lengthcxx . . $ Colamd_Row_struct#length.++ ;
1785 }
1786 else
1787 {
1788 /* this is a repeated entry in the column, */
1789 /* it will be removed */
1790 Col [col].lengthcxx . . $ Colamd_Col_struct#length.-- ;
1791 }
1792
1793 /* mark the row as having been seen in this column */
1794 Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. = col ;
1795
1796 last_row = row ;
1797 }
1798 }
1799
1800 /* === Compute row pointers ============================================= */
1801
1802 /* row form of the matrix starts directly after the column */
1803 /* form of matrix in A */
1804 Row [0].startcxx . . $ Colamd_Row_struct#start. = p [n_col] ;
1805 Row [0].shared1cxx . . $ Colamd_Row_struct#shared1..pcxx . . $ Colamd_Row_struct#$anonymous_type_4#p. = Row [0].startcxx . . $ Colamd_Row_struct#start. ;
1806 Row [0].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. = -1 ;
1807 for (row = 1 ; row < n_row ; row++)
1808 {
1809 Row [row].startcxx . . $ Colamd_Row_struct#start. = Row [row-1].startcxx . . $ Colamd_Row_struct#start. + Row [row-1].lengthcxx . . $ Colamd_Row_struct#length. ;
1810 Row [row].shared1cxx . . $ Colamd_Row_struct#shared1..pcxx . . $ Colamd_Row_struct#$anonymous_type_4#p. = Row [row].startcxx . . $ Colamd_Row_struct#start. ;
1811 Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. = -1 ;
1812 }
1813
1814 /* === Create row form ================================================== */
1815
1816 if (stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] == COLAMD_OK_BUT_JUMBLEDcxx . . $ `external/glpk/colamd.h:31:9`!)
1817 {
1818 /* if cols jumbled, watch for repeated row indices */
1819 for (col = 0 ; col < n_col ; col++)
1820 {
1821 cp = &A [p [col]] ;
1822 cp_end = &A [p [col+1]] ;
1823 while (cp < cp_end)
1824 {
1825 row = *cp++ ;
1826 if (Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. != col)
1827 {
1828 A [(Row [row].shared1cxx . . $ Colamd_Row_struct#shared1..pcxx . . $ Colamd_Row_struct#$anonymous_type_4#p.)++] = col ;
1829 Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. = col ;
1830 }
1831 }
1832 }
1833 }
1834 else
1835 {
1836 /* if cols not jumbled, we don't need the mark (this is faster) */
1837 for (col = 0 ; col < n_col ; col++)
1838 {
1839 cp = &A [p [col]] ;
1840 cp_end = &A [p [col+1]] ;
1841 while (cp < cp_end)
1842 {
1843 A [(Row [*cp++].shared1cxx . . $ Colamd_Row_struct#shared1..pcxx . . $ Colamd_Row_struct#$anonymous_type_4#p.)++] = col ;
1844 }
1845 }
1846 }
1847
1848 /* === Clear the row marks and set row degrees ========================== */
1849
1850 for (row = 0 ; row < n_row ; row++)
1851 {
1852 Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. = 0 ;
1853 Row [row].shared1cxx . . $ Colamd_Row_struct#shared1..degreecxx . . $ Colamd_Row_struct#$anonymous_type_4#degree. = Row [row].lengthcxx . . $ Colamd_Row_struct#length. ;
1854 }
1855
1856 /* === See if we need to re-create columns ============================== */
1857
1858 if (stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] == COLAMD_OK_BUT_JUMBLEDcxx . . $ `external/glpk/colamd.h:31:9`!)
1859 {
1860 DEBUG0cxx . . $ `external/glpk/colamd.c:1015:9`! (("colamd: reconstructing column form, matrix jumbled\n")) ;
1861
1862 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
1863 /* make sure column lengths are correct */
1864 for (col = 0 ; col < n_col ; col++)
1865 {
1866 p [col] = Col [col].length ;
1867 }
1868 for (row = 0 ; row < n_row ; row++)
1869 {
1870 rp = &A [Row [row].start] ;
1871 rp_end = rp + Row [row].length ;
1872 while (rp < rp_end)
1873 {
1874 p [*rp++]-- ;
1875 }
1876 }
1877 for (col = 0 ; col < n_col ; col++)
1878 {
1879 ASSERT (p [col] == 0) ;
1880 }
1881 /* now p is all zero (different than when debugging is turned off) */
1882 #endif /* NDEBUG */
1883
1884 /* === Compute col pointers ========================================= */
1885
1886 /* col form of the matrix starts at A [0]. */
1887 /* Note, we may have a gap between the col form and the row */
1888 /* form if there were duplicate entries, if so, it will be */
1889 /* removed upon the first garbage collection */
1890 Col [0].startcxx . . $ Colamd_Col_struct#start. = 0 ;
1891 p [0] = Col [0].startcxx . . $ Colamd_Col_struct#start. ;
1892 for (col = 1 ; col < n_col ; col++)
1893 {
1894 /* note that the lengths here are for pruned columns, i.e. */
1895 /* no duplicate row indices will exist for these columns */
1896 Col [col].startcxx . . $ Colamd_Col_struct#start. = Col [col-1].startcxx . . $ Colamd_Col_struct#start. + Col [col-1].lengthcxx . . $ Colamd_Col_struct#length. ;
1897 p [col] = Col [col].startcxx . . $ Colamd_Col_struct#start. ;
1898 }
1899
1900 /* === Re-create col form =========================================== */
1901
1902 for (row = 0 ; row < n_row ; row++)
1903 {
1904 rp = &A [Row [row].startcxx . . $ Colamd_Row_struct#start.] ;
1905 rp_end = rp + Row [row].lengthcxx . . $ Colamd_Row_struct#length. ;
1906 while (rp < rp_end)
1907 {
1908 A [(p [*rp++])++] = row ;
1909 }
1910 }
1911 }
1912
1913 /* === Done. Matrix is not (or no longer) jumbled ====================== */
1914
1915 return (TRUEcxx . . $ `external/glpk/colamd.c:801:9`!) ;
1916 }
1917
1918
1919 /* ========================================================================== */
1920 /* === init_scoring ========================================================= */
1921 /* ========================================================================== */
1922
1923 /*
1924 Kills dense or empty columns and rows, calculates an initial score for
1925 each column, and places all columns in the degree lists. Not user-callable.
1926 */
1927
1928 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! void init_scoringcxx . . $ init_scoring(d1029ecdd7227091).
1929 (
1930 /* === Parameters ======================================================= */
1931
1932 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row, /* number of rows of A */
1933 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col, /* number of columns of A */
1934 Colamd_Rowcxx . . $ Colamd_Row# Row [], /* of size n_row+1 */
1935 Colamd_Colcxx . . $ Colamd_Col# Col [], /* of size n_col+1 */
1936 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [], /* column form and row form of A */
1937 Intcxx . . $ `external/glpk/colamd.c:710:9`! head [], /* of size n_col+1 */
1938 double knobs [COLAMD_KNOBScxx . . $ `external/glpk/colamd.h:19:9`!],/* parameters */
1939 Intcxx . . $ `external/glpk/colamd.c:710:9`! *p_n_row2, /* number of non-dense, non-empty rows */
1940 Intcxx . . $ `external/glpk/colamd.c:710:9`! *p_n_col2, /* number of non-dense, non-empty columns */
1941 Intcxx . . $ `external/glpk/colamd.c:710:9`! *p_max_deg /* maximum row degree */
1942 )
1943 {
1944 /* === Local variables ================================================== */
1945
1946 Intcxx . . $ `external/glpk/colamd.c:710:9`! c ; /* a column index */
1947 Intcxx . . $ `external/glpk/colamd.c:710:9`! r, row ; /* a row index */
1948 Intcxx . . $ `external/glpk/colamd.c:710:9`! *cp ; /* a column pointer */
1949 Intcxx . . $ `external/glpk/colamd.c:710:9`! deg ; /* degree of a row or column */
1950 Intcxx . . $ `external/glpk/colamd.c:710:9`! *cp_end ; /* a pointer to the end of a column */
1951 Intcxx . . $ `external/glpk/colamd.c:710:9`! *new_cp ; /* new column pointer */
1952 Intcxx . . $ `external/glpk/colamd.c:710:9`! col_length ; /* length of pruned column */
1953 Intcxx . . $ `external/glpk/colamd.c:710:9`! score ; /* current column score */
1954 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col2 ; /* number of non-dense, non-empty columns */
1955 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row2 ; /* number of non-dense, non-empty rows */
1956 Intcxx . . $ `external/glpk/colamd.c:710:9`! dense_row_count ; /* remove rows with more entries than this */
1957 Intcxx . . $ `external/glpk/colamd.c:710:9`! dense_col_count ; /* remove cols with more entries than this */
1958 Intcxx . . $ `external/glpk/colamd.c:710:9`! min_score ; /* smallest column score */
1959 Intcxx . . $ `external/glpk/colamd.c:710:9`! max_deg ; /* maximum row degree */
1960 Intcxx . . $ `external/glpk/colamd.c:710:9`! next_col ; /* Used to add to degree list.*/
1961
1962 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
1963 Int debug_count ; /* debug only. */
1964 #endif /* NDEBUG */
1965
1966 /* === Extract knobs ==================================================== */
1967
1968 /* Note: if knobs contains a NaN, this is undefined: */
1969 if (knobs [COLAMD_DENSE_ROWcxx . . $ `external/glpk/colamd.h:21:9`!] < 0)
1970 {
1971 /* only remove completely dense rows */
1972 dense_row_count = n_col-1 ;
1973 }
1974 else
1975 {
1976 dense_row_count = DENSE_DEGREEcxx . . $ `external/glpk/colamd.c:788:9`! (knobs [COLAMD_DENSE_ROWcxx . . $ `external/glpk/colamd.h:21:9`!], n_col) ;
1977 }
1978 if (knobs [COLAMD_DENSE_COLcxx . . $ `external/glpk/colamd.h:22:9`!] < 0)
1979 {
1980 /* only remove completely dense columns */
1981 dense_col_count = n_row-1 ;
1982 }
1983 else
1984 {
1985 dense_col_count =
1986 DENSE_DEGREEcxx . . $ `external/glpk/colamd.c:788:9`! (knobs [COLAMD_DENSE_COLcxx . . $ `external/glpk/colamd.h:22:9`!], MINcxx . . $ `external/glpk/colamd.c:792:9`! (n_row, n_col)) ;
1987 }
1988
1989 DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`! (("colamd: densecount: %d %d\n", dense_row_count, dense_col_count)) ;
1990 max_deg = 0 ;
1991 n_col2 = n_col ;
1992 n_row2 = n_row ;
1993
1994 /* === Kill empty columns =============================================== */
1995
1996 /* Put the empty columns at the end in their natural order, so that LU */
1997 /* factorization can proceed as far as possible. */
1998 for (c = n_col-1 ; c >= 0 ; c--)
1999 {
2000 deg = Col [c].lengthcxx . . $ Colamd_Col_struct#length. ;
2001 if (deg == 0)
2002 {
2003 /* this is a empty column, kill and order it last */
2004 Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. = --n_col2 ;
2005 KILL_PRINCIPAL_COLcxx . . $ `external/glpk/colamd.c:828:9`! (c) ;
2006 }
2007 }
2008 DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`! (("colamd: null columns killed: %d\n", n_col - n_col2)) ;
2009
2010 /* === Kill dense columns =============================================== */
2011
2012 /* Put the dense columns at the end, in their natural order */
2013 for (c = n_col-1 ; c >= 0 ; c--)
2014 {
2015 /* skip any dead columns */
2016 if (COL_IS_DEADcxx . . $ `external/glpk/colamd.c:824:9`! (c))
2017 {
2018 continue ;
2019 }
2020 deg = Col [c].lengthcxx . . $ Colamd_Col_struct#length. ;
2021 if (deg > dense_col_count)
2022 {
2023 /* this is a dense column, kill and order it last */
2024 Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. = --n_col2 ;
2025 /* decrement the row degrees */
2026 cp = &A [Col [c].startcxx . . $ Colamd_Col_struct#start.] ;
2027 cp_end = cp + Col [c].lengthcxx . . $ Colamd_Col_struct#length. ;
2028 while (cp < cp_end)
2029 {
2030 Row [*cp++].shared1cxx . . $ Colamd_Row_struct#shared1..degreecxx . . $ Colamd_Row_struct#$anonymous_type_4#degree.-- ;
2031 }
2032 KILL_PRINCIPAL_COLcxx . . $ `external/glpk/colamd.c:828:9`! (c) ;
2033 }
2034 }
2035 DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`! (("colamd: Dense and null columns killed: %d\n", n_col - n_col2)) ;
2036
2037 /* === Kill dense and empty rows ======================================== */
2038
2039 for (r = 0 ; r < n_row ; r++)
2040 {
2041 deg = Row [r].shared1cxx . . $ Colamd_Row_struct#shared1..degreecxx . . $ Colamd_Row_struct#$anonymous_type_4#degree. ;
2042 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (deg >= 0 && deg <= n_col) ;
2043 if (deg > dense_row_count || deg == 0)
2044 {
2045 /* kill a dense or empty row */
2046 KILL_ROWcxx . . $ `external/glpk/colamd.c:827:9`! (r) ;
2047 --n_row2 ;
2048 }
2049 else
2050 {
2051 /* keep track of max degree of remaining rows */
2052 max_deg = MAXcxx . . $ `external/glpk/colamd.c:791:9`! (max_deg, deg) ;
2053 }
2054 }
2055 DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`! (("colamd: Dense and null rows killed: %d\n", n_row - n_row2)) ;
2056
2057 /* === Compute initial column scores ==================================== */
2058
2059 /* At this point the row degrees are accurate. They reflect the number */
2060 /* of "live" (non-dense) columns in each row. No empty rows exist. */
2061 /* Some "live" columns may contain only dead rows, however. These are */
2062 /* pruned in the code below. */
2063
2064 /* now find the initial matlab score for each column */
2065 for (c = n_col-1 ; c >= 0 ; c--)
2066 {
2067 /* skip dead column */
2068 if (COL_IS_DEADcxx . . $ `external/glpk/colamd.c:824:9`! (c))
2069 {
2070 continue ;
2071 }
2072 score = 0 ;
2073 cp = &A [Col [c].startcxx . . $ Colamd_Col_struct#start.] ;
2074 new_cp = cp ;
2075 cp_end = cp + Col [c].lengthcxx . . $ Colamd_Col_struct#length. ;
2076 while (cp < cp_end)
2077 {
2078 /* get a row */
2079 row = *cp++ ;
2080 /* skip if dead */
2081 if (ROW_IS_DEADcxx . . $ `external/glpk/colamd.c:821:9`! (row))
2082 {
2083 continue ;
2084 }
2085 /* compact the column */
2086 *new_cp++ = row ;
2087 /* add row's external degree */
2088 score += Row [row].shared1cxx . . $ Colamd_Row_struct#shared1..degreecxx . . $ Colamd_Row_struct#$anonymous_type_4#degree. - 1 ;
2089 /* guard against integer overflow */
2090 score = MINcxx . . $ `external/glpk/colamd.c:792:9`! (score, n_col) ;
2091 }
2092 /* determine pruned column length */
2093 col_length = (Intcxx . . $ `external/glpk/colamd.c:710:9`!) (new_cp - &A [Col [c].startcxx . . $ Colamd_Col_struct#start.]) ;
2094 if (col_length == 0)
2095 {
2096 /* a newly-made null column (all rows in this col are "dense" */
2097 /* and have already been killed) */
2098 DEBUG2cxx . . $ `external/glpk/colamd.c:1017:9`! (("Newly null killed: %d\n", c)) ;
2099 Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. = --n_col2 ;
2100 KILL_PRINCIPAL_COLcxx . . $ `external/glpk/colamd.c:828:9`! (c) ;
2101 }
2102 else
2103 {
2104 /* set column length and set score */
2105 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (score >= 0) ;
2106 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (score <= n_col) ;
2107 Col [c].lengthcxx . . $ Colamd_Col_struct#length. = col_length ;
2108 Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. = score ;
2109 }
2110 }
2111 DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`! (("colamd: Dense, null, and newly-null columns killed: %d\n",
2112 n_col-n_col2)) ;
2113
2114 /* At this point, all empty rows and columns are dead. All live columns */
2115 /* are "clean" (containing no dead rows) and simplicial (no supercolumns */
2116 /* yet). Rows may contain dead columns, but all live rows contain at */
2117 /* least one live column. */
2118
2119 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2120 debug_structures (n_row, n_col, Row, Col, A, n_col2) ;
2121 #endif /* NDEBUG */
2122
2123 /* === Initialize degree lists ========================================== */
2124
2125 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2126 debug_count = 0 ;
2127 #endif /* NDEBUG */
2128
2129 /* clear the hash buckets */
2130 for (c = 0 ; c <= n_col ; c++)
2131 {
2132 head [c] = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
2133 }
2134 min_score = n_col ;
2135 /* place in reverse order, so low column indices are at the front */
2136 /* of the lists. This is to encourage natural tie-breaking */
2137 for (c = n_col-1 ; c >= 0 ; c--)
2138 {
2139 /* only add principal columns to degree lists */
2140 if (COL_IS_ALIVEcxx . . $ `external/glpk/colamd.c:825:9`! (c))
2141 {
2142 DEBUG4cxx . . $ `external/glpk/colamd.c:1019:9`! (("place %d score %d minscore %d ncol %d\n",
2143 c, Col [c].shared2.score, min_score, n_col)) ;
2144
2145 /* === Add columns score to DList =============================== */
2146
2147 score = Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. ;
2148
2149 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (min_score >= 0) ;
2150 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (min_score <= n_col) ;
2151 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (score >= 0) ;
2152 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (score <= n_col) ;
2153 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (head [score] >= EMPTY) ;
2154
2155 /* now add this column to dList at proper score location */
2156 next_col = head [score] ;
2157 Col [c].shared3cxx . . $ Colamd_Col_struct#shared3..prevcxx . . $ Colamd_Col_struct#$anonymous_type_2#prev. = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
2158 Col [c].shared4cxx . . $ Colamd_Col_struct#shared4..degree_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#degree_next. = next_col ;
2159
2160 /* if there already was a column with the same score, set its */
2161 /* previous pointer to this new column */
2162 if (next_col != EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!)
2163 {
2164 Col [next_col].shared3cxx . . $ Colamd_Col_struct#shared3..prevcxx . . $ Colamd_Col_struct#$anonymous_type_2#prev. = c ;
2165 }
2166 head [score] = c ;
2167
2168 /* see if this score is less than current min */
2169 min_score = MINcxx . . $ `external/glpk/colamd.c:792:9`! (min_score, score) ;
2170
2171 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2172 debug_count++ ;
2173 #endif /* NDEBUG */
2174
2175 }
2176 }
2177
2178 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2179 DEBUG1 (("colamd: Live cols %d out of %d, non-princ: %d\n",
2180 debug_count, n_col, n_col-debug_count)) ;
2181 ASSERT (debug_count == n_col2) ;
2182 debug_deg_lists (n_row, n_col, Row, Col, head, min_score, n_col2, max_deg) ;
2183 #endif /* NDEBUG */
2184
2185 /* === Return number of remaining columns, and max row degree =========== */
2186
2187 *p_n_col2 = n_col2 ;
2188 *p_n_row2 = n_row2 ;
2189 *p_max_deg = max_deg ;
2190 }
2191
2192
2193 /* ========================================================================== */
2194 /* === find_ordering ======================================================== */
2195 /* ========================================================================== */
2196
2197 /*
2198 Order the principal columns of the supercolumn form of the matrix
2199 (no supercolumns on input). Uses a minimum approximate column minimum
2200 degree ordering method. Not user-callable.
2201 */
2202
2203 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! find_orderingcxx . . $ find_ordering(7f397f83d5f3a4b2). /* return the number of garbage collections */
2204 (
2205 /* === Parameters ======================================================= */
2206
2207 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row, /* number of rows of A */
2208 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col, /* number of columns of A */
2209 Intcxx . . $ `external/glpk/colamd.c:710:9`! Alen, /* size of A, 2*nnz + n_col or larger */
2210 Colamd_Rowcxx . . $ Colamd_Row# Row [], /* of size n_row+1 */
2211 Colamd_Colcxx . . $ Colamd_Col# Col [], /* of size n_col+1 */
2212 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [], /* column form and row form of A */
2213 Intcxx . . $ `external/glpk/colamd.c:710:9`! head [], /* of size n_col+1 */
2214 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col2, /* Remaining columns to order */
2215 Intcxx . . $ `external/glpk/colamd.c:710:9`! max_deg, /* Maximum row degree */
2216 Intcxx . . $ `external/glpk/colamd.c:710:9`! pfree, /* index of first free slot (2*nnz on entry) */
2217 Intcxx . . $ `external/glpk/colamd.c:710:9`! aggressive
2218 )
2219 {
2220 /* === Local variables ================================================== */
2221
2222 Intcxx . . $ `external/glpk/colamd.c:710:9`! k ; /* current pivot ordering step */
2223 Intcxx . . $ `external/glpk/colamd.c:710:9`! pivot_col ; /* current pivot column */
2224 Intcxx . . $ `external/glpk/colamd.c:710:9`! *cp ; /* a column pointer */
2225 Intcxx . . $ `external/glpk/colamd.c:710:9`! *rp ; /* a row pointer */
2226 Intcxx . . $ `external/glpk/colamd.c:710:9`! pivot_row ; /* current pivot row */
2227 Intcxx . . $ `external/glpk/colamd.c:710:9`! *new_cp ; /* modified column pointer */
2228 Intcxx . . $ `external/glpk/colamd.c:710:9`! *new_rp ; /* modified row pointer */
2229 Intcxx . . $ `external/glpk/colamd.c:710:9`! pivot_row_start ; /* pointer to start of pivot row */
2230 Intcxx . . $ `external/glpk/colamd.c:710:9`! pivot_row_degree ; /* number of columns in pivot row */
2231 Intcxx . . $ `external/glpk/colamd.c:710:9`! pivot_row_length ; /* number of supercolumns in pivot row */
2232 Intcxx . . $ `external/glpk/colamd.c:710:9`! pivot_col_score ; /* score of pivot column */
2233 Intcxx . . $ `external/glpk/colamd.c:710:9`! needed_memory ; /* free space needed for pivot row */
2234 Intcxx . . $ `external/glpk/colamd.c:710:9`! *cp_end ; /* pointer to the end of a column */
2235 Intcxx . . $ `external/glpk/colamd.c:710:9`! *rp_end ; /* pointer to the end of a row */
2236 Intcxx . . $ `external/glpk/colamd.c:710:9`! row ; /* a row index */
2237 Intcxx . . $ `external/glpk/colamd.c:710:9`! col ; /* a column index */
2238 Intcxx . . $ `external/glpk/colamd.c:710:9`! max_score ; /* maximum possible score */
2239 Intcxx . . $ `external/glpk/colamd.c:710:9`! cur_score ; /* score of current column */
2240 unsigned Intcxx . . $ `external/glpk/colamd.c:710:9`! hash ; /* hash value for supernode detection */
2241 Intcxx . . $ `external/glpk/colamd.c:710:9`! head_column ; /* head of hash bucket */
2242 Intcxx . . $ `external/glpk/colamd.c:710:9`! first_col ; /* first column in hash bucket */
2243 Intcxx . . $ `external/glpk/colamd.c:710:9`! tag_mark ; /* marker value for mark array */
2244 Intcxx . . $ `external/glpk/colamd.c:710:9`! row_mark ; /* Row [row].shared2.mark */
2245 Intcxx . . $ `external/glpk/colamd.c:710:9`! set_difference ; /* set difference size of row with pivot row */
2246 Intcxx . . $ `external/glpk/colamd.c:710:9`! min_score ; /* smallest column score */
2247 Intcxx . . $ `external/glpk/colamd.c:710:9`! col_thickness ; /* "thickness" (no. of columns in a supercol) */
2248 Intcxx . . $ `external/glpk/colamd.c:710:9`! max_mark ; /* maximum value of tag_mark */
2249 Intcxx . . $ `external/glpk/colamd.c:710:9`! pivot_col_thickness ; /* number of columns represented by pivot col */
2250 Intcxx . . $ `external/glpk/colamd.c:710:9`! prev_col ; /* Used by Dlist operations. */
2251 Intcxx . . $ `external/glpk/colamd.c:710:9`! next_col ; /* Used by Dlist operations. */
2252 Intcxx . . $ `external/glpk/colamd.c:710:9`! ngarbage ; /* number of garbage collections performed */
2253
2254 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2255 Int debug_d ; /* debug loop counter */
2256 Int debug_step = 0 ; /* debug loop counter */
2257 #endif /* NDEBUG */
2258
2259 /* === Initialization and clear mark ==================================== */
2260
2261 max_mark = INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`! - n_col ; /* INT_MAX defined in <limits.h> */
2262 tag_mark = clear_markcxx . . $ clear_mark(a64fdf7fc08061e1). (0, max_mark, n_row, Row) ;
2263 min_score = 0 ;
2264 ngarbage = 0 ;
2265 DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`! (("colamd: Ordering, n_col2=%d\n", n_col2)) ;
2266
2267 /* === Order the columns ================================================ */
2268
2269 for (k = 0 ; k < n_col2 ; /* 'k' is incremented below */)
2270 {
2271
2272 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2273 if (debug_step % 100 == 0)
2274 {
2275 DEBUG2 (("\n... Step k: %d out of n_col2: %d\n", k, n_col2)) ;
2276 }
2277 else
2278 {
2279 DEBUG3 (("\n----------Step k: %d out of n_col2: %d\n", k, n_col2)) ;
2280 }
2281 debug_step++ ;
2282 debug_deg_lists (n_row, n_col, Row, Col, head,
2283 min_score, n_col2-k, max_deg) ;
2284 debug_matrix (n_row, n_col, Row, Col, A) ;
2285 #endif /* NDEBUG */
2286
2287 /* === Select pivot column, and order it ============================ */
2288
2289 /* make sure degree list isn't empty */
2290 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (min_score >= 0) ;
2291 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (min_score <= n_col) ;
2292 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (head [min_score] >= EMPTY) ;
2293
2294 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2295 for (debug_d = 0 ; debug_d < min_score ; debug_d++)
2296 {
2297 ASSERT (head [debug_d] == EMPTY) ;
2298 }
2299 #endif /* NDEBUG */
2300
2301 /* get pivot column from head of minimum degree list */
2302 while (head [min_score] == EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! && min_score < n_col)
2303 {
2304 min_score++ ;
2305 }
2306 pivot_col = head [min_score] ;
2307 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (pivot_col >= 0 && pivot_col <= n_col) ;
2308 next_col = Col [pivot_col].shared4cxx . . $ Colamd_Col_struct#shared4..degree_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#degree_next. ;
2309 head [min_score] = next_col ;
2310 if (next_col != EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!)
2311 {
2312 Col [next_col].shared3cxx . . $ Colamd_Col_struct#shared3..prevcxx . . $ Colamd_Col_struct#$anonymous_type_2#prev. = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
2313 }
2314
2315 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (COL_IS_ALIVE (pivot_col)) ;
2316
2317 /* remember score for defrag check */
2318 pivot_col_score = Col [pivot_col].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. ;
2319
2320 /* the pivot column is the kth column in the pivot order */
2321 Col [pivot_col].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. = k ;
2322
2323 /* increment order count by column thickness */
2324 pivot_col_thickness = Col [pivot_col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. ;
2325 k += pivot_col_thickness ;
2326 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (pivot_col_thickness > 0) ;
2327 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("Pivot col: %d thick %d\n", pivot_col, pivot_col_thickness)) ;
2328
2329 /* === Garbage_collection, if necessary ============================= */
2330
2331 needed_memory = MINcxx . . $ `external/glpk/colamd.c:792:9`! (pivot_col_score, n_col - k) ;
2332 if (pfree + needed_memory >= Alen)
2333 {
2334 pfree = garbage_collectioncxx . . $ garbage_collection(59e400dca74828d0). (n_row, n_col, Row, Col, A, &A [pfree]) ;
2335 ngarbage++ ;
2336 /* after garbage collection we will have enough */
2337 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (pfree + needed_memory < Alen) ;
2338 /* garbage collection has wiped out the Row[].shared2.mark array */
2339 tag_mark = clear_markcxx . . $ clear_mark(a64fdf7fc08061e1). (0, max_mark, n_row, Row) ;
2340
2341 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2342 debug_matrix (n_row, n_col, Row, Col, A) ;
2343 #endif /* NDEBUG */
2344 }
2345
2346 /* === Compute pivot row pattern ==================================== */
2347
2348 /* get starting location for this new merged row */
2349 pivot_row_start = pfree ;
2350
2351 /* initialize new row counts to zero */
2352 pivot_row_degree = 0 ;
2353
2354 /* tag pivot column as having been visited so it isn't included */
2355 /* in merged pivot row */
2356 Col [pivot_col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. = -pivot_col_thickness ;
2357
2358 /* pivot row is the union of all rows in the pivot column pattern */
2359 cp = &A [Col [pivot_col].startcxx . . $ Colamd_Col_struct#start.] ;
2360 cp_end = cp + Col [pivot_col].lengthcxx . . $ Colamd_Col_struct#length. ;
2361 while (cp < cp_end)
2362 {
2363 /* get a row */
2364 row = *cp++ ;
2365 DEBUG4cxx . . $ `external/glpk/colamd.c:1019:9`! (("Pivot col pattern %d %d\n", ROW_IS_ALIVE (row), row)) ;
2366 /* skip if row is dead */
2367 if (ROW_IS_ALIVEcxx . . $ `external/glpk/colamd.c:823:9`! (row))
2368 {
2369 rp = &A [Row [row].startcxx . . $ Colamd_Row_struct#start.] ;
2370 rp_end = rp + Row [row].lengthcxx . . $ Colamd_Row_struct#length. ;
2371 while (rp < rp_end)
2372 {
2373 /* get a column */
2374 col = *rp++ ;
2375 /* add the column, if alive and untagged */
2376 col_thickness = Col [col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. ;
2377 if (col_thickness > 0 && COL_IS_ALIVEcxx . . $ `external/glpk/colamd.c:825:9`! (col))
2378 {
2379 /* tag column in pivot row */
2380 Col [col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. = -col_thickness ;
2381 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (pfree < Alen) ;
2382 /* place column in pivot row */
2383 A [pfree++] = col ;
2384 pivot_row_degree += col_thickness ;
2385 }
2386 }
2387 }
2388 }
2389
2390 /* clear tag on pivot column */
2391 Col [pivot_col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. = pivot_col_thickness ;
2392 max_deg = MAXcxx . . $ `external/glpk/colamd.c:791:9`! (max_deg, pivot_row_degree) ;
2393
2394 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2395 DEBUG3 (("check2\n")) ;
2396 debug_mark (n_row, Row, tag_mark, max_mark) ;
2397 #endif /* NDEBUG */
2398
2399 /* === Kill all rows used to construct pivot row ==================== */
2400
2401 /* also kill pivot row, temporarily */
2402 cp = &A [Col [pivot_col].startcxx . . $ Colamd_Col_struct#start.] ;
2403 cp_end = cp + Col [pivot_col].lengthcxx . . $ Colamd_Col_struct#length. ;
2404 while (cp < cp_end)
2405 {
2406 /* may be killing an already dead row */
2407 row = *cp++ ;
2408 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("Kill row in pivot col: %d\n", row)) ;
2409 KILL_ROWcxx . . $ `external/glpk/colamd.c:827:9`! (row) ;
2410 }
2411
2412 /* === Select a row index to use as the new pivot row =============== */
2413
2414 pivot_row_length = pfree - pivot_row_start ;
2415 if (pivot_row_length > 0)
2416 {
2417 /* pick the "pivot" row arbitrarily (first row in col) */
2418 pivot_row = A [Col [pivot_col].startcxx . . $ Colamd_Col_struct#start.] ;
2419 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("Pivotal row is %d\n", pivot_row)) ;
2420 }
2421 else
2422 {
2423 /* there is no pivot row, since it is of zero length */
2424 pivot_row = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
2425 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (pivot_row_length == 0) ;
2426 }
2427 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (Col [pivot_col].length > 0 || pivot_row_length == 0) ;
2428
2429 /* === Approximate degree computation =============================== */
2430
2431 /* Here begins the computation of the approximate degree. The column */
2432 /* score is the sum of the pivot row "length", plus the size of the */
2433 /* set differences of each row in the column minus the pattern of the */
2434 /* pivot row itself. The column ("thickness") itself is also */
2435 /* excluded from the column score (we thus use an approximate */
2436 /* external degree). */
2437
2438 /* The time taken by the following code (compute set differences, and */
2439 /* add them up) is proportional to the size of the data structure */
2440 /* being scanned - that is, the sum of the sizes of each column in */
2441 /* the pivot row. Thus, the amortized time to compute a column score */
2442 /* is proportional to the size of that column (where size, in this */
2443 /* context, is the column "length", or the number of row indices */
2444 /* in that column). The number of row indices in a column is */
2445 /* monotonically non-decreasing, from the length of the original */
2446 /* column on input to colamd. */
2447
2448 /* === Compute set differences ====================================== */
2449
2450 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("** Computing set differences phase. **\n")) ;
2451
2452 /* pivot row is currently dead - it will be revived later. */
2453
2454 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("Pivot row: ")) ;
2455 /* for each column in pivot row */
2456 rp = &A [pivot_row_start] ;
2457 rp_end = rp + pivot_row_length ;
2458 while (rp < rp_end)
2459 {
2460 col = *rp++ ;
2461 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (COL_IS_ALIVE (col) && col != pivot_col) ;
2462 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("Col: %d\n", col)) ;
2463
2464 /* clear tags used to construct pivot row pattern */
2465 col_thickness = -Col [col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. ;
2466 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (col_thickness > 0) ;
2467 Col [col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. = col_thickness ;
2468
2469 /* === Remove column from degree list =========================== */
2470
2471 cur_score = Col [col].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. ;
2472 prev_col = Col [col].shared3cxx . . $ Colamd_Col_struct#shared3..prevcxx . . $ Colamd_Col_struct#$anonymous_type_2#prev. ;
2473 next_col = Col [col].shared4cxx . . $ Colamd_Col_struct#shared4..degree_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#degree_next. ;
2474 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (cur_score >= 0) ;
2475 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (cur_score <= n_col) ;
2476 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (cur_score >= EMPTY) ;
2477 if (prev_col == EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!)
2478 {
2479 head [cur_score] = next_col ;
2480 }
2481 else
2482 {
2483 Col [prev_col].shared4cxx . . $ Colamd_Col_struct#shared4..degree_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#degree_next. = next_col ;
2484 }
2485 if (next_col != EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!)
2486 {
2487 Col [next_col].shared3cxx . . $ Colamd_Col_struct#shared3..prevcxx . . $ Colamd_Col_struct#$anonymous_type_2#prev. = prev_col ;
2488 }
2489
2490 /* === Scan the column ========================================== */
2491
2492 cp = &A [Col [col].startcxx . . $ Colamd_Col_struct#start.] ;
2493 cp_end = cp + Col [col].lengthcxx . . $ Colamd_Col_struct#length. ;
2494 while (cp < cp_end)
2495 {
2496 /* get a row */
2497 row = *cp++ ;
2498 row_mark = Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. ;
2499 /* skip if dead */
2500 if (ROW_IS_MARKED_DEADcxx . . $ `external/glpk/colamd.c:822:9`! (row_mark))
2501 {
2502 continue ;
2503 }
2504 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (row != pivot_row) ;
2505 set_difference = row_mark - tag_mark ;
2506 /* check if the row has been seen yet */
2507 if (set_difference < 0)
2508 {
2509 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (Row [row].shared1.degree <= max_deg) ;
2510 set_difference = Row [row].shared1cxx . . $ Colamd_Row_struct#shared1..degreecxx . . $ Colamd_Row_struct#$anonymous_type_4#degree. ;
2511 }
2512 /* subtract column thickness from this row's set difference */
2513 set_difference -= col_thickness ;
2514 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (set_difference >= 0) ;
2515 /* absorb this row if the set difference becomes zero */
2516 if (set_difference == 0 && aggressive)
2517 {
2518 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("aggressive absorption. Row: %d\n", row)) ;
2519 KILL_ROWcxx . . $ `external/glpk/colamd.c:827:9`! (row) ;
2520 }
2521 else
2522 {
2523 /* save the new mark */
2524 Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. = set_difference + tag_mark ;
2525 }
2526 }
2527 }
2528
2529 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2530 debug_deg_lists (n_row, n_col, Row, Col, head,
2531 min_score, n_col2-k-pivot_row_degree, max_deg) ;
2532 #endif /* NDEBUG */
2533
2534 /* === Add up set differences for each column ======================= */
2535
2536 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("** Adding set differences phase. **\n")) ;
2537
2538 /* for each column in pivot row */
2539 rp = &A [pivot_row_start] ;
2540 rp_end = rp + pivot_row_length ;
2541 while (rp < rp_end)
2542 {
2543 /* get a column */
2544 col = *rp++ ;
2545 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (COL_IS_ALIVE (col) && col != pivot_col) ;
2546 hash = 0 ;
2547 cur_score = 0 ;
2548 cp = &A [Col [col].startcxx . . $ Colamd_Col_struct#start.] ;
2549 /* compact the column */
2550 new_cp = cp ;
2551 cp_end = cp + Col [col].lengthcxx . . $ Colamd_Col_struct#length. ;
2552
2553 DEBUG4cxx . . $ `external/glpk/colamd.c:1019:9`! (("Adding set diffs for Col: %d.\n", col)) ;
2554
2555 while (cp < cp_end)
2556 {
2557 /* get a row */
2558 row = *cp++ ;
2559 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`!(row >= 0 && row < n_row) ;
2560 row_mark = Row [row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. ;
2561 /* skip if dead */
2562 if (ROW_IS_MARKED_DEADcxx . . $ `external/glpk/colamd.c:822:9`! (row_mark))
2563 {
2564 DEBUG4cxx . . $ `external/glpk/colamd.c:1019:9`! ((" Row %d, dead\n", row)) ;
2565 continue ;
2566 }
2567 DEBUG4cxx . . $ `external/glpk/colamd.c:1019:9`! ((" Row %d, set diff %d\n", row, row_mark-tag_mark));
2568 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (row_mark >= tag_mark) ;
2569 /* compact the column */
2570 *new_cp++ = row ;
2571 /* compute hash function */
2572 hash += row ;
2573 /* add set difference */
2574 cur_score += row_mark - tag_mark ;
2575 /* integer overflow... */
2576 cur_score = MINcxx . . $ `external/glpk/colamd.c:792:9`! (cur_score, n_col) ;
2577 }
2578
2579 /* recompute the column's length */
2580 Col [col].lengthcxx . . $ Colamd_Col_struct#length. = (Intcxx . . $ `external/glpk/colamd.c:710:9`!) (new_cp - &A [Col [col].startcxx . . $ Colamd_Col_struct#start.]) ;
2581
2582 /* === Further mass elimination ================================= */
2583
2584 if (Col [col].lengthcxx . . $ Colamd_Col_struct#length. == 0)
2585 {
2586 DEBUG4cxx . . $ `external/glpk/colamd.c:1019:9`! (("further mass elimination. Col: %d\n", col)) ;
2587 /* nothing left but the pivot row in this column */
2588 KILL_PRINCIPAL_COLcxx . . $ `external/glpk/colamd.c:828:9`! (col) ;
2589 pivot_row_degree -= Col [col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. ;
2590 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (pivot_row_degree >= 0) ;
2591 /* order it */
2592 Col [col].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. = k ;
2593 /* increment order count by column thickness */
2594 k += Col [col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. ;
2595 }
2596 else
2597 {
2598 /* === Prepare for supercolumn detection ==================== */
2599
2600 DEBUG4cxx . . $ `external/glpk/colamd.c:1019:9`! (("Preparing supercol detection for Col: %d.\n", col)) ;
2601
2602 /* save score so far */
2603 Col [col].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. = cur_score ;
2604
2605 /* add column to hash table, for supercolumn detection */
2606 hash %= n_col + 1 ;
2607
2608 DEBUG4cxx . . $ `external/glpk/colamd.c:1019:9`! ((" Hash = %d, n_col = %d.\n", hash, n_col)) ;
2609 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (((Int) hash) <= n_col) ;
2610
2611 head_column = head [hash] ;
2612 if (head_column > EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!)
2613 {
2614 /* degree list "hash" is non-empty, use prev (shared3) of */
2615 /* first column in degree list as head of hash bucket */
2616 first_col = Col [head_column].shared3cxx . . $ Colamd_Col_struct#shared3..headhashcxx . . $ Colamd_Col_struct#$anonymous_type_2#headhash. ;
2617 Col [head_column].shared3cxx . . $ Colamd_Col_struct#shared3..headhashcxx . . $ Colamd_Col_struct#$anonymous_type_2#headhash. = col ;
2618 }
2619 else
2620 {
2621 /* degree list "hash" is empty, use head as hash bucket */
2622 first_col = - (head_column + 2) ;
2623 head [hash] = - (col + 2) ;
2624 }
2625 Col [col].shared4cxx . . $ Colamd_Col_struct#shared4..hash_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#hash_next. = first_col ;
2626
2627 /* save hash function in Col [col].shared3.hash */
2628 Col [col].shared3cxx . . $ Colamd_Col_struct#shared3..hashcxx . . $ Colamd_Col_struct#$anonymous_type_2#hash. = (Intcxx . . $ `external/glpk/colamd.c:710:9`!) hash ;
2629 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (COL_IS_ALIVE (col)) ;
2630 }
2631 }
2632
2633 /* The approximate external column degree is now computed. */
2634
2635 /* === Supercolumn detection ======================================== */
2636
2637 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("** Supercolumn detection phase. **\n")) ;
2638
2639 detect_super_colscxx . . $ detect_super_cols(e427314c50360653). (
2640
2641 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2642 n_col, Row,
2643 #endif /* NDEBUG */
2644
2645 Col, A, head, pivot_row_start, pivot_row_length) ;
2646
2647 /* === Kill the pivotal column ====================================== */
2648
2649 KILL_PRINCIPAL_COLcxx . . $ `external/glpk/colamd.c:828:9`! (pivot_col) ;
2650
2651 /* === Clear mark =================================================== */
2652
2653 tag_mark = clear_markcxx . . $ clear_mark(a64fdf7fc08061e1). (tag_mark+max_deg+1, max_mark, n_row, Row) ;
2654
2655 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2656 DEBUG3 (("check3\n")) ;
2657 debug_mark (n_row, Row, tag_mark, max_mark) ;
2658 #endif /* NDEBUG */
2659
2660 /* === Finalize the new pivot row, and column scores ================ */
2661
2662 DEBUG3cxx . . $ `external/glpk/colamd.c:1018:9`! (("** Finalize scores phase. **\n")) ;
2663
2664 /* for each column in pivot row */
2665 rp = &A [pivot_row_start] ;
2666 /* compact the pivot row */
2667 new_rp = rp ;
2668 rp_end = rp + pivot_row_length ;
2669 while (rp < rp_end)
2670 {
2671 col = *rp++ ;
2672 /* skip dead columns */
2673 if (COL_IS_DEADcxx . . $ `external/glpk/colamd.c:824:9`! (col))
2674 {
2675 continue ;
2676 }
2677 *new_rp++ = col ;
2678 /* add new pivot row to column */
2679 A [Col [col].startcxx . . $ Colamd_Col_struct#start. + (Col [col].lengthcxx . . $ Colamd_Col_struct#length.++)] = pivot_row ;
2680
2681 /* retrieve score so far and add on pivot row's degree. */
2682 /* (we wait until here for this in case the pivot */
2683 /* row's degree was reduced due to mass elimination). */
2684 cur_score = Col [col].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. + pivot_row_degree ;
2685
2686 /* calculate the max possible score as the number of */
2687 /* external columns minus the 'k' value minus the */
2688 /* columns thickness */
2689 max_score = n_col - k - Col [col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. ;
2690
2691 /* make the score the external degree of the union-of-rows */
2692 cur_score -= Col [col].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. ;
2693
2694 /* make sure score is less or equal than the max score */
2695 cur_score = MINcxx . . $ `external/glpk/colamd.c:792:9`! (cur_score, max_score) ;
2696 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (cur_score >= 0) ;
2697
2698 /* store updated score */
2699 Col [col].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. = cur_score ;
2700
2701 /* === Place column back in degree list ========================= */
2702
2703 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (min_score >= 0) ;
2704 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (min_score <= n_col) ;
2705 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (cur_score >= 0) ;
2706 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (cur_score <= n_col) ;
2707 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (head [cur_score] >= EMPTY) ;
2708 next_col = head [cur_score] ;
2709 Col [col].shared4cxx . . $ Colamd_Col_struct#shared4..degree_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#degree_next. = next_col ;
2710 Col [col].shared3cxx . . $ Colamd_Col_struct#shared3..prevcxx . . $ Colamd_Col_struct#$anonymous_type_2#prev. = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
2711 if (next_col != EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!)
2712 {
2713 Col [next_col].shared3cxx . . $ Colamd_Col_struct#shared3..prevcxx . . $ Colamd_Col_struct#$anonymous_type_2#prev. = col ;
2714 }
2715 head [cur_score] = col ;
2716
2717 /* see if this score is less than current min */
2718 min_score = MINcxx . . $ `external/glpk/colamd.c:792:9`! (min_score, cur_score) ;
2719
2720 }
2721
2722 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2723 debug_deg_lists (n_row, n_col, Row, Col, head,
2724 min_score, n_col2-k, max_deg) ;
2725 #endif /* NDEBUG */
2726
2727 /* === Resurrect the new pivot row ================================== */
2728
2729 if (pivot_row_degree > 0)
2730 {
2731 /* update pivot row length to reflect any cols that were killed */
2732 /* during super-col detection and mass elimination */
2733 Row [pivot_row].startcxx . . $ Colamd_Row_struct#start. = pivot_row_start ;
2734 Row [pivot_row].lengthcxx . . $ Colamd_Row_struct#length. = (Intcxx . . $ `external/glpk/colamd.c:710:9`!) (new_rp - &A[pivot_row_start]) ;
2735 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (Row [pivot_row].length > 0) ;
2736 Row [pivot_row].shared1cxx . . $ Colamd_Row_struct#shared1..degreecxx . . $ Colamd_Row_struct#$anonymous_type_4#degree. = pivot_row_degree ;
2737 Row [pivot_row].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. = 0 ;
2738 /* pivot row is no longer dead */
2739
2740 DEBUG1cxx . . $ `external/glpk/colamd.c:1016:9`! (("Resurrect Pivot_row %d deg: %d\n",
2741 pivot_row, pivot_row_degree)) ;
2742 }
2743 }
2744
2745 /* === All principal columns have now been ordered ====================== */
2746
2747 return (ngarbage) ;
2748 }
2749
2750
2751 /* ========================================================================== */
2752 /* === order_children ======================================================= */
2753 /* ========================================================================== */
2754
2755 /*
2756 The find_ordering routine has ordered all of the principal columns (the
2757 representatives of the supercolumns). The non-principal columns have not
2758 yet been ordered. This routine orders those columns by walking up the
2759 parent tree (a column is a child of the column which absorbed it). The
2760 final permutation vector is then placed in p [0 ... n_col-1], with p [0]
2761 being the first column, and p [n_col-1] being the last. It doesn't look
2762 like it at first glance, but be assured that this routine takes time linear
2763 in the number of columns. Although not immediately obvious, the time
2764 taken by this routine is O (n_col), that is, linear in the number of
2765 columns. Not user-callable.
2766 */
2767
2768 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! void order_childrencxx . . $ order_children(af26e60859f2017e).
2769 (
2770 /* === Parameters ======================================================= */
2771
2772 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col, /* number of columns of A */
2773 Colamd_Colcxx . . $ Colamd_Col# Col [], /* of size n_col+1 */
2774 Intcxx . . $ `external/glpk/colamd.c:710:9`! p [] /* p [0 ... n_col-1] is the column permutation*/
2775 )
2776 {
2777 /* === Local variables ================================================== */
2778
2779 Intcxx . . $ `external/glpk/colamd.c:710:9`! i ; /* loop counter for all columns */
2780 Intcxx . . $ `external/glpk/colamd.c:710:9`! c ; /* column index */
2781 Intcxx . . $ `external/glpk/colamd.c:710:9`! parent ; /* index of column's parent */
2782 Intcxx . . $ `external/glpk/colamd.c:710:9`! order ; /* column's order */
2783
2784 /* === Order each non-principal column ================================== */
2785
2786 for (i = 0 ; i < n_col ; i++)
2787 {
2788 /* find an un-ordered non-principal column */
2789 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (COL_IS_DEAD (i)) ;
2790 if (!COL_IS_DEAD_PRINCIPALcxx . . $ `external/glpk/colamd.c:826:9`! (i) && Col [i].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. == EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!)
2791 {
2792 parent = i ;
2793 /* once found, find its principal parent */
2794 do
2795 {
2796 parent = Col [parent].shared1cxx . . $ Colamd_Col_struct#shared1..parentcxx . . $ Colamd_Col_struct#$anonymous_type_0#parent. ;
2797 } while (!COL_IS_DEAD_PRINCIPALcxx . . $ `external/glpk/colamd.c:826:9`! (parent)) ;
2798
2799 /* now, order all un-ordered non-principal columns along path */
2800 /* to this parent. collapse tree at the same time */
2801 c = i ;
2802 /* get order of parent */
2803 order = Col [parent].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. ;
2804
2805 do
2806 {
2807 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (Col [c].shared2.order == EMPTY) ;
2808
2809 /* order this column */
2810 Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. = order++ ;
2811 /* collaps tree */
2812 Col [c].shared1cxx . . $ Colamd_Col_struct#shared1..parentcxx . . $ Colamd_Col_struct#$anonymous_type_0#parent. = parent ;
2813
2814 /* get immediate parent of this column */
2815 c = Col [c].shared1cxx . . $ Colamd_Col_struct#shared1..parentcxx . . $ Colamd_Col_struct#$anonymous_type_0#parent. ;
2816
2817 /* continue until we hit an ordered column. There are */
2818 /* guarranteed not to be anymore unordered columns */
2819 /* above an ordered column */
2820 } while (Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. == EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!) ;
2821
2822 /* re-order the super_col parent to largest order for this group */
2823 Col [parent].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. = order ;
2824 }
2825 }
2826
2827 /* === Generate the permutation ========================================= */
2828
2829 for (c = 0 ; c < n_col ; c++)
2830 {
2831 p [Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order.] = c ;
2832 }
2833 }
2834
2835
2836 /* ========================================================================== */
2837 /* === detect_super_cols ==================================================== */
2838 /* ========================================================================== */
2839
2840 /*
2841 Detects supercolumns by finding matches between columns in the hash buckets.
2842 Check amongst columns in the set A [row_start ... row_start + row_length-1].
2843 The columns under consideration are currently *not* in the degree lists,
2844 and have already been placed in the hash buckets.
2845
2846 The hash bucket for columns whose hash function is equal to h is stored
2847 as follows:
2848
2849 if head [h] is >= 0, then head [h] contains a degree list, so:
2850
2851 head [h] is the first column in degree bucket h.
2852 Col [head [h]].headhash gives the first column in hash bucket h.
2853
2854 otherwise, the degree list is empty, and:
2855
2856 -(head [h] + 2) is the first column in hash bucket h.
2857
2858 For a column c in a hash bucket, Col [c].shared3.prev is NOT a "previous
2859 column" pointer. Col [c].shared3.hash is used instead as the hash number
2860 for that column. The value of Col [c].shared4.hash_next is the next column
2861 in the same hash bucket.
2862
2863 Assuming no, or "few" hash collisions, the time taken by this routine is
2864 linear in the sum of the sizes (lengths) of each column whose score has
2865 just been computed in the approximate degree computation.
2866 Not user-callable.
2867 */
2868
2869 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! void detect_super_colscxx . . $ detect_super_cols(e427314c50360653).
2870 (
2871 /* === Parameters ======================================================= */
2872
2873 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
2874 /* these two parameters are only needed when debugging is enabled: */
2875 Int n_col, /* number of columns of A */
2876 Colamd_Row Row [], /* of size n_row+1 */
2877 #endif /* NDEBUG */
2878
2879 Colamd_Colcxx . . $ Colamd_Col# Col [], /* of size n_col+1 */
2880 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [], /* row indices of A */
2881 Intcxx . . $ `external/glpk/colamd.c:710:9`! head [], /* head of degree lists and hash buckets */
2882 Intcxx . . $ `external/glpk/colamd.c:710:9`! row_start, /* pointer to set of columns to check */
2883 Intcxx . . $ `external/glpk/colamd.c:710:9`! row_length /* number of columns to check */
2884 )
2885 {
2886 /* === Local variables ================================================== */
2887
2888 Intcxx . . $ `external/glpk/colamd.c:710:9`! hash ; /* hash value for a column */
2889 Intcxx . . $ `external/glpk/colamd.c:710:9`! *rp ; /* pointer to a row */
2890 Intcxx . . $ `external/glpk/colamd.c:710:9`! c ; /* a column index */
2891 Intcxx . . $ `external/glpk/colamd.c:710:9`! super_c ; /* column index of the column to absorb into */
2892 Intcxx . . $ `external/glpk/colamd.c:710:9`! *cp1 ; /* column pointer for column super_c */
2893 Intcxx . . $ `external/glpk/colamd.c:710:9`! *cp2 ; /* column pointer for column c */
2894 Intcxx . . $ `external/glpk/colamd.c:710:9`! length ; /* length of column super_c */
2895 Intcxx . . $ `external/glpk/colamd.c:710:9`! prev_c ; /* column preceding c in hash bucket */
2896 Intcxx . . $ `external/glpk/colamd.c:710:9`! i ; /* loop counter */
2897 Intcxx . . $ `external/glpk/colamd.c:710:9`! *rp_end ; /* pointer to the end of the row */
2898 Intcxx . . $ `external/glpk/colamd.c:710:9`! col ; /* a column index in the row to check */
2899 Intcxx . . $ `external/glpk/colamd.c:710:9`! head_column ; /* first column in hash bucket or degree list */
2900 Intcxx . . $ `external/glpk/colamd.c:710:9`! first_col ; /* first column in hash bucket */
2901
2902 /* === Consider each column in the row ================================== */
2903
2904 rp = &A [row_start] ;
2905 rp_end = rp + row_length ;
2906 while (rp < rp_end)
2907 {
2908 col = *rp++ ;
2909 if (COL_IS_DEADcxx . . $ `external/glpk/colamd.c:824:9`! (col))
2910 {
2911 continue ;
2912 }
2913
2914 /* get hash number for this column */
2915 hash = Col [col].shared3cxx . . $ Colamd_Col_struct#shared3..hashcxx . . $ Colamd_Col_struct#$anonymous_type_2#hash. ;
2916 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (hash <= n_col) ;
2917
2918 /* === Get the first column in this hash bucket ===================== */
2919
2920 head_column = head [hash] ;
2921 if (head_column > EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!)
2922 {
2923 first_col = Col [head_column].shared3cxx . . $ Colamd_Col_struct#shared3..headhashcxx . . $ Colamd_Col_struct#$anonymous_type_2#headhash. ;
2924 }
2925 else
2926 {
2927 first_col = - (head_column + 2) ;
2928 }
2929
2930 /* === Consider each column in the hash bucket ====================== */
2931
2932 for (super_c = first_col ; super_c != EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
2933 super_c = Col [super_c].shared4cxx . . $ Colamd_Col_struct#shared4..hash_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#hash_next.)
2934 {
2935 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (COL_IS_ALIVE (super_c)) ;
2936 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (Col [super_c].shared3.hash == hash) ;
2937 length = Col [super_c].lengthcxx . . $ Colamd_Col_struct#length. ;
2938
2939 /* prev_c is the column preceding column c in the hash bucket */
2940 prev_c = super_c ;
2941
2942 /* === Compare super_c with all columns after it ================ */
2943
2944 for (c = Col [super_c].shared4cxx . . $ Colamd_Col_struct#shared4..hash_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#hash_next. ;
2945 c != EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ; c = Col [c].shared4cxx . . $ Colamd_Col_struct#shared4..hash_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#hash_next.)
2946 {
2947 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (c != super_c) ;
2948 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (COL_IS_ALIVE (c)) ;
2949 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (Col [c].shared3.hash == hash) ;
2950
2951 /* not identical if lengths or scores are different */
2952 if (Col [c].lengthcxx . . $ Colamd_Col_struct#length. != length ||
2953 Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score. != Col [super_c].shared2cxx . . $ Colamd_Col_struct#shared2..scorecxx . . $ Colamd_Col_struct#$anonymous_type_1#score.)
2954 {
2955 prev_c = c ;
2956 continue ;
2957 }
2958
2959 /* compare the two columns */
2960 cp1 = &A [Col [super_c].startcxx . . $ Colamd_Col_struct#start.] ;
2961 cp2 = &A [Col [c].startcxx . . $ Colamd_Col_struct#start.] ;
2962
2963 for (i = 0 ; i < length ; i++)
2964 {
2965 /* the columns are "clean" (no dead rows) */
2966 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (ROW_IS_ALIVE (*cp1)) ;
2967 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (ROW_IS_ALIVE (*cp2)) ;
2968 /* row indices will same order for both supercols, */
2969 /* no gather scatter nessasary */
2970 if (*cp1++ != *cp2++)
2971 {
2972 break ;
2973 }
2974 }
2975
2976 /* the two columns are different if the for-loop "broke" */
2977 if (i != length)
2978 {
2979 prev_c = c ;
2980 continue ;
2981 }
2982
2983 /* === Got it! two columns are identical =================== */
2984
2985 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (Col [c].shared2.score == Col [super_c].shared2.score) ;
2986
2987 Col [super_c].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. += Col [c].shared1cxx . . $ Colamd_Col_struct#shared1..thicknesscxx . . $ Colamd_Col_struct#$anonymous_type_0#thickness. ;
2988 Col [c].shared1cxx . . $ Colamd_Col_struct#shared1..parentcxx . . $ Colamd_Col_struct#$anonymous_type_0#parent. = super_c ;
2989 KILL_NON_PRINCIPAL_COLcxx . . $ `external/glpk/colamd.c:829:9`! (c) ;
2990 /* order c later, in order_children() */
2991 Col [c].shared2cxx . . $ Colamd_Col_struct#shared2..ordercxx . . $ Colamd_Col_struct#$anonymous_type_1#order. = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
2992 /* remove c from hash bucket */
2993 Col [prev_c].shared4cxx . . $ Colamd_Col_struct#shared4..hash_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#hash_next. = Col [c].shared4cxx . . $ Colamd_Col_struct#shared4..hash_nextcxx . . $ Colamd_Col_struct#$anonymous_type_3#hash_next. ;
2994 }
2995 }
2996
2997 /* === Empty this hash bucket ======================================= */
2998
2999 if (head_column > EMPTYcxx . . $ `external/glpk/colamd.c:810:9`!)
3000 {
3001 /* corresponding degree list "hash" is not empty */
3002 Col [head_column].shared3cxx . . $ Colamd_Col_struct#shared3..headhashcxx . . $ Colamd_Col_struct#$anonymous_type_2#headhash. = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
3003 }
3004 else
3005 {
3006 /* corresponding degree list "hash" is empty */
3007 head [hash] = EMPTYcxx . . $ `external/glpk/colamd.c:810:9`! ;
3008 }
3009 }
3010 }
3011
3012
3013 /* ========================================================================== */
3014 /* === garbage_collection =================================================== */
3015 /* ========================================================================== */
3016
3017 /*
3018 Defragments and compacts columns and rows in the workspace A. Used when
3019 all avaliable memory has been used while performing row merging. Returns
3020 the index of the first free position in A, after garbage collection. The
3021 time taken by this routine is linear is the size of the array A, which is
3022 itself linear in the number of nonzeros in the input matrix.
3023 Not user-callable.
3024 */
3025
3026 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! garbage_collectioncxx . . $ garbage_collection(59e400dca74828d0). /* returns the new value of pfree */
3027 (
3028 /* === Parameters ======================================================= */
3029
3030 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row, /* number of rows */
3031 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_col, /* number of columns */
3032 Colamd_Rowcxx . . $ Colamd_Row# Row [], /* row info */
3033 Colamd_Colcxx . . $ Colamd_Col# Col [], /* column info */
3034 Intcxx . . $ `external/glpk/colamd.c:710:9`! A [], /* A [0 ... Alen-1] holds the matrix */
3035 Intcxx . . $ `external/glpk/colamd.c:710:9`! *pfree /* &A [0] ... pfree is in use */
3036 )
3037 {
3038 /* === Local variables ================================================== */
3039
3040 Intcxx . . $ `external/glpk/colamd.c:710:9`! *psrc ; /* source pointer */
3041 Intcxx . . $ `external/glpk/colamd.c:710:9`! *pdest ; /* destination pointer */
3042 Intcxx . . $ `external/glpk/colamd.c:710:9`! j ; /* counter */
3043 Intcxx . . $ `external/glpk/colamd.c:710:9`! r ; /* a row index */
3044 Intcxx . . $ `external/glpk/colamd.c:710:9`! c ; /* a column index */
3045 Intcxx . . $ `external/glpk/colamd.c:710:9`! length ; /* length of a row or column */
3046
3047 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
3048 Int debug_rows ;
3049 DEBUG2 (("Defrag..\n")) ;
3050 for (psrc = &A[0] ; psrc < pfree ; psrc++) ASSERT (*psrc >= 0) ;
3051 debug_rows = 0 ;
3052 #endif /* NDEBUG */
3053
3054 /* === Defragment the columns =========================================== */
3055
3056 pdest = &A[0] ;
3057 for (c = 0 ; c < n_col ; c++)
3058 {
3059 if (COL_IS_ALIVEcxx . . $ `external/glpk/colamd.c:825:9`! (c))
3060 {
3061 psrc = &A [Col [c].startcxx . . $ Colamd_Col_struct#start.] ;
3062
3063 /* move and compact the column */
3064 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (pdest <= psrc) ;
3065 Col [c].startcxx . . $ Colamd_Col_struct#start. = (Intcxx . . $ `external/glpk/colamd.c:710:9`!) (pdest - &A [0]) ;
3066 length = Col [c].lengthcxx . . $ Colamd_Col_struct#length. ;
3067 for (j = 0 ; j < length ; j++)
3068 {
3069 r = *psrc++ ;
3070 if (ROW_IS_ALIVEcxx . . $ `external/glpk/colamd.c:823:9`! (r))
3071 {
3072 *pdest++ = r ;
3073 }
3074 }
3075 Col [c].lengthcxx . . $ Colamd_Col_struct#length. = (Intcxx . . $ `external/glpk/colamd.c:710:9`!) (pdest - &A [Col [c].startcxx . . $ Colamd_Col_struct#start.]) ;
3076 }
3077 }
3078
3079 /* === Prepare to defragment the rows =================================== */
3080
3081 for (r = 0 ; r < n_row ; r++)
3082 {
3083 if (ROW_IS_DEADcxx . . $ `external/glpk/colamd.c:821:9`! (r) || (Row [r].lengthcxx . . $ Colamd_Row_struct#length. == 0))
3084 {
3085 /* This row is already dead, or is of zero length. Cannot compact
3086 * a row of zero length, so kill it. NOTE: in the current version,
3087 * there are no zero-length live rows. Kill the row (for the first
3088 * time, or again) just to be safe. */
3089 KILL_ROWcxx . . $ `external/glpk/colamd.c:827:9`! (r) ;
3090 }
3091 else
3092 {
3093 /* save first column index in Row [r].shared2.first_column */
3094 psrc = &A [Row [r].startcxx . . $ Colamd_Row_struct#start.] ;
3095 Row [r].shared2cxx . . $ Colamd_Row_struct#shared2..first_columncxx . . $ Colamd_Row_struct#$anonymous_type_5#first_column. = *psrc ;
3096 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (ROW_IS_ALIVE (r)) ;
3097 /* flag the start of the row with the one's complement of row */
3098 *psrc = ONES_COMPLEMENTcxx . . $ `external/glpk/colamd.c:794:9`! (r) ;
3099 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
3100 debug_rows++ ;
3101 #endif /* NDEBUG */
3102 }
3103 }
3104
3105 /* === Defragment the rows ============================================== */
3106
3107 psrc = pdest ;
3108 while (psrc < pfree)
3109 {
3110 /* find a negative number ... the start of a row */
3111 if (*psrc++ < 0)
3112 {
3113 psrc-- ;
3114 /* get the row index */
3115 r = ONES_COMPLEMENTcxx . . $ `external/glpk/colamd.c:794:9`! (*psrc) ;
3116 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (r >= 0 && r < n_row) ;
3117 /* restore first column index */
3118 *psrc = Row [r].shared2cxx . . $ Colamd_Row_struct#shared2..first_columncxx . . $ Colamd_Row_struct#$anonymous_type_5#first_column. ;
3119 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (ROW_IS_ALIVE (r)) ;
3120 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (Row [r].length > 0) ;
3121 /* move and compact the row */
3122 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (pdest <= psrc) ;
3123 Row [r].startcxx . . $ Colamd_Row_struct#start. = (Intcxx . . $ `external/glpk/colamd.c:710:9`!) (pdest - &A [0]) ;
3124 length = Row [r].lengthcxx . . $ Colamd_Row_struct#length. ;
3125 for (j = 0 ; j < length ; j++)
3126 {
3127 c = *psrc++ ;
3128 if (COL_IS_ALIVEcxx . . $ `external/glpk/colamd.c:825:9`! (c))
3129 {
3130 *pdest++ = c ;
3131 }
3132 }
3133 Row [r].lengthcxx . . $ Colamd_Row_struct#length. = (Intcxx . . $ `external/glpk/colamd.c:710:9`!) (pdest - &A [Row [r].startcxx . . $ Colamd_Row_struct#start.]) ;
3134 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (Row [r].length > 0) ;
3135 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
3136 debug_rows-- ;
3137 #endif /* NDEBUG */
3138 }
3139 }
3140 /* ensure we found all the rows */
3141 ASSERTcxx . . $ `external/glpk/colamd.c:1021:9`! (debug_rows == 0) ;
3142
3143 /* === Return the new value of pfree ==================================== */
3144
3145 return ((Intcxx . . $ `external/glpk/colamd.c:710:9`!) (pdest - &A [0])) ;
3146 }
3147
3148
3149 /* ========================================================================== */
3150 /* === clear_mark =========================================================== */
3151 /* ========================================================================== */
3152
3153 /*
3154 Clears the Row [].shared2.mark array, and returns the new tag_mark.
3155 Return value is the new tag_mark. Not user-callable.
3156 */
3157
3158 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! Intcxx . . $ `external/glpk/colamd.c:710:9`! clear_markcxx . . $ clear_mark(a64fdf7fc08061e1). /* return the new value for tag_mark */
3159 (
3160 /* === Parameters ======================================================= */
3161
3162 Intcxx . . $ `external/glpk/colamd.c:710:9`! tag_mark, /* new value of tag_mark */
3163 Intcxx . . $ `external/glpk/colamd.c:710:9`! max_mark, /* max allowed value of tag_mark */
3164
3165 Intcxx . . $ `external/glpk/colamd.c:710:9`! n_row, /* number of rows in A */
3166 Colamd_Rowcxx . . $ Colamd_Row# Row [] /* Row [0 ... n_row-1].shared2.mark is set to zero */
3167 )
3168 {
3169 /* === Local variables ================================================== */
3170
3171 Intcxx . . $ `external/glpk/colamd.c:710:9`! r ;
3172
3173 if (tag_mark <= 0 || tag_mark >= max_mark)
3174 {
3175 for (r = 0 ; r < n_row ; r++)
3176 {
3177 if (ROW_IS_ALIVEcxx . . $ `external/glpk/colamd.c:823:9`! (r))
3178 {
3179 Row [r].shared2cxx . . $ Colamd_Row_struct#shared2..markcxx . . $ Colamd_Row_struct#$anonymous_type_5#mark. = 0 ;
3180 }
3181 }
3182 tag_mark = 1 ;
3183 }
3184
3185 return (tag_mark) ;
3186 }
3187
3188
3189 /* ========================================================================== */
3190 /* === print_report ========================================================= */
3191 /* ========================================================================== */
3192
3193 PRIVATEcxx . . $ `external/glpk/colamd.c:786:9`! void print_reportcxx . . $ print_report(56561451ddc58846).
3194 (
3195 char *method,
3196 Intcxx . . $ `external/glpk/colamd.c:710:9`! stats [COLAMD_STATScxx . . $ `external/glpk/colamd.h:20:9`!]
3197 )
3198 {
3199
3200 Intcxx . . $ `external/glpk/colamd.c:710:9`! i1, i2, i3 ;
3201
3202 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`! (("\n%s version %d.%d, %s: ", method,
3203 COLAMD_MAIN_VERSIONcxx . . $ `external/glpk/colamd.h:13:9`!, COLAMD_SUB_VERSIONcxx . . $ `external/glpk/colamd.h:14:9`!, COLAMD_DATEcxx . . $ `external/glpk/colamd.h:11:9`!)) ;
3204
3205 if (!stats)
3206 {
3207 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`! (("No statistics available.\n")) ;
3208 return ;
3209 }
3210
3211 i1 = stats [COLAMD_INFO1cxx . . $ `external/glpk/colamd.h:26:9`!] ;
3212 i2 = stats [COLAMD_INFO2cxx . . $ `external/glpk/colamd.h:27:9`!] ;
3213 i3 = stats [COLAMD_INFO3cxx . . $ `external/glpk/colamd.h:28:9`!] ;
3214
3215 if (stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!] >= 0)
3216 {
3217 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`! (("OK. ")) ;
3218 }
3219 else
3220 {
3221 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`! (("ERROR. ")) ;
3222 }
3223
3224 switch (stats [COLAMD_STATUScxx . . $ `external/glpk/colamd.h:25:9`!])
3225 {
3226
3227 case COLAMD_OK_BUT_JUMBLEDcxx . . $ `external/glpk/colamd.h:31:9`!:
3228
3229 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("Matrix has unsorted or duplicate row indices.\n")) ;
3230
3231 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("%s: number of duplicate or out-of-order row indices: %d\n",
3232 method, i3)) ;
3233
3234 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("%s: last seen duplicate or out-of-order row index: %d\n",
3235 method, INDEXcxx . . $ `external/glpk/colamd.c:840:9`! (i2))) ;
3236
3237 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("%s: last seen in column: %d",
3238 method, INDEXcxx . . $ `external/glpk/colamd.c:840:9`! (i1))) ;
3239
3240 /* no break - fall through to next case instead */
3241
3242 case COLAMD_OKcxx . . $ `external/glpk/colamd.h:30:9`!:
3243
3244 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("\n")) ;
3245
3246 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("%s: number of dense or empty rows ignored: %d\n",
3247 method, stats [COLAMD_DENSE_ROWcxx . . $ `external/glpk/colamd.h:21:9`!])) ;
3248
3249 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("%s: number of dense or empty columns ignored: %d\n",
3250 method, stats [COLAMD_DENSE_COLcxx . . $ `external/glpk/colamd.h:22:9`!])) ;
3251
3252 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("%s: number of garbage collections performed: %d\n",
3253 method, stats [COLAMD_DEFRAG_COUNTcxx . . $ `external/glpk/colamd.h:24:9`!])) ;
3254 break ;
3255
3256 case COLAMD_ERROR_A_not_presentcxx . . $ `external/glpk/colamd.h:32:9`!:
3257
3258 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("Array A (row indices of matrix) not present.\n")) ;
3259 break ;
3260
3261 case COLAMD_ERROR_p_not_presentcxx . . $ `external/glpk/colamd.h:33:9`!:
3262
3263 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("Array p (column pointers for matrix) not present.\n")) ;
3264 break ;
3265
3266 case COLAMD_ERROR_nrow_negativecxx . . $ `external/glpk/colamd.h:34:9`!:
3267
3268 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("Invalid number of rows (%d).\n", i1)) ;
3269 break ;
3270
3271 case COLAMD_ERROR_ncol_negativecxx . . $ `external/glpk/colamd.h:35:9`!:
3272
3273 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("Invalid number of columns (%d).\n", i1)) ;
3274 break ;
3275
3276 case COLAMD_ERROR_nnz_negativecxx . . $ `external/glpk/colamd.h:36:9`!:
3277
3278 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("Invalid number of nonzero entries (%d).\n", i1)) ;
3279 break ;
3280
3281 case COLAMD_ERROR_p0_nonzerocxx . . $ `external/glpk/colamd.h:37:9`!:
3282
3283 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("Invalid column pointer, p [0] = %d, must be zero.\n", i1));
3284 break ;
3285
3286 case COLAMD_ERROR_A_too_smallcxx . . $ `external/glpk/colamd.h:38:9`!:
3287
3288 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("Array A too small.\n")) ;
3289 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!((" Need Alen >= %d, but given only Alen = %d.\n",
3290 i1, i2)) ;
3291 break ;
3292
3293 case COLAMD_ERROR_col_length_negativecxx . . $ `external/glpk/colamd.h:39:9`!:
3294
3295 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!
3296 (("Column %d has a negative number of nonzero entries (%d).\n",
3297 INDEXcxx . . $ `external/glpk/colamd.c:840:9`! (i1), i2)) ;
3298 break ;
3299
3300 case COLAMD_ERROR_row_index_out_of_boundscxx . . $ `external/glpk/colamd.h:40:9`!:
3301
3302 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!
3303 (("Row index (row %d) out of bounds (%d to %d) in column %d.\n",
3304 INDEXcxx . . $ `external/glpk/colamd.c:840:9`! (i2), INDEXcxx . . $ `external/glpk/colamd.c:840:9`! (0), INDEXcxx . . $ `external/glpk/colamd.c:840:9`! (i3-1), INDEXcxx . . $ `external/glpk/colamd.c:840:9`! (i1))) ;
3305 break ;
3306
3307 case COLAMD_ERROR_out_of_memorycxx . . $ `external/glpk/colamd.h:41:9`!:
3308
3309 PRINTFcxx . . $ `external/glpk/colamd.c:844:9`!(("Out of memory.\n")) ;
3310 break ;
3311
3312 /* v2.4: internal-error case deleted */
3313 }
3314 }
3315
3316
3317
3318
3319 /* ========================================================================== */
3320 /* === colamd debugging routines ============================================ */
3321 /* ========================================================================== */
3322
3323 /* When debugging is disabled, the remainder of this file is ignored. */
3324
3325 #ifndef NDEBUGcxx . . $ `external/glpk/colamd.c:626:9`!
3326
3327
3328 /* ========================================================================== */
3329 /* === debug_structures ===================================================== */
3330 /* ========================================================================== */
3331
3332 /*
3333 At this point, all empty rows and columns are dead. All live columns
3334 are "clean" (containing no dead rows) and simplicial (no supercolumns
3335 yet). Rows may contain dead columns, but all live rows contain at
3336 least one live column.
3337 */
3338
3339 PRIVATE void debug_structures
3340 (
3341 /* === Parameters ======================================================= */
3342
3343 Int n_row,
3344 Int n_col,
3345 Colamd_Row Row [],
3346 Colamd_Col Col [],
3347 Int A [],
3348 Int n_col2
3349 )
3350 {
3351 /* === Local variables ================================================== */
3352
3353 Int i ;
3354 Int c ;
3355 Int *cp ;
3356 Int *cp_end ;
3357 Int len ;
3358 Int score ;
3359 Int r ;
3360 Int *rp ;
3361 Int *rp_end ;
3362 Int deg ;
3363
3364 /* === Check A, Row, and Col ============================================ */
3365
3366 for (c = 0 ; c < n_col ; c++)
3367 {
3368 if (COL_IS_ALIVE (c))
3369 {
3370 len = Col [c].length ;
3371 score = Col [c].shared2.score ;
3372 DEBUG4 (("initial live col %5d %5d %5d\n", c, len, score)) ;
3373 ASSERT (len > 0) ;
3374 ASSERT (score >= 0) ;
3375 ASSERT (Col [c].shared1.thickness == 1) ;
3376 cp = &A [Col [c].start] ;
3377 cp_end = cp + len ;
3378 while (cp < cp_end)
3379 {
3380 r = *cp++ ;
3381 ASSERT (ROW_IS_ALIVE (r)) ;
3382 }
3383 }
3384 else
3385 {
3386 i = Col [c].shared2.order ;
3387 ASSERT (i >= n_col2 && i < n_col) ;
3388 }
3389 }
3390
3391 for (r = 0 ; r < n_row ; r++)
3392 {
3393 if (ROW_IS_ALIVE (r))
3394 {
3395 i = 0 ;
3396 len = Row [r].length ;
3397 deg = Row [r].shared1.degree ;
3398 ASSERT (len > 0) ;
3399 ASSERT (deg > 0) ;
3400 rp = &A [Row [r].start] ;
3401 rp_end = rp + len ;
3402 while (rp < rp_end)
3403 {
3404 c = *rp++ ;
3405 if (COL_IS_ALIVE (c))
3406 {
3407 i++ ;
3408 }
3409 }
3410 ASSERT (i > 0) ;
3411 }
3412 }
3413 }
3414
3415
3416 /* ========================================================================== */
3417 /* === debug_deg_lists ====================================================== */
3418 /* ========================================================================== */
3419
3420 /*
3421 Prints the contents of the degree lists. Counts the number of columns
3422 in the degree list and compares it to the total it should have. Also
3423 checks the row degrees.
3424 */
3425
3426 PRIVATE void debug_deg_lists
3427 (
3428 /* === Parameters ======================================================= */
3429
3430 Int n_row,
3431 Int n_col,
3432 Colamd_Row Row [],
3433 Colamd_Col Col [],
3434 Int head [],
3435 Int min_score,
3436 Int should,
3437 Int max_deg
3438 )
3439 {
3440 /* === Local variables ================================================== */
3441
3442 Int deg ;
3443 Int col ;
3444 Int have ;
3445 Int row ;
3446
3447 /* === Check the degree lists =========================================== */
3448
3449 if (n_col > 10000 && colamd_debug <= 0)
3450 {
3451 return ;
3452 }
3453 have = 0 ;
3454 DEBUG4 (("Degree lists: %d\n", min_score)) ;
3455 for (deg = 0 ; deg <= n_col ; deg++)
3456 {
3457 col = head [deg] ;
3458 if (col == EMPTY)
3459 {
3460 continue ;
3461 }
3462 DEBUG4 (("%d:", deg)) ;
3463 while (col != EMPTY)
3464 {
3465 DEBUG4 ((" %d", col)) ;
3466 have += Col [col].shared1.thickness ;
3467 ASSERT (COL_IS_ALIVE (col)) ;
3468 col = Col [col].shared4.degree_next ;
3469 }
3470 DEBUG4 (("\n")) ;
3471 }
3472 DEBUG4 (("should %d have %d\n", should, have)) ;
3473 ASSERT (should == have) ;
3474
3475 /* === Check the row degrees ============================================ */
3476
3477 if (n_row > 10000 && colamd_debug <= 0)
3478 {
3479 return ;
3480 }
3481 for (row = 0 ; row < n_row ; row++)
3482 {
3483 if (ROW_IS_ALIVE (row))
3484 {
3485 ASSERT (Row [row].shared1.degree <= max_deg) ;
3486 }
3487 }
3488 }
3489
3490
3491 /* ========================================================================== */
3492 /* === debug_mark =========================================================== */
3493 /* ========================================================================== */
3494
3495 /*
3496 Ensures that the tag_mark is less that the maximum and also ensures that
3497 each entry in the mark array is less than the tag mark.
3498 */
3499
3500 PRIVATE void debug_mark
3501 (
3502 /* === Parameters ======================================================= */
3503
3504 Int n_row,
3505 Colamd_Row Row [],
3506 Int tag_mark,
3507 Int max_mark
3508 )
3509 {
3510 /* === Local variables ================================================== */
3511
3512 Int r ;
3513
3514 /* === Check the Row marks ============================================== */
3515
3516 ASSERT (tag_mark > 0 && tag_mark <= max_mark) ;
3517 if (n_row > 10000 && colamd_debug <= 0)
3518 {
3519 return ;
3520 }
3521 for (r = 0 ; r < n_row ; r++)
3522 {
3523 ASSERT (Row [r].shared2.mark < tag_mark) ;
3524 }
3525 }
3526
3527
3528 /* ========================================================================== */
3529 /* === debug_matrix ========================================================= */
3530 /* ========================================================================== */
3531
3532 /*
3533 Prints out the contents of the columns and the rows.
3534 */
3535
3536 PRIVATE void debug_matrix
3537 (
3538 /* === Parameters ======================================================= */
3539
3540 Int n_row,
3541 Int n_col,
3542 Colamd_Row Row [],
3543 Colamd_Col Col [],
3544 Int A []
3545 )
3546 {
3547 /* === Local variables ================================================== */
3548
3549 Int r ;
3550 Int c ;
3551 Int *rp ;
3552 Int *rp_end ;
3553 Int *cp ;
3554 Int *cp_end ;
3555
3556 /* === Dump the rows and columns of the matrix ========================== */
3557
3558 if (colamd_debug < 3)
3559 {
3560 return ;
3561 }
3562 DEBUG3 (("DUMP MATRIX:\n")) ;
3563 for (r = 0 ; r < n_row ; r++)
3564 {
3565 DEBUG3 (("Row %d alive? %d\n", r, ROW_IS_ALIVE (r))) ;
3566 if (ROW_IS_DEAD (r))
3567 {
3568 continue ;
3569 }
3570 DEBUG3 (("start %d length %d degree %d\n",
3571 Row [r].start, Row [r].length, Row [r].shared1.degree)) ;
3572 rp = &A [Row [r].start] ;
3573 rp_end = rp + Row [r].length ;
3574 while (rp < rp_end)
3575 {
3576 c = *rp++ ;
3577 DEBUG4 ((" %d col %d\n", COL_IS_ALIVE (c), c)) ;
3578 }
3579 }
3580
3581 for (c = 0 ; c < n_col ; c++)
3582 {
3583 DEBUG3 (("Col %d alive? %d\n", c, COL_IS_ALIVE (c))) ;
3584 if (COL_IS_DEAD (c))
3585 {
3586 continue ;
3587 }
3588 DEBUG3 (("start %d length %d shared1 %d shared2 %d\n",
3589 Col [c].start, Col [c].length,
3590 Col [c].shared1.thickness, Col [c].shared2.score)) ;
3591 cp = &A [Col [c].start] ;
3592 cp_end = cp + Col [c].length ;
3593 while (cp < cp_end)
3594 {
3595 r = *cp++ ;
3596 DEBUG4 ((" %d row %d\n", ROW_IS_ALIVE (r), r)) ;
3597 }
3598 }
3599 }
3600
3601 PRIVATE void colamd_get_debug
3602 (
3603 char *method
3604 )
3605 {
3606 FILE *f ;
3607 colamd_debug = 0 ; /* no debug printing */
3608 f = fopen ("debug", "r") ;
3609 if (f == (FILE *) NULL)
3610 {
3611 colamd_debug = 0 ;
3612 }
3613 else
3614 {
3615 fscanf (f, "%d", &colamd_debug) ;
3616 fclose (f) ;
3617 }
3618 DEBUG0 (("%s: debug version, D = %d (THIS WILL BE SLOW!)\n",
3619 method, colamd_debug)) ;
3620 }
3621
3622 #endif /* NDEBUG */