1 /*! \file
2 Copyright (c) 2003, The Regents of the University of California, through
3 Lawrence Berkeley National Laboratory (subject to receipt of any required
4 approvals from U.S. Dept. of Energy)
5
6 All rights reserved.
7
8 The source code is distributed under BSD license, see the file License.txt
9 at the top-level directory.
10 */
11
12 /*! @file ilu_zsnode_dfs.c
13 * \brief Determines the union of row structures of columns within the relaxed node
14 *
15 * <pre>
16 * -- SuperLU routine (version 4.0) --
17 * Lawrence Berkeley National Laboratory
18 * June 30, 2009
19 * </pre>
20 */
21
22 #include "slu_zdefs.h"
23
24 /*! \brief
25 *
26 * <pre>
27 * Purpose
28 * =======
29 * ilu_zsnode_dfs() - Determine the union of the row structures of those
30 * columns within the relaxed snode.
31 * Note: The relaxed snodes are leaves of the supernodal etree, therefore,
32 * the portion outside the rectangular supernode must be zero.
33 *
34 * Return value
35 * ============
36 * 0 success;
37 * >0 number of bytes allocated when run out of memory.
38 * </pre>
39 */
40
41 int
ilu_zsnode_dfs(const int jcol,const int kcol,const int * asub,const int * xa_begin,const int * xa_end,int * marker,GlobalLU_t * Glu)42 ilu_zsnode_dfs(
43 const int jcol, /* in - start of the supernode */
44 const int kcol, /* in - end of the supernode */
45 const int *asub, /* in */
46 const int *xa_begin, /* in */
47 const int *xa_end, /* in */
48 int *marker, /* modified */
49 GlobalLU_t *Glu /* modified */
50 )
51 {
52
53 register int i, k, nextl;
54 int nsuper, krow, kmark, mem_error;
55 int *xsup, *supno;
56 int *lsub, *xlsub;
57 int nzlmax;
58
59 xsup = Glu->xsup;
60 supno = Glu->supno;
61 lsub = Glu->lsub;
62 xlsub = Glu->xlsub;
63 nzlmax = Glu->nzlmax;
64
65 nsuper = ++supno[jcol]; /* Next available supernode number */
66 nextl = xlsub[jcol];
67
68 for (i = jcol; i <= kcol; i++)
69 {
70 /* For each nonzero in A[*,i] */
71 for (k = xa_begin[i]; k < xa_end[i]; k++)
72 {
73 krow = asub[k];
74 kmark = marker[krow];
75 if ( kmark != kcol )
76 { /* First time visit krow */
77 marker[krow] = kcol;
78 lsub[nextl++] = krow;
79 if ( nextl >= nzlmax )
80 {
81 if ( (mem_error = zLUMemXpand(jcol, nextl, LSUB, &nzlmax,
82 Glu)) != 0)
83 return (mem_error);
84 lsub = Glu->lsub;
85 }
86 }
87 }
88 supno[i] = nsuper;
89 }
90
91 /* Supernode > 1 */
92 if ( jcol < kcol )
93 for (i = jcol+1; i <= kcol; i++) xlsub[i] = nextl;
94
95 xsup[nsuper+1] = kcol + 1;
96 supno[kcol+1] = nsuper;
97 xlsub[kcol+1] = nextl;
98
99 return 0;
100 }
101