Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
amesos_amd_l2.c
Go to the documentation of this file.
1 /* ========================================================================= */
2 /* === AMD_2 =============================================================== */
3 /* ========================================================================= */
4 
5 /* ------------------------------------------------------------------------- */
6 /* AMD, Copyright (c) Timothy A. Davis, */
7 /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8 /* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
9 /* web: http://www.cise.ufl.edu/research/sparse/amd */
10 /* ------------------------------------------------------------------------- */
11 
12 /* AMD_2: performs the AMD ordering on a symmetric sparse matrix A, followed
13  * by a postordering (via depth-first search) of the assembly tree using the
14  * AMD_postorder routine.
15  */
16 
17 /* This file should make the long int version of AMD */
18 #define DLONG 1
19 
20 #include "amesos_amd_internal.h"
21 
22 /* ========================================================================= */
23 /* === clear_flag ========================================================== */
24 /* ========================================================================= */
25 
26 static Int amesos_clear_flag (Int wflg, Int wbig, Int W [ ], Int n)
27 {
28  Int x ;
29  if (wflg < 2 || wflg >= wbig)
30  {
31  for (x = 0 ; x < n ; x++)
32  {
33  if (W [x] != 0) W [x] = 1 ;
34  }
35  wflg = 2 ;
36  }
37  /* at this point, W [0..n-1] < wflg holds */
38  return (wflg) ;
39 }
40 
41 
42 /* ========================================================================= */
43 /* === AMD_2 =============================================================== */
44 /* ========================================================================= */
45 
46 GLOBAL void AMD_2
47 (
48  Int n, /* A is n-by-n, where n > 0 */
49  Int Pe [ ], /* Pe [0..n-1]: index in Iw of row i on input */
50  Int Iw [ ], /* workspace of size iwlen. Iw [0..pfree-1]
51  * holds the matrix on input */
52  Int Len [ ], /* Len [0..n-1]: length for row/column i on input */
53  Int iwlen, /* length of Iw. iwlen >= pfree + n */
54  Int pfree, /* Iw [pfree ... iwlen-1] is empty on input */
55 
56  /* 7 size-n workspaces, not defined on input: */
57  Int Nv [ ], /* the size of each supernode on output */
58  Int Next [ ], /* the output inverse permutation */
59  Int Last [ ], /* the output permutation */
60  Int Head [ ],
61  Int Elen [ ], /* the size columns of L for each supernode */
62  Int Degree [ ],
63  Int W [ ],
64 
65  /* control parameters and output statistics */
66  double Control [ ], /* array of size AMD_CONTROL */
67  double Info [ ] /* array of size AMD_INFO */
68 )
69 {
70 
71 /*
72  * Given a representation of the nonzero pattern of a symmetric matrix, A,
73  * (excluding the diagonal) perform an approximate minimum (UMFPACK/MA38-style)
74  * degree ordering to compute a pivot order such that the introduction of
75  * nonzeros (fill-in) in the Cholesky factors A = LL' is kept low. At each
76  * step, the pivot selected is the one with the minimum UMFAPACK/MA38-style
77  * upper-bound on the external degree. This routine can optionally perform
78  * aggresive absorption (as done by MC47B in the Harwell Subroutine
79  * Library).
80  *
81  * The approximate degree algorithm implemented here is the symmetric analog of
82  * the degree update algorithm in MA38 and UMFPACK (the Unsymmetric-pattern
83  * MultiFrontal PACKage, both by Davis and Duff). The routine is based on the
84  * MA27 minimum degree ordering algorithm by Iain Duff and John Reid.
85  *
86  * This routine is a translation of the original AMDBAR and MC47B routines,
87  * in Fortran, with the following modifications:
88  *
89  * (1) dense rows/columns are removed prior to ordering the matrix, and placed
90  * last in the output order. The presence of a dense row/column can
91  * increase the ordering time by up to O(n^2), unless they are removed
92  * prior to ordering.
93  *
94  * (2) the minimum degree ordering is followed by a postordering (depth-first
95  * search) of the assembly tree. Note that mass elimination (discussed
96  * below) combined with the approximate degree update can lead to the mass
97  * elimination of nodes with lower exact degree than the current pivot
98  * element. No additional fill-in is caused in the representation of the
99  * Schur complement. The mass-eliminated nodes merge with the current
100  * pivot element. They are ordered prior to the current pivot element.
101  * Because they can have lower exact degree than the current element, the
102  * merger of two or more of these nodes in the current pivot element can
103  * lead to a single element that is not a "fundamental supernode". The
104  * diagonal block can have zeros in it. Thus, the assembly tree used here
105  * is not guaranteed to be the precise supernodal elemination tree (with
106  * "funadmental" supernodes), and the postordering performed by this
107  * routine is not guaranteed to be a precise postordering of the
108  * elimination tree.
109  *
110  * (3) input parameters are added, to control aggressive absorption and the
111  * detection of "dense" rows/columns of A.
112  *
113  * (4) additional statistical information is returned, such as the number of
114  * nonzeros in L, and the flop counts for subsequent LDL' and LU
115  * factorizations. These are slight upper bounds, because of the mass
116  * elimination issue discussed above.
117  *
118  * (5) additional routines are added to interface this routine to MATLAB
119  * to provide a simple C-callable user-interface, to check inputs for
120  * errors, compute the symmetry of the pattern of A and the number of
121  * nonzeros in each row/column of A+A', to compute the pattern of A+A',
122  * to perform the assembly tree postordering, and to provide debugging
123  * ouput. Many of these functions are also provided by the Fortran
124  * Harwell Subroutine Library routine MC47A.
125  *
126  * (6) both int and UF_long versions are provided. In the descriptions below
127  * and integer is and int or UF_long depending on which version is
128  * being used.
129 
130  **********************************************************************
131  ***** CAUTION: ARGUMENTS ARE NOT CHECKED FOR ERRORS ON INPUT. ******
132  **********************************************************************
133  ** If you want error checking, a more versatile input format, and a **
134  ** simpler user interface, use amd_order or amd_l_order instead. **
135  ** This routine is not meant to be user-callable. **
136  **********************************************************************
137 
138  * ----------------------------------------------------------------------------
139  * References:
140  * ----------------------------------------------------------------------------
141  *
142  * [1] Timothy A. Davis and Iain Duff, "An unsymmetric-pattern multifrontal
143  * method for sparse LU factorization", SIAM J. Matrix Analysis and
144  * Applications, vol. 18, no. 1, pp. 140-158. Discusses UMFPACK / MA38,
145  * which first introduced the approximate minimum degree used by this
146  * routine.
147  *
148  * [2] Patrick Amestoy, Timothy A. Davis, and Iain S. Duff, "An approximate
149  * minimum degree ordering algorithm," SIAM J. Matrix Analysis and
150  * Applications, vol. 17, no. 4, pp. 886-905, 1996. Discusses AMDBAR and
151  * MC47B, which are the Fortran versions of this routine.
152  *
153  * [3] Alan George and Joseph Liu, "The evolution of the minimum degree
154  * ordering algorithm," SIAM Review, vol. 31, no. 1, pp. 1-19, 1989.
155  * We list below the features mentioned in that paper that this code
156  * includes:
157  *
158  * mass elimination:
159  * Yes. MA27 relied on supervariable detection for mass elimination.
160  *
161  * indistinguishable nodes:
162  * Yes (we call these "supervariables"). This was also in the MA27
163  * code - although we modified the method of detecting them (the
164  * previous hash was the true degree, which we no longer keep track
165  * of). A supervariable is a set of rows with identical nonzero
166  * pattern. All variables in a supervariable are eliminated together.
167  * Each supervariable has as its numerical name that of one of its
168  * variables (its principal variable).
169  *
170  * quotient graph representation:
171  * Yes. We use the term "element" for the cliques formed during
172  * elimination. This was also in the MA27 code. The algorithm can
173  * operate in place, but it will work more efficiently if given some
174  * "elbow room."
175  *
176  * element absorption:
177  * Yes. This was also in the MA27 code.
178  *
179  * external degree:
180  * Yes. The MA27 code was based on the true degree.
181  *
182  * incomplete degree update and multiple elimination:
183  * No. This was not in MA27, either. Our method of degree update
184  * within MC47B is element-based, not variable-based. It is thus
185  * not well-suited for use with incomplete degree update or multiple
186  * elimination.
187  *
188  * Authors, and Copyright (C) 2004 by:
189  * Timothy A. Davis, Patrick Amestoy, Iain S. Duff, John K. Reid.
190  *
191  * Acknowledgements: This work (and the UMFPACK package) was supported by the
192  * National Science Foundation (ASC-9111263, DMS-9223088, and CCR-0203270).
193  * The UMFPACK/MA38 approximate degree update algorithm, the unsymmetric analog
194  * which forms the basis of AMD, was developed while Tim Davis was supported by
195  * CERFACS (Toulouse, France) in a post-doctoral position. This C version, and
196  * the etree postorder, were written while Tim Davis was on sabbatical at
197  * Stanford University and Lawrence Berkeley National Laboratory.
198 
199  * ----------------------------------------------------------------------------
200  * INPUT ARGUMENTS (unaltered):
201  * ----------------------------------------------------------------------------
202 
203  * n: The matrix order. Restriction: n >= 1.
204  *
205  * iwlen: The size of the Iw array. On input, the matrix is stored in
206  * Iw [0..pfree-1]. However, Iw [0..iwlen-1] should be slightly larger
207  * than what is required to hold the matrix, at least iwlen >= pfree + n.
208  * Otherwise, excessive compressions will take place. The recommended
209  * value of iwlen is 1.2 * pfree + n, which is the value used in the
210  * user-callable interface to this routine (amd_order.c). The algorithm
211  * will not run at all if iwlen < pfree. Restriction: iwlen >= pfree + n.
212  * Note that this is slightly more restrictive than the actual minimum
213  * (iwlen >= pfree), but AMD_2 will be very slow with no elbow room.
214  * Thus, this routine enforces a bare minimum elbow room of size n.
215  *
216  * pfree: On input the tail end of the array, Iw [pfree..iwlen-1], is empty,
217  * and the matrix is stored in Iw [0..pfree-1]. During execution,
218  * additional data is placed in Iw, and pfree is modified so that
219  * Iw [pfree..iwlen-1] is always the unused part of Iw.
220  *
221  * Control: A double array of size AMD_CONTROL containing input parameters
222  * that affect how the ordering is computed. If NULL, then default
223  * settings are used.
224  *
225  * Control [AMD_DENSE] is used to determine whether or not a given input
226  * row is "dense". A row is "dense" if the number of entries in the row
227  * exceeds Control [AMD_DENSE] times sqrt (n), except that rows with 16 or
228  * fewer entries are never considered "dense". To turn off the detection
229  * of dense rows, set Control [AMD_DENSE] to a negative number, or to a
230  * number larger than sqrt (n). The default value of Control [AMD_DENSE]
231  * is AMD_DEFAULT_DENSE, which is defined in amd.h as 10.
232  *
233  * Control [AMD_AGGRESSIVE] is used to determine whether or not aggressive
234  * absorption is to be performed. If nonzero, then aggressive absorption
235  * is performed (this is the default).
236 
237  * ----------------------------------------------------------------------------
238  * INPUT/OUPUT ARGUMENTS:
239  * ----------------------------------------------------------------------------
240  *
241  * Pe: An integer array of size n. On input, Pe [i] is the index in Iw of
242  * the start of row i. Pe [i] is ignored if row i has no off-diagonal
243  * entries. Thus Pe [i] must be in the range 0 to pfree-1 for non-empty
244  * rows.
245  *
246  * During execution, it is used for both supervariables and elements:
247  *
248  * Principal supervariable i: index into Iw of the description of
249  * supervariable i. A supervariable represents one or more rows of
250  * the matrix with identical nonzero pattern. In this case,
251  * Pe [i] >= 0.
252  *
253  * Non-principal supervariable i: if i has been absorbed into another
254  * supervariable j, then Pe [i] = FLIP (j), where FLIP (j) is defined
255  * as (-(j)-2). Row j has the same pattern as row i. Note that j
256  * might later be absorbed into another supervariable j2, in which
257  * case Pe [i] is still FLIP (j), and Pe [j] = FLIP (j2) which is
258  * < EMPTY, where EMPTY is defined as (-1) in amd_internal.h.
259  *
260  * Unabsorbed element e: the index into Iw of the description of element
261  * e, if e has not yet been absorbed by a subsequent element. Element
262  * e is created when the supervariable of the same name is selected as
263  * the pivot. In this case, Pe [i] >= 0.
264  *
265  * Absorbed element e: if element e is absorbed into element e2, then
266  * Pe [e] = FLIP (e2). This occurs when the pattern of e (which we
267  * refer to as Le) is found to be a subset of the pattern of e2 (that
268  * is, Le2). In this case, Pe [i] < EMPTY. If element e is "null"
269  * (it has no nonzeros outside its pivot block), then Pe [e] = EMPTY,
270  * and e is the root of an assembly subtree (or the whole tree if
271  * there is just one such root).
272  *
273  * Dense variable i: if i is "dense", then Pe [i] = EMPTY.
274  *
275  * On output, Pe holds the assembly tree/forest, which implicitly
276  * represents a pivot order with identical fill-in as the actual order
277  * (via a depth-first search of the tree), as follows. If Nv [i] > 0,
278  * then i represents a node in the assembly tree, and the parent of i is
279  * Pe [i], or EMPTY if i is a root. If Nv [i] = 0, then (i, Pe [i])
280  * represents an edge in a subtree, the root of which is a node in the
281  * assembly tree. Note that i refers to a row/column in the original
282  * matrix, not the permuted matrix.
283  *
284  * Info: A double array of size AMD_INFO. If present, (that is, not NULL),
285  * then statistics about the ordering are returned in the Info array.
286  * See amd.h for a description.
287 
288  * ----------------------------------------------------------------------------
289  * INPUT/MODIFIED (undefined on output):
290  * ----------------------------------------------------------------------------
291  *
292  * Len: An integer array of size n. On input, Len [i] holds the number of
293  * entries in row i of the matrix, excluding the diagonal. The contents
294  * of Len are undefined on output.
295  *
296  * Iw: An integer array of size iwlen. On input, Iw [0..pfree-1] holds the
297  * description of each row i in the matrix. The matrix must be symmetric,
298  * and both upper and lower triangular parts must be present. The
299  * diagonal must not be present. Row i is held as follows:
300  *
301  * Len [i]: the length of the row i data structure in the Iw array.
302  * Iw [Pe [i] ... Pe [i] + Len [i] - 1]:
303  * the list of column indices for nonzeros in row i (simple
304  * supervariables), excluding the diagonal. All supervariables
305  * start with one row/column each (supervariable i is just row i).
306  * If Len [i] is zero on input, then Pe [i] is ignored on input.
307  *
308  * Note that the rows need not be in any particular order, and there
309  * may be empty space between the rows.
310  *
311  * During execution, the supervariable i experiences fill-in. This is
312  * represented by placing in i a list of the elements that cause fill-in
313  * in supervariable i:
314  *
315  * Len [i]: the length of supervariable i in the Iw array.
316  * Iw [Pe [i] ... Pe [i] + Elen [i] - 1]:
317  * the list of elements that contain i. This list is kept short
318  * by removing absorbed elements.
319  * Iw [Pe [i] + Elen [i] ... Pe [i] + Len [i] - 1]:
320  * the list of supervariables in i. This list is kept short by
321  * removing nonprincipal variables, and any entry j that is also
322  * contained in at least one of the elements (j in Le) in the list
323  * for i (e in row i).
324  *
325  * When supervariable i is selected as pivot, we create an element e of
326  * the same name (e=i):
327  *
328  * Len [e]: the length of element e in the Iw array.
329  * Iw [Pe [e] ... Pe [e] + Len [e] - 1]:
330  * the list of supervariables in element e.
331  *
332  * An element represents the fill-in that occurs when supervariable i is
333  * selected as pivot (which represents the selection of row i and all
334  * non-principal variables whose principal variable is i). We use the
335  * term Le to denote the set of all supervariables in element e. Absorbed
336  * supervariables and elements are pruned from these lists when
337  * computationally convenient.
338  *
339  * CAUTION: THE INPUT MATRIX IS OVERWRITTEN DURING COMPUTATION.
340  * The contents of Iw are undefined on output.
341 
342  * ----------------------------------------------------------------------------
343  * OUTPUT (need not be set on input):
344  * ----------------------------------------------------------------------------
345  *
346  * Nv: An integer array of size n. During execution, ABS (Nv [i]) is equal to
347  * the number of rows that are represented by the principal supervariable
348  * i. If i is a nonprincipal or dense variable, then Nv [i] = 0.
349  * Initially, Nv [i] = 1 for all i. Nv [i] < 0 signifies that i is a
350  * principal variable in the pattern Lme of the current pivot element me.
351  * After element me is constructed, Nv [i] is set back to a positive
352  * value.
353  *
354  * On output, Nv [i] holds the number of pivots represented by super
355  * row/column i of the original matrix, or Nv [i] = 0 for non-principal
356  * rows/columns. Note that i refers to a row/column in the original
357  * matrix, not the permuted matrix.
358  *
359  * Elen: An integer array of size n. See the description of Iw above. At the
360  * start of execution, Elen [i] is set to zero for all rows i. During
361  * execution, Elen [i] is the number of elements in the list for
362  * supervariable i. When e becomes an element, Elen [e] = FLIP (esize) is
363  * set, where esize is the size of the element (the number of pivots, plus
364  * the number of nonpivotal entries). Thus Elen [e] < EMPTY.
365  * Elen (i) = EMPTY set when variable i becomes nonprincipal.
366  *
367  * For variables, Elen (i) >= EMPTY holds until just before the
368  * postordering and permutation vectors are computed. For elements,
369  * Elen [e] < EMPTY holds.
370  *
371  * On output, Elen [i] is the degree of the row/column in the Cholesky
372  * factorization of the permuted matrix, corresponding to the original row
373  * i, if i is a super row/column. It is equal to EMPTY if i is
374  * non-principal. Note that i refers to a row/column in the original
375  * matrix, not the permuted matrix.
376  *
377  * Note that the contents of Elen on output differ from the Fortran
378  * version (Elen holds the inverse permutation in the Fortran version,
379  * which is instead returned in the Next array in this C version,
380  * described below).
381  *
382  * Last: In a degree list, Last [i] is the supervariable preceding i, or EMPTY
383  * if i is the head of the list. In a hash bucket, Last [i] is the hash
384  * key for i.
385  *
386  * Last [Head [hash]] is also used as the head of a hash bucket if
387  * Head [hash] contains a degree list (see the description of Head,
388  * below).
389  *
390  * On output, Last [0..n-1] holds the permutation. That is, if
391  * i = Last [k], then row i is the kth pivot row (where k ranges from 0 to
392  * n-1). Row Last [k] of A is the kth row in the permuted matrix, PAP'.
393  *
394  * Next: Next [i] is the supervariable following i in a link list, or EMPTY if
395  * i is the last in the list. Used for two kinds of lists: degree lists
396  * and hash buckets (a supervariable can be in only one kind of list at a
397  * time).
398  *
399  * On output Next [0..n-1] holds the inverse permutation. That is, if
400  * k = Next [i], then row i is the kth pivot row. Row i of A appears as
401  * the (Next[i])-th row in the permuted matrix, PAP'.
402  *
403  * Note that the contents of Next on output differ from the Fortran
404  * version (Next is undefined on output in the Fortran version).
405 
406  * ----------------------------------------------------------------------------
407  * LOCAL WORKSPACE (not input or output - used only during execution):
408  * ----------------------------------------------------------------------------
409  *
410  * Degree: An integer array of size n. If i is a supervariable, then
411  * Degree [i] holds the current approximation of the external degree of
412  * row i (an upper bound). The external degree is the number of nonzeros
413  * in row i, minus ABS (Nv [i]), the diagonal part. The bound is equal to
414  * the exact external degree if Elen [i] is less than or equal to two.
415  *
416  * We also use the term "external degree" for elements e to refer to
417  * |Le \ Lme|. If e is an element, then Degree [e] is |Le|, which is the
418  * degree of the off-diagonal part of the element e (not including the
419  * diagonal part).
420  *
421  * Head: An integer array of size n. Head is used for degree lists.
422  * Head [deg] is the first supervariable in a degree list. All
423  * supervariables i in a degree list Head [deg] have the same approximate
424  * degree, namely, deg = Degree [i]. If the list Head [deg] is empty then
425  * Head [deg] = EMPTY.
426  *
427  * During supervariable detection Head [hash] also serves as a pointer to
428  * a hash bucket. If Head [hash] >= 0, there is a degree list of degree
429  * hash. The hash bucket head pointer is Last [Head [hash]]. If
430  * Head [hash] = EMPTY, then the degree list and hash bucket are both
431  * empty. If Head [hash] < EMPTY, then the degree list is empty, and
432  * FLIP (Head [hash]) is the head of the hash bucket. After supervariable
433  * detection is complete, all hash buckets are empty, and the
434  * (Last [Head [hash]] = EMPTY) condition is restored for the non-empty
435  * degree lists.
436  *
437  * W: An integer array of size n. The flag array W determines the status of
438  * elements and variables, and the external degree of elements.
439  *
440  * for elements:
441  * if W [e] = 0, then the element e is absorbed.
442  * if W [e] >= wflg, then W [e] - wflg is the size of the set
443  * |Le \ Lme|, in terms of nonzeros (the sum of ABS (Nv [i]) for
444  * each principal variable i that is both in the pattern of
445  * element e and NOT in the pattern of the current pivot element,
446  * me).
447  * if wflg > W [e] > 0, then e is not absorbed and has not yet been
448  * seen in the scan of the element lists in the computation of
449  * |Le\Lme| in Scan 1 below.
450  *
451  * for variables:
452  * during supervariable detection, if W [j] != wflg then j is
453  * not in the pattern of variable i.
454  *
455  * The W array is initialized by setting W [i] = 1 for all i, and by
456  * setting wflg = 2. It is reinitialized if wflg becomes too large (to
457  * ensure that wflg+n does not cause integer overflow).
458 
459  * ----------------------------------------------------------------------------
460  * LOCAL INTEGERS:
461  * ----------------------------------------------------------------------------
462  */
463 
464  Int deg, degme, dext, lemax, e, elenme, eln, i, ilast, inext, j,
465  jlast, jnext, k, knt1, knt2, knt3, lenj, ln, me, mindeg, nel, nleft,
466  nvi, nvj, nvpiv, slenme, wbig, we, wflg, wnvi, ok, ndense, ncmpa,
467  dense, aggressive ;
468 
469  unsigned Int hash ; /* unsigned, so that hash % n is well defined.*/
470 
471 /*
472  * deg: the degree of a variable or element
473  * degme: size, |Lme|, of the current element, me (= Degree [me])
474  * dext: external degree, |Le \ Lme|, of some element e
475  * lemax: largest |Le| seen so far (called dmax in Fortran version)
476  * e: an element
477  * elenme: the length, Elen [me], of element list of pivotal variable
478  * eln: the length, Elen [...], of an element list
479  * hash: the computed value of the hash function
480  * i: a supervariable
481  * ilast: the entry in a link list preceding i
482  * inext: the entry in a link list following i
483  * j: a supervariable
484  * jlast: the entry in a link list preceding j
485  * jnext: the entry in a link list, or path, following j
486  * k: the pivot order of an element or variable
487  * knt1: loop counter used during element construction
488  * knt2: loop counter used during element construction
489  * knt3: loop counter used during compression
490  * lenj: Len [j]
491  * ln: length of a supervariable list
492  * me: current supervariable being eliminated, and the current
493  * element created by eliminating that supervariable
494  * mindeg: current minimum degree
495  * nel: number of pivots selected so far
496  * nleft: n - nel, the number of nonpivotal rows/columns remaining
497  * nvi: the number of variables in a supervariable i (= Nv [i])
498  * nvj: the number of variables in a supervariable j (= Nv [j])
499  * nvpiv: number of pivots in current element
500  * slenme: number of variables in variable list of pivotal variable
501  * wbig: = INT_MAX - n for the int version, UF_long_max - n for the
502  * UF_long version. wflg is not allowed to be >= wbig.
503  * we: W [e]
504  * wflg: used for flagging the W array. See description of Iw.
505  * wnvi: wflg - Nv [i]
506  * x: either a supervariable or an element
507  *
508  * ok: true if supervariable j can be absorbed into i
509  * ndense: number of "dense" rows/columns
510  * dense: rows/columns with initial degree > dense are considered "dense"
511  * aggressive: true if aggressive absorption is being performed
512  * ncmpa: number of garbage collections
513 
514  * ----------------------------------------------------------------------------
515  * LOCAL DOUBLES, used for statistical output only (except for alpha):
516  * ----------------------------------------------------------------------------
517  */
518 
519  double f, r, ndiv, s, nms_lu, nms_ldl, dmax, alpha, lnz, lnzme ;
520 
521 /*
522  * f: nvpiv
523  * r: degme + nvpiv
524  * ndiv: number of divisions for LU or LDL' factorizations
525  * s: number of multiply-subtract pairs for LU factorization, for the
526  * current element me
527  * nms_lu number of multiply-subtract pairs for LU factorization
528  * nms_ldl number of multiply-subtract pairs for LDL' factorization
529  * dmax: the largest number of entries in any column of L, including the
530  * diagonal
531  * alpha: "dense" degree ratio
532  * lnz: the number of nonzeros in L (excluding the diagonal)
533  * lnzme: the number of nonzeros in L (excl. the diagonal) for the
534  * current element me
535 
536  * ----------------------------------------------------------------------------
537  * LOCAL "POINTERS" (indices into the Iw array)
538  * ----------------------------------------------------------------------------
539 */
540 
541  Int p, p1, p2, p3, p4, pdst, pend, pj, pme, pme1, pme2, pn, psrc ;
542 
543 /*
544  * Any parameter (Pe [...] or pfree) or local variable starting with "p" (for
545  * Pointer) is an index into Iw, and all indices into Iw use variables starting
546  * with "p." The only exception to this rule is the iwlen input argument.
547  *
548  * p: pointer into lots of things
549  * p1: Pe [i] for some variable i (start of element list)
550  * p2: Pe [i] + Elen [i] - 1 for some variable i
551  * p3: index of first supervariable in clean list
552  * p4:
553  * pdst: destination pointer, for compression
554  * pend: end of memory to compress
555  * pj: pointer into an element or variable
556  * pme: pointer into the current element (pme1...pme2)
557  * pme1: the current element, me, is stored in Iw [pme1...pme2]
558  * pme2: the end of the current element
559  * pn: pointer into a "clean" variable, also used to compress
560  * psrc: source pointer, for compression
561 */
562 
563 /* ========================================================================= */
564 /* INITIALIZATIONS */
565 /* ========================================================================= */
566 
567  /* Note that this restriction on iwlen is slightly more restrictive than
568  * what is actually required in AMD_2. AMD_2 can operate with no elbow
569  * room at all, but it will be slow. For better performance, at least
570  * size-n elbow room is enforced. */
571  ASSERT (iwlen >= pfree + n) ;
572  ASSERT (n > 0) ;
573 
574  /* initialize output statistics */
575  lnz = 0 ;
576  ndiv = 0 ;
577  nms_lu = 0 ;
578  nms_ldl = 0 ;
579  dmax = 1 ;
580  me = EMPTY ;
581 
582  mindeg = 0 ;
583  ncmpa = 0 ;
584  nel = 0 ;
585  lemax = 0 ;
586 
587  /* get control parameters */
588  if (Control != (double *) NULL)
589  {
590  alpha = Control [AMD_DENSE] ;
591  aggressive = (Control [AMD_AGGRESSIVE] != 0) ;
592  }
593  else
594  {
595  alpha = AMD_DEFAULT_DENSE ;
596  aggressive = AMD_DEFAULT_AGGRESSIVE ;
597  }
598  /* Note: if alpha is NaN, this is undefined: */
599  if (alpha < 0)
600  {
601  /* only remove completely dense rows/columns */
602  dense = n-2 ;
603  }
604  else
605  {
606  dense = alpha * sqrt ((double) n) ;
607  }
608  dense = MAX (16, dense) ;
609  dense = MIN (n, dense) ;
610  AMD_DEBUG1 (("\n\nAMD (debug), alpha %g, aggr. "ID"\n",
611  alpha, aggressive)) ;
612 
613  for (i = 0 ; i < n ; i++)
614  {
615  Last [i] = EMPTY ;
616  Head [i] = EMPTY ;
617  Next [i] = EMPTY ;
618  /* if separate Hhead array is used for hash buckets: *
619  Hhead [i] = EMPTY ;
620  */
621  Nv [i] = 1 ;
622  W [i] = 1 ;
623  Elen [i] = 0 ;
624  Degree [i] = Len [i] ;
625  }
626 
627 #ifndef NDEBUG
628  AMD_DEBUG1 (("\n======Nel "ID" initial\n", nel)) ;
629  AMD_dump (n, Pe, Iw, Len, iwlen, pfree, Nv, Next, Last,
630  Head, Elen, Degree, W, -1) ;
631 #endif
632 
633  /* initialize wflg */
634  wbig = Int_MAX - n ;
635  wflg = amesos_clear_flag (0, wbig, W, n) ;
636 
637  /* --------------------------------------------------------------------- */
638  /* initialize degree lists and eliminate dense and empty rows */
639  /* --------------------------------------------------------------------- */
640 
641  ndense = 0 ;
642 
643  for (i = 0 ; i < n ; i++)
644  {
645  deg = Degree [i] ;
646  ASSERT (deg >= 0 && deg < n) ;
647  if (deg == 0)
648  {
649 
650  /* -------------------------------------------------------------
651  * we have a variable that can be eliminated at once because
652  * there is no off-diagonal non-zero in its row. Note that
653  * Nv [i] = 1 for an empty variable i. It is treated just
654  * the same as an eliminated element i.
655  * ------------------------------------------------------------- */
656 
657  Elen [i] = FLIP (1) ;
658  nel++ ;
659  Pe [i] = EMPTY ;
660  W [i] = 0 ;
661 
662  }
663  else if (deg > dense)
664  {
665 
666  /* -------------------------------------------------------------
667  * Dense variables are not treated as elements, but as unordered,
668  * non-principal variables that have no parent. They do not take
669  * part in the postorder, since Nv [i] = 0. Note that the Fortran
670  * version does not have this option.
671  * ------------------------------------------------------------- */
672 
673  AMD_DEBUG1 (("Dense node "ID" degree "ID"\n", i, deg)) ;
674  ndense++ ;
675  Nv [i] = 0 ; /* do not postorder this node */
676  Elen [i] = EMPTY ;
677  nel++ ;
678  Pe [i] = EMPTY ;
679 
680  }
681  else
682  {
683 
684  /* -------------------------------------------------------------
685  * place i in the degree list corresponding to its degree
686  * ------------------------------------------------------------- */
687 
688  inext = Head [deg] ;
689  ASSERT (inext >= EMPTY && inext < n) ;
690  if (inext != EMPTY) Last [inext] = i ;
691  Next [i] = inext ;
692  Head [deg] = i ;
693 
694  }
695  }
696 
697 /* ========================================================================= */
698 /* WHILE (selecting pivots) DO */
699 /* ========================================================================= */
700 
701  while (nel < n)
702  {
703 
704 #ifndef NDEBUG
705  AMD_DEBUG1 (("\n======Nel "ID"\n", nel)) ;
706  if (AMD_debug >= 2)
707  {
708  AMD_dump (n, Pe, Iw, Len, iwlen, pfree, Nv, Next,
709  Last, Head, Elen, Degree, W, nel) ;
710  }
711 #endif
712 
713 /* ========================================================================= */
714 /* GET PIVOT OF MINIMUM DEGREE */
715 /* ========================================================================= */
716 
717  /* ----------------------------------------------------------------- */
718  /* find next supervariable for elimination */
719  /* ----------------------------------------------------------------- */
720 
721  ASSERT (mindeg >= 0 && mindeg < n) ;
722  for (deg = mindeg ; deg < n ; deg++)
723  {
724  me = Head [deg] ;
725  if (me != EMPTY) break ;
726  }
727  mindeg = deg ;
728  ASSERT (me >= 0 && me < n) ;
729  AMD_DEBUG1 (("=================me: "ID"\n", me)) ;
730 
731  /* ----------------------------------------------------------------- */
732  /* remove chosen variable from link list */
733  /* ----------------------------------------------------------------- */
734 
735  inext = Next [me] ;
736  ASSERT (inext >= EMPTY && inext < n) ;
737  if (inext != EMPTY) Last [inext] = EMPTY ;
738  Head [deg] = inext ;
739 
740  /* ----------------------------------------------------------------- */
741  /* me represents the elimination of pivots nel to nel+Nv[me]-1. */
742  /* place me itself as the first in this set. */
743  /* ----------------------------------------------------------------- */
744 
745  elenme = Elen [me] ;
746  nvpiv = Nv [me] ;
747  ASSERT (nvpiv > 0) ;
748  nel += nvpiv ;
749 
750 /* ========================================================================= */
751 /* CONSTRUCT NEW ELEMENT */
752 /* ========================================================================= */
753 
754  /* -----------------------------------------------------------------
755  * At this point, me is the pivotal supervariable. It will be
756  * converted into the current element. Scan list of the pivotal
757  * supervariable, me, setting tree pointers and constructing new list
758  * of supervariables for the new element, me. p is a pointer to the
759  * current position in the old list.
760  * ----------------------------------------------------------------- */
761 
762  /* flag the variable "me" as being in Lme by negating Nv [me] */
763  Nv [me] = -nvpiv ;
764  degme = 0 ;
765  ASSERT (Pe [me] >= 0 && Pe [me] < iwlen) ;
766 
767  if (elenme == 0)
768  {
769 
770  /* ------------------------------------------------------------- */
771  /* construct the new element in place */
772  /* ------------------------------------------------------------- */
773 
774  pme1 = Pe [me] ;
775  pme2 = pme1 - 1 ;
776 
777  for (p = pme1 ; p <= pme1 + Len [me] - 1 ; p++)
778  {
779  i = Iw [p] ;
780  ASSERT (i >= 0 && i < n && Nv [i] >= 0) ;
781  nvi = Nv [i] ;
782  if (nvi > 0)
783  {
784 
785  /* ----------------------------------------------------- */
786  /* i is a principal variable not yet placed in Lme. */
787  /* store i in new list */
788  /* ----------------------------------------------------- */
789 
790  /* flag i as being in Lme by negating Nv [i] */
791  degme += nvi ;
792  Nv [i] = -nvi ;
793  Iw [++pme2] = i ;
794 
795  /* ----------------------------------------------------- */
796  /* remove variable i from degree list. */
797  /* ----------------------------------------------------- */
798 
799  ilast = Last [i] ;
800  inext = Next [i] ;
801  ASSERT (ilast >= EMPTY && ilast < n) ;
802  ASSERT (inext >= EMPTY && inext < n) ;
803  if (inext != EMPTY) Last [inext] = ilast ;
804  if (ilast != EMPTY)
805  {
806  Next [ilast] = inext ;
807  }
808  else
809  {
810  /* i is at the head of the degree list */
811  ASSERT (Degree [i] >= 0 && Degree [i] < n) ;
812  Head [Degree [i]] = inext ;
813  }
814  }
815  }
816  }
817  else
818  {
819 
820  /* ------------------------------------------------------------- */
821  /* construct the new element in empty space, Iw [pfree ...] */
822  /* ------------------------------------------------------------- */
823 
824  p = Pe [me] ;
825  pme1 = pfree ;
826  slenme = Len [me] - elenme ;
827 
828  for (knt1 = 1 ; knt1 <= elenme + 1 ; knt1++)
829  {
830 
831  if (knt1 > elenme)
832  {
833  /* search the supervariables in me. */
834  e = me ;
835  pj = p ;
836  ln = slenme ;
837  AMD_DEBUG2 (("Search sv: "ID" "ID" "ID"\n", me,pj,ln)) ;
838  }
839  else
840  {
841  /* search the elements in me. */
842  e = Iw [p++] ;
843  ASSERT (e >= 0 && e < n) ;
844  pj = Pe [e] ;
845  ln = Len [e] ;
846  AMD_DEBUG2 (("Search element e "ID" in me "ID"\n", e,me)) ;
847  ASSERT (Elen [e] < EMPTY && W [e] > 0 && pj >= 0) ;
848  }
849  ASSERT (ln >= 0 && (ln == 0 || (pj >= 0 && pj < iwlen))) ;
850 
851  /* ---------------------------------------------------------
852  * search for different supervariables and add them to the
853  * new list, compressing when necessary. this loop is
854  * executed once for each element in the list and once for
855  * all the supervariables in the list.
856  * --------------------------------------------------------- */
857 
858  for (knt2 = 1 ; knt2 <= ln ; knt2++)
859  {
860  i = Iw [pj++] ;
861  ASSERT (i >= 0 && i < n && (i == me || Elen [i] >= EMPTY));
862  nvi = Nv [i] ;
863  AMD_DEBUG2 ((": "ID" "ID" "ID" "ID"\n",
864  i, Elen [i], Nv [i], wflg)) ;
865 
866  if (nvi > 0)
867  {
868 
869  /* ------------------------------------------------- */
870  /* compress Iw, if necessary */
871  /* ------------------------------------------------- */
872 
873  if (pfree >= iwlen)
874  {
875 
876  AMD_DEBUG1 (("GARBAGE COLLECTION\n")) ;
877 
878  /* prepare for compressing Iw by adjusting pointers
879  * and lengths so that the lists being searched in
880  * the inner and outer loops contain only the
881  * remaining entries. */
882 
883  Pe [me] = p ;
884  Len [me] -= knt1 ;
885  /* check if nothing left of supervariable me */
886  if (Len [me] == 0) Pe [me] = EMPTY ;
887  Pe [e] = pj ;
888  Len [e] = ln - knt2 ;
889  /* nothing left of element e */
890  if (Len [e] == 0) Pe [e] = EMPTY ;
891 
892  ncmpa++ ; /* one more garbage collection */
893 
894  /* store first entry of each object in Pe */
895  /* FLIP the first entry in each object */
896  for (j = 0 ; j < n ; j++)
897  {
898  pn = Pe [j] ;
899  if (pn >= 0)
900  {
901  ASSERT (pn >= 0 && pn < iwlen) ;
902  Pe [j] = Iw [pn] ;
903  Iw [pn] = FLIP (j) ;
904  }
905  }
906 
907  /* psrc/pdst point to source/destination */
908  psrc = 0 ;
909  pdst = 0 ;
910  pend = pme1 - 1 ;
911 
912  while (psrc <= pend)
913  {
914  /* search for next FLIP'd entry */
915  j = FLIP (Iw [psrc++]) ;
916  if (j >= 0)
917  {
918  AMD_DEBUG2 (("Got object j: "ID"\n", j)) ;
919  Iw [pdst] = Pe [j] ;
920  Pe [j] = pdst++ ;
921  lenj = Len [j] ;
922  /* copy from source to destination */
923  for (knt3 = 0 ; knt3 <= lenj - 2 ; knt3++)
924  {
925  Iw [pdst++] = Iw [psrc++] ;
926  }
927  }
928  }
929 
930  /* move the new partially-constructed element */
931  p1 = pdst ;
932  for (psrc = pme1 ; psrc <= pfree-1 ; psrc++)
933  {
934  Iw [pdst++] = Iw [psrc] ;
935  }
936  pme1 = p1 ;
937  pfree = pdst ;
938  pj = Pe [e] ;
939  p = Pe [me] ;
940 
941  }
942 
943  /* ------------------------------------------------- */
944  /* i is a principal variable not yet placed in Lme */
945  /* store i in new list */
946  /* ------------------------------------------------- */
947 
948  /* flag i as being in Lme by negating Nv [i] */
949  degme += nvi ;
950  Nv [i] = -nvi ;
951  Iw [pfree++] = i ;
952  AMD_DEBUG2 ((" s: "ID" nv "ID"\n", i, Nv [i]));
953 
954  /* ------------------------------------------------- */
955  /* remove variable i from degree link list */
956  /* ------------------------------------------------- */
957 
958  ilast = Last [i] ;
959  inext = Next [i] ;
960  ASSERT (ilast >= EMPTY && ilast < n) ;
961  ASSERT (inext >= EMPTY && inext < n) ;
962  if (inext != EMPTY) Last [inext] = ilast ;
963  if (ilast != EMPTY)
964  {
965  Next [ilast] = inext ;
966  }
967  else
968  {
969  /* i is at the head of the degree list */
970  ASSERT (Degree [i] >= 0 && Degree [i] < n) ;
971  Head [Degree [i]] = inext ;
972  }
973  }
974  }
975 
976  if (e != me)
977  {
978  /* set tree pointer and flag to indicate element e is
979  * absorbed into new element me (the parent of e is me) */
980  AMD_DEBUG1 ((" Element "ID" => "ID"\n", e, me)) ;
981  Pe [e] = FLIP (me) ;
982  W [e] = 0 ;
983  }
984  }
985 
986  pme2 = pfree - 1 ;
987  }
988 
989  /* ----------------------------------------------------------------- */
990  /* me has now been converted into an element in Iw [pme1..pme2] */
991  /* ----------------------------------------------------------------- */
992 
993  /* degme holds the external degree of new element */
994  Degree [me] = degme ;
995  Pe [me] = pme1 ;
996  Len [me] = pme2 - pme1 + 1 ;
997  ASSERT (Pe [me] >= 0 && Pe [me] < iwlen) ;
998 
999  Elen [me] = FLIP (nvpiv + degme) ;
1000  /* FLIP (Elen (me)) is now the degree of pivot (including
1001  * diagonal part). */
1002 
1003 #ifndef NDEBUG
1004  AMD_DEBUG2 (("New element structure: length= "ID"\n", pme2-pme1+1)) ;
1005  for (pme = pme1 ; pme <= pme2 ; pme++) AMD_DEBUG3 ((" "ID"", Iw[pme]));
1006  AMD_DEBUG3 (("\n")) ;
1007 #endif
1008 
1009  /* ----------------------------------------------------------------- */
1010  /* make sure that wflg is not too large. */
1011  /* ----------------------------------------------------------------- */
1012 
1013  /* With the current value of wflg, wflg+n must not cause integer
1014  * overflow */
1015 
1016  wflg = amesos_clear_flag (wflg, wbig, W, n) ;
1017 
1018 /* ========================================================================= */
1019 /* COMPUTE (W [e] - wflg) = |Le\Lme| FOR ALL ELEMENTS */
1020 /* ========================================================================= */
1021 
1022  /* -----------------------------------------------------------------
1023  * Scan 1: compute the external degrees of previous elements with
1024  * respect to the current element. That is:
1025  * (W [e] - wflg) = |Le \ Lme|
1026  * for each element e that appears in any supervariable in Lme. The
1027  * notation Le refers to the pattern (list of supervariables) of a
1028  * previous element e, where e is not yet absorbed, stored in
1029  * Iw [Pe [e] + 1 ... Pe [e] + Len [e]]. The notation Lme
1030  * refers to the pattern of the current element (stored in
1031  * Iw [pme1..pme2]). If aggressive absorption is enabled, and
1032  * (W [e] - wflg) becomes zero, then the element e will be absorbed
1033  * in Scan 2.
1034  * ----------------------------------------------------------------- */
1035 
1036  AMD_DEBUG2 (("me: ")) ;
1037  for (pme = pme1 ; pme <= pme2 ; pme++)
1038  {
1039  i = Iw [pme] ;
1040  ASSERT (i >= 0 && i < n) ;
1041  eln = Elen [i] ;
1042  AMD_DEBUG3 ((""ID" Elen "ID": \n", i, eln)) ;
1043  if (eln > 0)
1044  {
1045  /* note that Nv [i] has been negated to denote i in Lme: */
1046  nvi = -Nv [i] ;
1047  ASSERT (nvi > 0 && Pe [i] >= 0 && Pe [i] < iwlen) ;
1048  wnvi = wflg - nvi ;
1049  for (p = Pe [i] ; p <= Pe [i] + eln - 1 ; p++)
1050  {
1051  e = Iw [p] ;
1052  ASSERT (e >= 0 && e < n) ;
1053  we = W [e] ;
1054  AMD_DEBUG4 ((" e "ID" we "ID" ", e, we)) ;
1055  if (we >= wflg)
1056  {
1057  /* unabsorbed element e has been seen in this loop */
1058  AMD_DEBUG4 ((" unabsorbed, first time seen")) ;
1059  we -= nvi ;
1060  }
1061  else if (we != 0)
1062  {
1063  /* e is an unabsorbed element */
1064  /* this is the first we have seen e in all of Scan 1 */
1065  AMD_DEBUG4 ((" unabsorbed")) ;
1066  we = Degree [e] + wnvi ;
1067  }
1068  AMD_DEBUG4 (("\n")) ;
1069  W [e] = we ;
1070  }
1071  }
1072  }
1073  AMD_DEBUG2 (("\n")) ;
1074 
1075 /* ========================================================================= */
1076 /* DEGREE UPDATE AND ELEMENT ABSORPTION */
1077 /* ========================================================================= */
1078 
1079  /* -----------------------------------------------------------------
1080  * Scan 2: for each i in Lme, sum up the degree of Lme (which is
1081  * degme), plus the sum of the external degrees of each Le for the
1082  * elements e appearing within i, plus the supervariables in i.
1083  * Place i in hash list.
1084  * ----------------------------------------------------------------- */
1085 
1086  for (pme = pme1 ; pme <= pme2 ; pme++)
1087  {
1088  i = Iw [pme] ;
1089  ASSERT (i >= 0 && i < n && Nv [i] < 0 && Elen [i] >= 0) ;
1090  AMD_DEBUG2 (("Updating: i "ID" "ID" "ID"\n", i, Elen[i], Len [i]));
1091  p1 = Pe [i] ;
1092  p2 = p1 + Elen [i] - 1 ;
1093  pn = p1 ;
1094  hash = 0 ;
1095  deg = 0 ;
1096  ASSERT (p1 >= 0 && p1 < iwlen && p2 >= -1 && p2 < iwlen) ;
1097 
1098  /* ------------------------------------------------------------- */
1099  /* scan the element list associated with supervariable i */
1100  /* ------------------------------------------------------------- */
1101 
1102  /* UMFPACK/MA38-style approximate degree: */
1103  if (aggressive)
1104  {
1105  for (p = p1 ; p <= p2 ; p++)
1106  {
1107  e = Iw [p] ;
1108  ASSERT (e >= 0 && e < n) ;
1109  we = W [e] ;
1110  if (we != 0)
1111  {
1112  /* e is an unabsorbed element */
1113  /* dext = | Le \ Lme | */
1114  dext = we - wflg ;
1115  if (dext > 0)
1116  {
1117  deg += dext ;
1118  Iw [pn++] = e ;
1119  hash += e ;
1120  AMD_DEBUG4 ((" e: "ID" hash = "ID"\n",e,hash)) ;
1121  }
1122  else
1123  {
1124  /* external degree of e is zero, absorb e into me*/
1125  AMD_DEBUG1 ((" Element "ID" =>"ID" (aggressive)\n",
1126  e, me)) ;
1127  ASSERT (dext == 0) ;
1128  Pe [e] = FLIP (me) ;
1129  W [e] = 0 ;
1130  }
1131  }
1132  }
1133  }
1134  else
1135  {
1136  for (p = p1 ; p <= p2 ; p++)
1137  {
1138  e = Iw [p] ;
1139  ASSERT (e >= 0 && e < n) ;
1140  we = W [e] ;
1141  if (we != 0)
1142  {
1143  /* e is an unabsorbed element */
1144  dext = we - wflg ;
1145  ASSERT (dext >= 0) ;
1146  deg += dext ;
1147  Iw [pn++] = e ;
1148  hash += e ;
1149  AMD_DEBUG4 ((" e: "ID" hash = "ID"\n",e,hash)) ;
1150  }
1151  }
1152  }
1153 
1154  /* count the number of elements in i (including me): */
1155  Elen [i] = pn - p1 + 1 ;
1156 
1157  /* ------------------------------------------------------------- */
1158  /* scan the supervariables in the list associated with i */
1159  /* ------------------------------------------------------------- */
1160 
1161  /* The bulk of the AMD run time is typically spent in this loop,
1162  * particularly if the matrix has many dense rows that are not
1163  * removed prior to ordering. */
1164  p3 = pn ;
1165  p4 = p1 + Len [i] ;
1166  for (p = p2 + 1 ; p < p4 ; p++)
1167  {
1168  j = Iw [p] ;
1169  ASSERT (j >= 0 && j < n) ;
1170  nvj = Nv [j] ;
1171  if (nvj > 0)
1172  {
1173  /* j is unabsorbed, and not in Lme. */
1174  /* add to degree and add to new list */
1175  deg += nvj ;
1176  Iw [pn++] = j ;
1177  hash += j ;
1178  AMD_DEBUG4 ((" s: "ID" hash "ID" Nv[j]= "ID"\n",
1179  j, hash, nvj)) ;
1180  }
1181  }
1182 
1183  /* ------------------------------------------------------------- */
1184  /* update the degree and check for mass elimination */
1185  /* ------------------------------------------------------------- */
1186 
1187  /* with aggressive absorption, deg==0 is identical to the
1188  * Elen [i] == 1 && p3 == pn test, below. */
1189  ASSERT (IMPLIES (aggressive, (deg==0) == (Elen[i]==1 && p3==pn))) ;
1190 
1191  if (Elen [i] == 1 && p3 == pn)
1192  {
1193 
1194  /* --------------------------------------------------------- */
1195  /* mass elimination */
1196  /* --------------------------------------------------------- */
1197 
1198  /* There is nothing left of this node except for an edge to
1199  * the current pivot element. Elen [i] is 1, and there are
1200  * no variables adjacent to node i. Absorb i into the
1201  * current pivot element, me. Note that if there are two or
1202  * more mass eliminations, fillin due to mass elimination is
1203  * possible within the nvpiv-by-nvpiv pivot block. It is this
1204  * step that causes AMD's analysis to be an upper bound.
1205  *
1206  * The reason is that the selected pivot has a lower
1207  * approximate degree than the true degree of the two mass
1208  * eliminated nodes. There is no edge between the two mass
1209  * eliminated nodes. They are merged with the current pivot
1210  * anyway.
1211  *
1212  * No fillin occurs in the Schur complement, in any case,
1213  * and this effect does not decrease the quality of the
1214  * ordering itself, just the quality of the nonzero and
1215  * flop count analysis. It also means that the post-ordering
1216  * is not an exact elimination tree post-ordering. */
1217 
1218  AMD_DEBUG1 ((" MASS i "ID" => parent e "ID"\n", i, me)) ;
1219  Pe [i] = FLIP (me) ;
1220  nvi = -Nv [i] ;
1221  degme -= nvi ;
1222  nvpiv += nvi ;
1223  nel += nvi ;
1224  Nv [i] = 0 ;
1225  Elen [i] = EMPTY ;
1226 
1227  }
1228  else
1229  {
1230 
1231  /* --------------------------------------------------------- */
1232  /* update the upper-bound degree of i */
1233  /* --------------------------------------------------------- */
1234 
1235  /* the following degree does not yet include the size
1236  * of the current element, which is added later: */
1237 
1238  Degree [i] = MIN (Degree [i], deg) ;
1239 
1240  /* --------------------------------------------------------- */
1241  /* add me to the list for i */
1242  /* --------------------------------------------------------- */
1243 
1244  /* move first supervariable to end of list */
1245  Iw [pn] = Iw [p3] ;
1246  /* move first element to end of element part of list */
1247  Iw [p3] = Iw [p1] ;
1248  /* add new element, me, to front of list. */
1249  Iw [p1] = me ;
1250  /* store the new length of the list in Len [i] */
1251  Len [i] = pn - p1 + 1 ;
1252 
1253  /* --------------------------------------------------------- */
1254  /* place in hash bucket. Save hash key of i in Last [i]. */
1255  /* --------------------------------------------------------- */
1256 
1257  /* NOTE: this can fail if hash is negative, because the ANSI C
1258  * standard does not define a % b when a and/or b are negative.
1259  * That's why hash is defined as an unsigned Int, to avoid this
1260  * problem. */
1261  hash = hash % n ;
1262  ASSERT (((Int) hash) >= 0 && ((Int) hash) < n) ;
1263 
1264  /* if the Hhead array is not used: */
1265  j = Head [hash] ;
1266  if (j <= EMPTY)
1267  {
1268  /* degree list is empty, hash head is FLIP (j) */
1269  Next [i] = FLIP (j) ;
1270  Head [hash] = FLIP (i) ;
1271  }
1272  else
1273  {
1274  /* degree list is not empty, use Last [Head [hash]] as
1275  * hash head. */
1276  Next [i] = Last [j] ;
1277  Last [j] = i ;
1278  }
1279 
1280  /* if a separate Hhead array is used: *
1281  Next [i] = Hhead [hash] ;
1282  Hhead [hash] = i ;
1283  */
1284 
1285  Last [i] = hash ;
1286  }
1287  }
1288 
1289  Degree [me] = degme ;
1290 
1291  /* ----------------------------------------------------------------- */
1292  /* Clear the counter array, W [...], by incrementing wflg. */
1293  /* ----------------------------------------------------------------- */
1294 
1295  /* make sure that wflg+n does not cause integer overflow */
1296  lemax = MAX (lemax, degme) ;
1297  wflg += lemax ;
1298  wflg = amesos_clear_flag (wflg, wbig, W, n) ;
1299  /* at this point, W [0..n-1] < wflg holds */
1300 
1301 /* ========================================================================= */
1302 /* SUPERVARIABLE DETECTION */
1303 /* ========================================================================= */
1304 
1305  AMD_DEBUG1 (("Detecting supervariables:\n")) ;
1306  for (pme = pme1 ; pme <= pme2 ; pme++)
1307  {
1308  i = Iw [pme] ;
1309  ASSERT (i >= 0 && i < n) ;
1310  AMD_DEBUG2 (("Consider i "ID" nv "ID"\n", i, Nv [i])) ;
1311  if (Nv [i] < 0)
1312  {
1313  /* i is a principal variable in Lme */
1314 
1315  /* ---------------------------------------------------------
1316  * examine all hash buckets with 2 or more variables. We do
1317  * this by examing all unique hash keys for supervariables in
1318  * the pattern Lme of the current element, me
1319  * --------------------------------------------------------- */
1320 
1321  /* let i = head of hash bucket, and empty the hash bucket */
1322  ASSERT (Last [i] >= 0 && Last [i] < n) ;
1323  hash = Last [i] ;
1324 
1325  /* if Hhead array is not used: */
1326  j = Head [hash] ;
1327  if (j == EMPTY)
1328  {
1329  /* hash bucket and degree list are both empty */
1330  i = EMPTY ;
1331  }
1332  else if (j < EMPTY)
1333  {
1334  /* degree list is empty */
1335  i = FLIP (j) ;
1336  Head [hash] = EMPTY ;
1337  }
1338  else
1339  {
1340  /* degree list is not empty, restore Last [j] of head j */
1341  i = Last [j] ;
1342  Last [j] = EMPTY ;
1343  }
1344 
1345  /* if separate Hhead array is used: *
1346  i = Hhead [hash] ;
1347  Hhead [hash] = EMPTY ;
1348  */
1349 
1350  ASSERT (i >= EMPTY && i < n) ;
1351  AMD_DEBUG2 (("----i "ID" hash "ID"\n", i, hash)) ;
1352 
1353  while (i != EMPTY && Next [i] != EMPTY)
1354  {
1355 
1356  /* -----------------------------------------------------
1357  * this bucket has one or more variables following i.
1358  * scan all of them to see if i can absorb any entries
1359  * that follow i in hash bucket. Scatter i into w.
1360  * ----------------------------------------------------- */
1361 
1362  ln = Len [i] ;
1363  eln = Elen [i] ;
1364  ASSERT (ln >= 0 && eln >= 0) ;
1365  ASSERT (Pe [i] >= 0 && Pe [i] < iwlen) ;
1366  /* do not flag the first element in the list (me) */
1367  for (p = Pe [i] + 1 ; p <= Pe [i] + ln - 1 ; p++)
1368  {
1369  ASSERT (Iw [p] >= 0 && Iw [p] < n) ;
1370  W [Iw [p]] = wflg ;
1371  }
1372 
1373  /* ----------------------------------------------------- */
1374  /* scan every other entry j following i in bucket */
1375  /* ----------------------------------------------------- */
1376 
1377  jlast = i ;
1378  j = Next [i] ;
1379  ASSERT (j >= EMPTY && j < n) ;
1380 
1381  while (j != EMPTY)
1382  {
1383  /* ------------------------------------------------- */
1384  /* check if j and i have identical nonzero pattern */
1385  /* ------------------------------------------------- */
1386 
1387  AMD_DEBUG3 (("compare i "ID" and j "ID"\n", i,j)) ;
1388 
1389  /* check if i and j have the same Len and Elen */
1390  ASSERT (Len [j] >= 0 && Elen [j] >= 0) ;
1391  ASSERT (Pe [j] >= 0 && Pe [j] < iwlen) ;
1392  ok = (Len [j] == ln) && (Elen [j] == eln) ;
1393  /* skip the first element in the list (me) */
1394  for (p = Pe [j] + 1 ; ok && p <= Pe [j] + ln - 1 ; p++)
1395  {
1396  ASSERT (Iw [p] >= 0 && Iw [p] < n) ;
1397  if (W [Iw [p]] != wflg) ok = 0 ;
1398  }
1399  if (ok)
1400  {
1401  /* --------------------------------------------- */
1402  /* found it! j can be absorbed into i */
1403  /* --------------------------------------------- */
1404 
1405  AMD_DEBUG1 (("found it! j "ID" => i "ID"\n", j,i));
1406  Pe [j] = FLIP (i) ;
1407  /* both Nv [i] and Nv [j] are negated since they */
1408  /* are in Lme, and the absolute values of each */
1409  /* are the number of variables in i and j: */
1410  Nv [i] += Nv [j] ;
1411  Nv [j] = 0 ;
1412  Elen [j] = EMPTY ;
1413  /* delete j from hash bucket */
1414  ASSERT (j != Next [j]) ;
1415  j = Next [j] ;
1416  Next [jlast] = j ;
1417 
1418  }
1419  else
1420  {
1421  /* j cannot be absorbed into i */
1422  jlast = j ;
1423  ASSERT (j != Next [j]) ;
1424  j = Next [j] ;
1425  }
1426  ASSERT (j >= EMPTY && j < n) ;
1427  }
1428 
1429  /* -----------------------------------------------------
1430  * no more variables can be absorbed into i
1431  * go to next i in bucket and clear flag array
1432  * ----------------------------------------------------- */
1433 
1434  wflg++ ;
1435  i = Next [i] ;
1436  ASSERT (i >= EMPTY && i < n) ;
1437 
1438  }
1439  }
1440  }
1441  AMD_DEBUG2 (("detect done\n")) ;
1442 
1443 /* ========================================================================= */
1444 /* RESTORE DEGREE LISTS AND REMOVE NONPRINCIPAL SUPERVARIABLES FROM ELEMENT */
1445 /* ========================================================================= */
1446 
1447  p = pme1 ;
1448  nleft = n - nel ;
1449  for (pme = pme1 ; pme <= pme2 ; pme++)
1450  {
1451  i = Iw [pme] ;
1452  ASSERT (i >= 0 && i < n) ;
1453  nvi = -Nv [i] ;
1454  AMD_DEBUG3 (("Restore i "ID" "ID"\n", i, nvi)) ;
1455  if (nvi > 0)
1456  {
1457  /* i is a principal variable in Lme */
1458  /* restore Nv [i] to signify that i is principal */
1459  Nv [i] = nvi ;
1460 
1461  /* --------------------------------------------------------- */
1462  /* compute the external degree (add size of current element) */
1463  /* --------------------------------------------------------- */
1464 
1465  deg = Degree [i] + degme - nvi ;
1466  deg = MIN (deg, nleft - nvi) ;
1467  ASSERT (IMPLIES (aggressive, deg > 0) && deg >= 0 && deg < n) ;
1468 
1469  /* --------------------------------------------------------- */
1470  /* place the supervariable at the head of the degree list */
1471  /* --------------------------------------------------------- */
1472 
1473  inext = Head [deg] ;
1474  ASSERT (inext >= EMPTY && inext < n) ;
1475  if (inext != EMPTY) Last [inext] = i ;
1476  Next [i] = inext ;
1477  Last [i] = EMPTY ;
1478  Head [deg] = i ;
1479 
1480  /* --------------------------------------------------------- */
1481  /* save the new degree, and find the minimum degree */
1482  /* --------------------------------------------------------- */
1483 
1484  mindeg = MIN (mindeg, deg) ;
1485  Degree [i] = deg ;
1486 
1487  /* --------------------------------------------------------- */
1488  /* place the supervariable in the element pattern */
1489  /* --------------------------------------------------------- */
1490 
1491  Iw [p++] = i ;
1492 
1493  }
1494  }
1495  AMD_DEBUG2 (("restore done\n")) ;
1496 
1497 /* ========================================================================= */
1498 /* FINALIZE THE NEW ELEMENT */
1499 /* ========================================================================= */
1500 
1501  AMD_DEBUG2 (("ME = "ID" DONE\n", me)) ;
1502  Nv [me] = nvpiv ;
1503  /* save the length of the list for the new element me */
1504  Len [me] = p - pme1 ;
1505  if (Len [me] == 0)
1506  {
1507  /* there is nothing left of the current pivot element */
1508  /* it is a root of the assembly tree */
1509  Pe [me] = EMPTY ;
1510  W [me] = 0 ;
1511  }
1512  if (elenme != 0)
1513  {
1514  /* element was not constructed in place: deallocate part of */
1515  /* it since newly nonprincipal variables may have been removed */
1516  pfree = p ;
1517  }
1518 
1519  /* The new element has nvpiv pivots and the size of the contribution
1520  * block for a multifrontal method is degme-by-degme, not including
1521  * the "dense" rows/columns. If the "dense" rows/columns are included,
1522  * the frontal matrix is no larger than
1523  * (degme+ndense)-by-(degme+ndense).
1524  */
1525 
1526  if (Info != (double *) NULL)
1527  {
1528  f = nvpiv ;
1529  r = degme + ndense ;
1530  dmax = MAX (dmax, f + r) ;
1531 
1532  /* number of nonzeros in L (excluding the diagonal) */
1533  lnzme = f*r + (f-1)*f/2 ;
1534  lnz += lnzme ;
1535 
1536  /* number of divide operations for LDL' and for LU */
1537  ndiv += lnzme ;
1538 
1539  /* number of multiply-subtract pairs for LU */
1540  s = f*r*r + r*(f-1)*f + (f-1)*f*(2*f-1)/6 ;
1541  nms_lu += s ;
1542 
1543  /* number of multiply-subtract pairs for LDL' */
1544  nms_ldl += (s + lnzme)/2 ;
1545  }
1546 
1547 #ifndef NDEBUG
1548  AMD_DEBUG2 (("finalize done nel "ID" n "ID"\n ::::\n", nel, n)) ;
1549  for (pme = Pe [me] ; pme <= Pe [me] + Len [me] - 1 ; pme++)
1550  {
1551  AMD_DEBUG3 ((" "ID"", Iw [pme])) ;
1552  }
1553  AMD_DEBUG3 (("\n")) ;
1554 #endif
1555 
1556  }
1557 
1558 /* ========================================================================= */
1559 /* DONE SELECTING PIVOTS */
1560 /* ========================================================================= */
1561 
1562  if (Info != (double *) NULL)
1563  {
1564 
1565  /* count the work to factorize the ndense-by-ndense submatrix */
1566  f = ndense ;
1567  dmax = MAX (dmax, (double) ndense) ;
1568 
1569  /* number of nonzeros in L (excluding the diagonal) */
1570  lnzme = (f-1)*f/2 ;
1571  lnz += lnzme ;
1572 
1573  /* number of divide operations for LDL' and for LU */
1574  ndiv += lnzme ;
1575 
1576  /* number of multiply-subtract pairs for LU */
1577  s = (f-1)*f*(2*f-1)/6 ;
1578  nms_lu += s ;
1579 
1580  /* number of multiply-subtract pairs for LDL' */
1581  nms_ldl += (s + lnzme)/2 ;
1582 
1583  /* number of nz's in L (excl. diagonal) */
1584  Info [AMD_LNZ] = lnz ;
1585 
1586  /* number of divide ops for LU and LDL' */
1587  Info [AMD_NDIV] = ndiv ;
1588 
1589  /* number of multiply-subtract pairs for LDL' */
1590  Info [AMD_NMULTSUBS_LDL] = nms_ldl ;
1591 
1592  /* number of multiply-subtract pairs for LU */
1593  Info [AMD_NMULTSUBS_LU] = nms_lu ;
1594 
1595  /* number of "dense" rows/columns */
1596  Info [AMD_NDENSE] = ndense ;
1597 
1598  /* largest front is dmax-by-dmax */
1599  Info [AMD_DMAX] = dmax ;
1600 
1601  /* number of garbage collections in AMD */
1602  Info [AMD_NCMPA] = ncmpa ;
1603 
1604  /* successful ordering */
1605  Info [AMD_STATUS] = AMD_OK ;
1606  }
1607 
1608 /* ========================================================================= */
1609 /* POST-ORDERING */
1610 /* ========================================================================= */
1611 
1612 /* -------------------------------------------------------------------------
1613  * Variables at this point:
1614  *
1615  * Pe: holds the elimination tree. The parent of j is FLIP (Pe [j]),
1616  * or EMPTY if j is a root. The tree holds both elements and
1617  * non-principal (unordered) variables absorbed into them.
1618  * Dense variables are non-principal and unordered.
1619  *
1620  * Elen: holds the size of each element, including the diagonal part.
1621  * FLIP (Elen [e]) > 0 if e is an element. For unordered
1622  * variables i, Elen [i] is EMPTY.
1623  *
1624  * Nv: Nv [e] > 0 is the number of pivots represented by the element e.
1625  * For unordered variables i, Nv [i] is zero.
1626  *
1627  * Contents no longer needed:
1628  * W, Iw, Len, Degree, Head, Next, Last.
1629  *
1630  * The matrix itself has been destroyed.
1631  *
1632  * n: the size of the matrix.
1633  * No other scalars needed (pfree, iwlen, etc.)
1634  * ------------------------------------------------------------------------- */
1635 
1636  /* restore Pe */
1637  for (i = 0 ; i < n ; i++)
1638  {
1639  Pe [i] = FLIP (Pe [i]) ;
1640  }
1641 
1642  /* restore Elen, for output information, and for postordering */
1643  for (i = 0 ; i < n ; i++)
1644  {
1645  Elen [i] = FLIP (Elen [i]) ;
1646  }
1647 
1648 /* Now the parent of j is Pe [j], or EMPTY if j is a root. Elen [e] > 0
1649  * is the size of element e. Elen [i] is EMPTY for unordered variable i. */
1650 
1651 #ifndef NDEBUG
1652  AMD_DEBUG2 (("\nTree:\n")) ;
1653  for (i = 0 ; i < n ; i++)
1654  {
1655  AMD_DEBUG2 ((" "ID" parent: "ID" ", i, Pe [i])) ;
1656  ASSERT (Pe [i] >= EMPTY && Pe [i] < n) ;
1657  if (Nv [i] > 0)
1658  {
1659  /* this is an element */
1660  e = i ;
1661  AMD_DEBUG2 ((" element, size is "ID"\n", Elen [i])) ;
1662  ASSERT (Elen [e] > 0) ;
1663  }
1664  AMD_DEBUG2 (("\n")) ;
1665  }
1666  AMD_DEBUG2 (("\nelements:\n")) ;
1667  for (e = 0 ; e < n ; e++)
1668  {
1669  if (Nv [e] > 0)
1670  {
1671  AMD_DEBUG3 (("Element e= "ID" size "ID" nv "ID" \n", e,
1672  Elen [e], Nv [e])) ;
1673  }
1674  }
1675  AMD_DEBUG2 (("\nvariables:\n")) ;
1676  for (i = 0 ; i < n ; i++)
1677  {
1678  Int cnt ;
1679  if (Nv [i] == 0)
1680  {
1681  AMD_DEBUG3 (("i unordered: "ID"\n", i)) ;
1682  j = Pe [i] ;
1683  cnt = 0 ;
1684  AMD_DEBUG3 ((" j: "ID"\n", j)) ;
1685  if (j == EMPTY)
1686  {
1687  AMD_DEBUG3 ((" i is a dense variable\n")) ;
1688  }
1689  else
1690  {
1691  ASSERT (j >= 0 && j < n) ;
1692  while (Nv [j] == 0)
1693  {
1694  AMD_DEBUG3 ((" j : "ID"\n", j)) ;
1695  j = Pe [j] ;
1696  AMD_DEBUG3 ((" j:: "ID"\n", j)) ;
1697  cnt++ ;
1698  if (cnt > n) break ;
1699  }
1700  e = j ;
1701  AMD_DEBUG3 ((" got to e: "ID"\n", e)) ;
1702  }
1703  }
1704  }
1705 #endif
1706 
1707 /* ========================================================================= */
1708 /* compress the paths of the variables */
1709 /* ========================================================================= */
1710 
1711  for (i = 0 ; i < n ; i++)
1712  {
1713  if (Nv [i] == 0)
1714  {
1715 
1716  /* -------------------------------------------------------------
1717  * i is an un-ordered row. Traverse the tree from i until
1718  * reaching an element, e. The element, e, was the principal
1719  * supervariable of i and all nodes in the path from i to when e
1720  * was selected as pivot.
1721  * ------------------------------------------------------------- */
1722 
1723  AMD_DEBUG1 (("Path compression, i unordered: "ID"\n", i)) ;
1724  j = Pe [i] ;
1725  ASSERT (j >= EMPTY && j < n) ;
1726  AMD_DEBUG3 ((" j: "ID"\n", j)) ;
1727  if (j == EMPTY)
1728  {
1729  /* Skip a dense variable. It has no parent. */
1730  AMD_DEBUG3 ((" i is a dense variable\n")) ;
1731  continue ;
1732  }
1733 
1734  /* while (j is a variable) */
1735  while (Nv [j] == 0)
1736  {
1737  AMD_DEBUG3 ((" j : "ID"\n", j)) ;
1738  j = Pe [j] ;
1739  AMD_DEBUG3 ((" j:: "ID"\n", j)) ;
1740  ASSERT (j >= 0 && j < n) ;
1741  }
1742  /* got to an element e */
1743  e = j ;
1744  AMD_DEBUG3 (("got to e: "ID"\n", e)) ;
1745 
1746  /* -------------------------------------------------------------
1747  * traverse the path again from i to e, and compress the path
1748  * (all nodes point to e). Path compression allows this code to
1749  * compute in O(n) time.
1750  * ------------------------------------------------------------- */
1751 
1752  j = i ;
1753  /* while (j is a variable) */
1754  while (Nv [j] == 0)
1755  {
1756  jnext = Pe [j] ;
1757  AMD_DEBUG3 (("j "ID" jnext "ID"\n", j, jnext)) ;
1758  Pe [j] = e ;
1759  j = jnext ;
1760  ASSERT (j >= 0 && j < n) ;
1761  }
1762  }
1763  }
1764 
1765 /* ========================================================================= */
1766 /* postorder the assembly tree */
1767 /* ========================================================================= */
1768 
1769  AMD_postorder (n, Pe, Nv, Elen,
1770  W, /* output order */
1771  Head, Next, Last) ; /* workspace */
1772 
1773 /* ========================================================================= */
1774 /* compute output permutation and inverse permutation */
1775 /* ========================================================================= */
1776 
1777  /* W [e] = k means that element e is the kth element in the new
1778  * order. e is in the range 0 to n-1, and k is in the range 0 to
1779  * the number of elements. Use Head for inverse order. */
1780 
1781  for (k = 0 ; k < n ; k++)
1782  {
1783  Head [k] = EMPTY ;
1784  Next [k] = EMPTY ;
1785  }
1786  for (e = 0 ; e < n ; e++)
1787  {
1788  k = W [e] ;
1789  ASSERT ((k == EMPTY) == (Nv [e] == 0)) ;
1790  if (k != EMPTY)
1791  {
1792  ASSERT (k >= 0 && k < n) ;
1793  Head [k] = e ;
1794  }
1795  }
1796 
1797  /* construct output inverse permutation in Next,
1798  * and permutation in Last */
1799  nel = 0 ;
1800  for (k = 0 ; k < n ; k++)
1801  {
1802  e = Head [k] ;
1803  if (e == EMPTY) break ;
1804  ASSERT (e >= 0 && e < n && Nv [e] > 0) ;
1805  Next [e] = nel ;
1806  nel += Nv [e] ;
1807  }
1808  ASSERT (nel == n - ndense) ;
1809 
1810  /* order non-principal variables (dense, & those merged into supervar's) */
1811  for (i = 0 ; i < n ; i++)
1812  {
1813  if (Nv [i] == 0)
1814  {
1815  e = Pe [i] ;
1816  ASSERT (e >= EMPTY && e < n) ;
1817  if (e != EMPTY)
1818  {
1819  /* This is an unordered variable that was merged
1820  * into element e via supernode detection or mass
1821  * elimination of i when e became the pivot element.
1822  * Place i in order just before e. */
1823  ASSERT (Next [i] == EMPTY && Nv [e] > 0) ;
1824  Next [i] = Next [e] ;
1825  Next [e]++ ;
1826  }
1827  else
1828  {
1829  /* This is a dense unordered variable, with no parent.
1830  * Place it last in the output order. */
1831  Next [i] = nel++ ;
1832  }
1833  }
1834  }
1835  ASSERT (nel == n) ;
1836 
1837  AMD_DEBUG2 (("\n\nPerm:\n")) ;
1838  for (i = 0 ; i < n ; i++)
1839  {
1840  k = Next [i] ;
1841  ASSERT (k >= 0 && k < n) ;
1842  Last [k] = i ;
1843  AMD_DEBUG2 ((" perm ["ID"] = "ID"\n", k, i)) ;
1844  }
1845 }
#define AMD_NCMPA
Definition: amesos_amd.h:360
void f()
#define AMD_NMULTSUBS_LDL
Definition: amesos_amd.h:363
#define EMPTY
#define GLOBAL
#define AMD_DEBUG1(params)
#define AMD_DEBUG3(params)
#define Int
#define AMD_DEFAULT_AGGRESSIVE
Definition: amesos_amd.h:349
#define AMD_STATUS
Definition: amesos_amd.h:352
#define MAX(a, b)
#define AMD_NDENSE
Definition: amesos_amd.h:358
#define AMD_debug
#define NULL
#define AMD_dump
#define AMD_DENSE
Definition: amesos_amd.h:344
#define ASSERT(expression)
#define FLIP(i)
#define ID
#define AMD_AGGRESSIVE
Definition: amesos_amd.h:345
#define AMD_DEBUG4(params)
#define AMD_DMAX
Definition: amesos_amd.h:365
#define AMD_NMULTSUBS_LU
Definition: amesos_amd.h:364
#define AMD_DEBUG2(params)
#define Int_MAX
#define AMD_OK
Definition: amesos_amd.h:371
static Int amesos_clear_flag(Int wflg, Int wbig, Int W[], Int n)
Definition: amesos_amd_l2.c:26
#define AMD_NDIV
Definition: amesos_amd.h:362
#define AMD_postorder
#define MIN(a, b)
#define AMD_DEFAULT_DENSE
Definition: amesos_amd.h:348
#define IMPLIES(p, q)
GLOBAL void AMD_2(Int n, Int Pe[], Int Iw[], Int Len[], Int iwlen, Int pfree, Int Nv[], Int Next[], Int Last[], Int Head[], Int Elen[], Int Degree[], Int W[], double Control[], double Info[])
Definition: amesos_amd_l2.c:47
#define AMD_LNZ
Definition: amesos_amd.h:361