Go to the documentation of this file.
20 #define RandomInRange(u) ((rand()>>3)%(u))
21 #define RandomInRangeFast(u) ((rand()>>3)%(u))
23 #define RandomInRange(u) ((int)(drand48()*((double)(u))))
24 #define RandomInRangeFast(u) ((rand()>>3)%(u))
29 #define amax(a, b) ((a) >= (b) ? (a) : (b))
30 #define amin(a, b) ((a) >= (b) ? (b) : (a))
32 #define AND(a, b) ((a) < 0 ? ((-(a))&(b)) : ((a)&(b)))
33 #define OR(a, b) ((a) < 0 ? -((-(a))|(b)) : ((a)|(b)))
34 #define XOR(a, b) ((a) < 0 ? -((-(a))^(b)) : ((a)^(b)))
36 #define SWAP(a, b, tmp) \
37 do {(tmp) = (a); (a) = (b); (b) = (tmp);} while(0)
39 #define INC_DEC(a, b, val) \
40 do {(a) += (val); (b) -= (val);} while(0)
43 #define scopy(n, a, b) (float *)memcpy((void *)(b), (void *)(a), sizeof(float)*(n))
44 #define idxcopy(n, a, b) (idxtype *)memcpy((void *)(b), (void *)(a), sizeof(idxtype)*(n))
46 #define HASHFCT(key, size) ((key)%(size))
52 #define cleartimer(tmr) (tmr = 0.0)
53 #define starttimer(tmr) (tmr -= seconds())
54 #define stoptimer(tmr) (tmr += seconds())
55 #define gettimer(tmr) (tmr)
61 #define IFSET(a, flag, cmd) if ((a)&(flag)) (cmd);
67 #define imalloc(n, msg) (malloc(sizeof(int)*(n)))
68 #define fmalloc(n, msg) (malloc(sizeof(float)*(n)))
69 #define idxmalloc(n, msg) (malloc(sizeof(idxtype)*(n)))
70 #define ismalloc(n, val, msg) (iset((n), (val), malloc(sizeof(int)*(n))))
71 #define idxsmalloc(n, val, msg) (idxset((n), (val), malloc(sizeof(idxtype)*(n))))
72 #define GKmalloc(a, b) (malloc((a)))
76 # define MALLOC_CHECK(ptr) \
77 if (malloc_verify((ptr)) == DMALLOC_VERIFY_ERROR) { \
78 printf("***MALLOC_CHECK failed on line %d of file %s: " #ptr "\n", \
79 __LINE__, __FILE__); \
83 # define MALLOC_CHECK(ptr) ;
91 #define MAKECSR(i, n, a) \
93 for (i=1; i<n; i++) a[i] += a[i-1]; \
94 for (i=n; i>0; i--) a[i] = a[i-1]; \
102 #define BNDInsert(nbnd, bndind, bndptr, vtx) \
104 ASSERT(bndptr[vtx] == -1); \
105 bndind[nbnd] = vtx; \
106 bndptr[vtx] = nbnd++;\
109 #define BNDDelete(nbnd, bndind, bndptr, vtx) \
111 ASSERT(bndptr[vtx] != -1); \
112 bndind[bndptr[vtx]] = bndind[--nbnd]; \
113 bndptr[bndind[nbnd]] = bndptr[vtx]; \
123 # define ASSERT(expr) \
125 printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
126 __LINE__, __FILE__); \
130 # define ASSERT(expr) ;
134 # define ASSERTP(expr, msg) \
136 printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
137 __LINE__, __FILE__); \
142 # define ASSERTP(expr, msg) ;