Go to the documentation of this file.
15 #ifndef _LIBMETIS_MACROS_H_
16 #define _LIBMETIS_MACROS_H_
21 #define AND(a, b) ((a) < 0 ? ((-(a))&(b)) : ((a)&(b)))
22 #define OR(a, b) ((a) < 0 ? -((-(a))|(b)) : ((a)|(b)))
23 #define XOR(a, b) ((a) < 0 ? -((-(a))^(b)) : ((a)^(b)))
27 #define HASHFCT(key, size) ((key)%(size))
31 #define GETOPTION(options, idx, defval) \
32 ((options) == NULL || (options)[idx] == -1 ? defval : (options)[idx])
35 #define I2RUBFACTOR(ufactor) (1.0+0.001*(ufactor))
38 #define WCOREPUSH wspacepush(ctrl)
39 #define WCOREPOP wspacepop(ctrl)
46 #define ListInsert(n, lind, lptr, i) \
48 ASSERT(lptr[i] == -1); \
53 #define ListDelete(n, lind, lptr, i) \
55 ASSERT(lptr[i] != -1); \
56 lind[lptr[i]] = lind[--(n)]; \
57 lptr[lind[n]] = lptr[i]; \
65 #define BNDInsert(nbnd, bndind, bndptr, vtx) \
66 ListInsert(nbnd, bndind, bndptr, vtx)
68 #define BNDDelete(nbnd, bndind, bndptr, vtx) \
69 ListDelete(nbnd, bndind, bndptr, vtx)
75 #define UpdateMovedVertexInfoAndBND(i, from, k, to, myrinfo, mynbrs, where, \
76 nbnd, bndptr, bndind, bndtype) \
79 myrinfo->ed += myrinfo->id-mynbrs[k].ed; \
80 SWAP(myrinfo->id, mynbrs[k].ed, j); \
81 if (mynbrs[k].ed == 0) \
82 mynbrs[k] = mynbrs[--myrinfo->nnbrs]; \
84 mynbrs[k].pid = from; \
88 if (bndtype == BNDTYPE_REFINE) { \
89 if (bndptr[i] != -1 && myrinfo->ed - myrinfo->id < 0) \
90 BNDDelete(nbnd, bndind, bndptr, i); \
91 if (bndptr[i] == -1 && myrinfo->ed - myrinfo->id >= 0) \
92 BNDInsert(nbnd, bndind, bndptr, i); \
95 if (bndptr[i] != -1 && myrinfo->ed <= 0) \
96 BNDDelete(nbnd, bndind, bndptr, i); \
97 if (bndptr[i] == -1 && myrinfo->ed > 0) \
98 BNDInsert(nbnd, bndind, bndptr, i); \
103 #define UpdateAdjacentVertexInfoAndBND(ctrl, vid, adjlen, me, from, to, \
104 myrinfo, ewgt, nbnd, bndptr, bndind, bndtype) \
109 if (myrinfo->inbr == -1) { \
110 myrinfo->inbr = cnbrpoolGetNext(ctrl, adjlen+1); \
111 myrinfo->nnbrs = 0; \
113 ASSERT(CheckRInfo(ctrl, myrinfo)); \
115 mynbrs = ctrl->cnbrpool + myrinfo->inbr; \
119 INC_DEC(myrinfo->ed, myrinfo->id, (ewgt)); \
120 if (bndtype == BNDTYPE_REFINE) { \
121 if (myrinfo->ed-myrinfo->id >= 0 && bndptr[(vid)] == -1) \
122 BNDInsert(nbnd, bndind, bndptr, (vid)); \
125 if (myrinfo->ed > 0 && bndptr[(vid)] == -1) \
126 BNDInsert(nbnd, bndind, bndptr, (vid)); \
129 else if (me == to) { \
130 INC_DEC(myrinfo->id, myrinfo->ed, (ewgt)); \
131 if (bndtype == BNDTYPE_REFINE) { \
132 if (myrinfo->ed-myrinfo->id < 0 && bndptr[(vid)] != -1) \
133 BNDDelete(nbnd, bndind, bndptr, (vid)); \
136 if (myrinfo->ed <= 0 && bndptr[(vid)] != -1) \
137 BNDDelete(nbnd, bndind, bndptr, (vid)); \
143 for (k=0; k<myrinfo->nnbrs; k++) { \
144 if (mynbrs[k].pid == from) { \
145 if (mynbrs[k].ed == (ewgt)) \
146 mynbrs[k] = mynbrs[--myrinfo->nnbrs]; \
148 mynbrs[k].ed -= (ewgt); \
156 for (k=0; k<myrinfo->nnbrs; k++) { \
157 if (mynbrs[k].pid == to) { \
158 mynbrs[k].ed += (ewgt); \
162 if (k == myrinfo->nnbrs) { \
163 mynbrs[k].pid = to; \
164 mynbrs[k].ed = (ewgt); \
169 ASSERT(CheckRInfo(ctrl, myrinfo));\
173 #define UpdateQueueInfo(queue, vstatus, vid, me, from, to, myrinfo, oldnnbrs, \
174 nupd, updptr, updind, bndtype) \
178 if (me == to || me == from || oldnnbrs != myrinfo->nnbrs) { \
179 rgain = (myrinfo->nnbrs > 0 ? \
180 1.0*myrinfo->ed/sqrt(myrinfo->nnbrs) : 0.0) - myrinfo->id; \
182 if (bndtype == BNDTYPE_REFINE) { \
183 if (vstatus[(vid)] == VPQSTATUS_PRESENT) { \
184 if (myrinfo->ed-myrinfo->id >= 0) \
185 rpqUpdate(queue, (vid), rgain); \
187 rpqDelete(queue, (vid)); \
188 vstatus[(vid)] = VPQSTATUS_NOTPRESENT; \
189 ListDelete(nupd, updind, updptr, (vid)); \
192 else if (vstatus[(vid)] == VPQSTATUS_NOTPRESENT && myrinfo->ed-myrinfo->id >= 0) { \
193 rpqInsert(queue, (vid), rgain); \
194 vstatus[(vid)] = VPQSTATUS_PRESENT; \
195 ListInsert(nupd, updind, updptr, (vid)); \
199 if (vstatus[(vid)] == VPQSTATUS_PRESENT) { \
200 if (myrinfo->ed > 0) \
201 rpqUpdate(queue, (vid), rgain); \
203 rpqDelete(queue, (vid)); \
204 vstatus[(vid)] = VPQSTATUS_NOTPRESENT; \
205 ListDelete(nupd, updind, updptr, (vid)); \
208 else if (vstatus[(vid)] == VPQSTATUS_NOTPRESENT && myrinfo->ed > 0) { \
209 rpqInsert(queue, (vid), rgain); \
210 vstatus[(vid)] = VPQSTATUS_PRESENT; \
211 ListInsert(nupd, updind, updptr, (vid)); \
223 #define SelectSafeTargetSubdomains(myrinfo, mynbrs, nads, adids, maxndoms, safetos, vtmp) \
225 idx_t j, k, l, nadd, to; \
226 for (j=0; j<myrinfo->nnbrs; j++) { \
227 safetos[to = mynbrs[j].pid] = 0; \
230 for (k=0; k<nads[to]; k++) \
231 vtmp[adids[to][k]] = 1; \
233 for (nadd=0, k=0; k<myrinfo->nnbrs; k++) { \
238 if (vtmp[l] == 0) { \
239 if (nads[l] > maxndoms-1) { \
246 if (nads[to]+nadd <= maxndoms) \
252 for (k=0; k<nads[to]; k++) \
253 vtmp[adids[to][k]] = 0; \
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:44