/
iv.c
169 lines (151 loc) · 3.65 KB
/
iv.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
/* Searches for a kernel of the Burau representation for n=4.
*
* This version looks for an arc from the basepoint to a puncture whose lift
* does not homologically cross the line between the last two punctures.
* It checks that the crossing numbers describing the arc are coprime.
*/
#include<stdio.h>
#define STARTTOTAL 1300
#define ENDTOTAL 2000
#define HUMPS 3
#define LEVELS 10000
#define STARTLEVEL 5000
int gcd(int i,int j)
{
while(j)
{
i = i-j*(i/j);
/* Exchange i and j */
i ^= j;
j ^= i;
i ^= j;
}
return(i);
}
/*Check to see if a described scc gives a kernel of the Burau representation
*Return V for victory, 0 for no, or error codes: o for overflow
*/
char example(int* nextcut, int* flcut, int leftend)
{
int cut, newcut;
int level = STARTLEVEL;
int i;
int lo = STARTLEVEL;
int hi = STARTLEVEL-1; /*record hi and lo levels reached*/
int parity;
int norm = 0;
int togo;
int rightend;
int poly[LEVELS];
togo = nextcut[HUMPS-1]/2;
rightend = leftend + nextcut[HUMPS-1]/2;
cut = nextcut[0]/2;
while(togo >= norm)
{
/* Check for Error o: overflow */
if(level<0 || level>=LEVELS) return('o');
/* Clear space in poly */
while(lo>level) poly[--lo] = 0;
while(hi<level) poly[++hi] = 0;
/* Alter poly and go through */
if(parity)
{
if(poly[level]++ >= 0) norm++;
else norm--;
}
else
{
if(poly[level]-- <= 0) norm++;
else norm--;
}
togo--;
cut = 2*leftend-1-cut;
if(cut<0) cut+= nextcut[HUMPS-1];
else if(cut>=nextcut[HUMPS-1]) cut-= nextcut[HUMPS-1];
/* Set i = current hump */
for(i = 0; nextcut[i] <= cut; i++);
/* Go over the hump */
newcut = flcut[i] - cut;
if(newcut < cut)
{
if(i) level--;
else
{
parity = !parity;
level += HUMPS+1;
}
if(newcut < leftend && cut >= leftend) level--;
if(newcut < rightend && cut >= rightend) level--;
}
else if(newcut > cut)
{
if(i) level++;
else
{
parity = !parity;
level -= (HUMPS+1);
}
if(newcut >= leftend && cut < leftend) level++;
if(newcut >= rightend && cut < rightend) level++;
}
else
{
if(norm) return(0);
if(togo) return('v');
return('V');
}
cut = newcut;
}
return(0);
}
printexamples(int* width,FILE* fp)
{
int nextcut[HUMPS]; /*1+number of last cut in that hump*/
int flcut[HUMPS]; /*first cut number + last cut number */
int i;
int leftend;
char error;
int gcdwidths = 0; /* The gcd of the values of width */
/* Initialize nextcut, flcut, gcdwidths */
for(i=0; i<HUMPS; i++)
{
gcdwidths = gcd(width[i], gcdwidths);
nextcut[i] = (i? nextcut[i-1]: 0) + width[i];
flcut[i] = (i? nextcut[i-1]: 0) + nextcut[i] - 1;
}
for(leftend = nextcut[HUMPS-1]/2; leftend>=0; leftend--)
{
if(gcd(gcdwidths,leftend) == 1)
{
error = example(nextcut,flcut,leftend);
if(error)
{
fprintf(fp,"Error %c: widths %d,%d,%d, leftend %d\n",
error,width[0],width[1],width[2],leftend);
fflush(fp);
}
}
}
}
main()
{
FILE* fp;
int total;
int width[HUMPS];
int leftend;
char error = 0;
fp = fopen("ivlog","w");
for(total = STARTTOTAL; total<=ENDTOTAL; total += 4)
{
fprintf(fp,"%d\n",total);
fflush(fp);
for(width[0] = 3; width[0]<=total; width[0]+=2)
for(width[1] = 0; width[0]+width[1] <= total; width[1]+=2)
{
width[2] = total - width[0] - width[1];
printexamples(width,fp);
}
}
fprintf(fp,"Done checking from %d to %d\n",STARTTOTAL,ENDTOTAL);
fclose(fp);
}