/ani/mrses

To get this branch, use:
bzr branch http://de.suren.me/webbzr/ani/mrses
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef _TOOLS_H
#define _TOOLS_H


#define isqrt(a) ((a<0)?(-sqrt(-a)):sqrt(a))
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define rnd(i) ((int)((i) * (random() / (RAND_MAX + 1.0))))
#define calc_alloc(size,rounding) ((((size)/(rounding)) + (((size)%(rounding))?1:0))*(rounding))

#define lcm(x, y) ((x * y) / gcd(x, y))
#define lcm3(x, y, z) lcm(lcm(x, y), z)

#define SWAPij(index, i, j) { \
    int tmp = *(index+i); *(index+i) = *(index+j); *(index+j) = tmp; \
}
#define SWAPi(index, properties, i) { \
    int tmp1 = rnd(properties); \
    SWAPij(index, i, tmp1); \
}
#define SWAP(index, properties, width) { \
    int tmp1 = rnd(properties - width); \
    int tmp2 = rnd(width); \
    SWAPij(index, tmp2, width + tmp1); \
}

#define PRINT_MATRIX(fmt, MATRIX, width, n, m) \
{ \
    int i, j; \
    for (i = 0; i < n; i++) { \
	for (j = 0; j < m; j++) \
	    printf(fmt, MATRIX[i * width + j]); \
	printf("\n"); \
    } \
    printf("\n"); \
}

#define PRINT_MULTIMATRIX(num, fmt, MATRIX, width, n, m) \
{ \
    int i, j; \
    for (i = 0; i < n; i++) { \
	for (j = 0; j < m; j++) \
	    printf(fmt, MATRIX[4*(i * width + j) + num]); \
	printf("\n"); \
    } \
    printf("\n"); \
}



unsigned gcd(unsigned x, unsigned y);


#endif /* _TOOLS_H */