-
Notifications
You must be signed in to change notification settings - Fork 0
/
DBToPermTests.c
executable file
·183 lines (144 loc) · 3.12 KB
/
DBToPermTests.c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include "DBInputs.h"
void initialisePermutation(Permutation *perm, int degree);
void isAllowedTest()
{
DataBase db;
int n;
int i;
int degree = 6;
Permutation perm;
int local = 10;
int global = 0;
int seed = 56;
initialiseDataBase(&db,degree);
initialisePermutation(&perm, degree);
randomDB(&db,local,global,seed,degree);
for (i = 0; i < 4; i++)
perm[i] = i;
for (i = 0; i < 5; i++)
{
n = isAllowed(&db, perm, i, 4, degree);
printf("%d %d\n", i, n);
}
writeDataBase(&db,degree);
}
void testExpand()
{
SmallPermset *sps_ptr = NULL;
Permutation perm;
DataBase db;
int d = 4;
int degree = 6;
int i;
int local = 15;
int global = 1;
int seed = 32;
initialisePermutation(&perm, d - 1);
// initialisePermSet(&sps);
for (i = 0; i < d - 1; i++)
{
perm[i] = i;
}
randomDB(&db, local, global, seed, degree);
expand(&sps_ptr,perm,d,&db,degree);
printf("Pointer: %p\n",sps_ptr);
printSmallPermset(sps_ptr,d);
}
void testInitialisePermutation()
{
Permutation perm;
int degree = 6;
int i;
initialisePermutation(&perm, degree);
printf("InitialisePermutation has run.\n");
for (i = 0; i < degree; i++)
{
printf("%d\n",i);
perm[i] = i;
}
printPermutation(perm, degree);
}
void altInitTest()
{
Permutation perm;
int degree = 6;
int i;
if (!(perm = malloc(degree * sizeof(int))))
{
printf("Error in intialisePerm: malloc failed.\n");
}
for (i = 0; i < degree; i++)
{
printf("%d\n",i);
perm[i] = i;
}
printPermutation(perm, degree);
}
void initPerm(Permutation *perm_ptr, int degree)
{
if (! (*perm_ptr = malloc(degree * sizeof(int))))
{
printf("Error in initialisePermutation: malloc failed.\n");
exit(0);
}
}
void newInitTest()
{
Permutation perm;
int degree = 6;
int i;
initPerm(&perm, degree);
for (i = 0; i < degree; i++)
{
printf("%d\n",i);
perm[i] = i;
}
printPermutation(perm, degree);
}
/*
void initPermSetTest(void)
{
SmallPermset *sps_ptr;
initialisePermSet(&sps_ptr);
printSmallPermset(sps_ptr, 2);
}
*/
void dbToPermTest(void)
{
DataBase db;
int local = 115;
int global = 7;
int seed = 179;
int degree = 12;
SmallPermset *sps_ptr;
randomDB(&db, local, global, seed, degree);
// writeDataBase(&db, degree);
sps_ptr = dbToPerm(&db, degree);
printSmallPermset(sps_ptr, degree);
}
void shiftTest(void)
{
uint64_t val;
uint64_t sum = 0;
uint64_t unus = 1;
for (int i = 0; i < 64; i++)
{
val = unus << i;
if (i % 5 == 0)
sum += val;
printf("unus << %d : %llu\n", i, val);
}
printf("Sum: %llu\n",sum);
uint64_t newsum = sum | unus << 29;
printf("Sum OR: %llu\nDifference: %llu\n", sum, newsum-sum);
}
int main(void)
{
// isAllowedTest();
// testExpand();
// testInitialisePermutation();
// altInitTest();
// initPermSetTest();
// dbToPermTest();
shiftTest();
}