Go to the documentation of this file.
19 #define RandomInRange(u) ((int)(1.0*(u)*rand()/(RAND_MAX+1.0)))
21 #define amax(a, b) ((a) >= (b) ? (a) : (b))
22 #define amin(a, b) ((a) >= (b) ? (b) : (a))
24 #define AND(a, b) ((a) < 0 ? ((-(a))&(b)) : ((a)&(b)))
25 #define OR(a, b) ((a) < 0 ? -((-(a))|(b)) : ((a)|(b)))
26 #define XOR(a, b) ((a) < 0 ? -((-(a))^(b)) : ((a)^(b)))
28 #define SWAP(a, b, tmp) \
29 do {(tmp) = (a); (a) = (b); (b) = (tmp);} while(0)
31 #define INC_DEC(a, b, val) \
32 do {(a) += (val); (b) -= (val);} while(0)
35 #define scopy(n, a, b) (float *)memcpy((void *)(b), (void *)(a), sizeof(float)*(n))
36 #define idxcopy(n, a, b) (idxtype *)memcpy((void *)(b), (void *)(a), sizeof(idxtype)*(n))
38 #define HASHFCT(key, size) ((key)%(size))
44 #define cleartimer(tmr) (tmr = 0.0)
45 #define starttimer(tmr) (tmr -= seconds())
46 #define stoptimer(tmr) (tmr += seconds())
47 #define gettimer(tmr) (tmr)
53 #define IFSET(a, flag, cmd) if ((a)&(flag)) (cmd);
59 #define imalloc(n, msg) (malloc(sizeof(int)*(n)))
60 #define fmalloc(n, msg) (malloc(sizeof(float)*(n)))
61 #define idxmalloc(n, msg) (malloc(sizeof(idxtype)*(n)))
62 #define ismalloc(n, val, msg) (iset((n), (val), malloc(sizeof(int)*(n))))
63 #define idxsmalloc(n, val, msg) (idxset((n), (val), malloc(sizeof(idxtype)*(n))))
64 #define GKmalloc(a, b) (malloc((a)))
68 # define MALLOC_CHECK(ptr);
78 # define MALLOC_CHECK(ptr) ;
86 #define MAKECSR(i, n, a) \
88 for (i=1; i<n; i++) a[i] += a[i-1]; \
89 for (i=n; i>0; i--) a[i] = a[i-1]; \
97 #define BNDInsert(nbnd, bndind, bndptr, vtx) \
99 ASSERT(bndptr[vtx] == -1); \
100 bndind[nbnd] = vtx; \
101 bndptr[vtx] = nbnd++;\
104 #define BNDDelete(nbnd, bndind, bndptr, vtx) \
106 ASSERT(bndptr[vtx] != -1); \
107 bndind[bndptr[vtx]] = bndind[--nbnd]; \
108 bndptr[bndind[nbnd]] = bndptr[vtx]; \
118 # define ASSERT(expr) \
120 printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
121 __LINE__, __FILE__); \
125 # define ASSERT(expr) ;
129 # define ASSERTP(expr, msg) \
131 printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
132 __LINE__, __FILE__); \
137 # define ASSERTP(expr, msg) ;