forked from cseed/knotkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smoothing.cpp
121 lines (103 loc) · 2.41 KB
/
smoothing.cpp
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
#include <knotkit.h>
void
smoothing::init (const knot_diagram &d, smallbitset state)
{
unsigned n_edges = d.num_edges ();
n_circles = 0;
assert (edge_circle.size () == n_edges);
for (unsigned i = 1; i <= n_edges; i ++)
edge_circle[i] = 0;
for (unsigned i = 1; i <= n_edges; i ++)
{
if (edge_circle[i])
continue;
n_circles ++;
for (unsigned p = edge_to (d, i);;)
{
unsigned e = d.ept_edge (p);
edge_circle[e] = n_circles;
p = d.resolve_next_ept (p, state % d.ept_crossing[p]);
assert (is_from_ept (d, p));
if (d.ept_edge (p) == i)
break;
p = d.edge_other_ept (p);
assert (is_to_ept (d, p));
}
}
#ifndef NDEBUG
for (unsigned c = 1; c <= d.n_crossings; c ++)
{
assert (crossing_from_inside (d, state, c)
== crossing_to_inside (d, state, c));
}
#endif
}
unsigned
smoothing::monomial_from (const knot_diagram &d, const smoothing &from_s, unsigned j) const
{
unsigned j2 = 0;
for (unsigned k = 1; k <= d.num_edges (); k ++)
{
if (unsigned_bittest (j, from_s.edge_circle[k]))
j2 = unsigned_bitset (j2, edge_circle[k]);
}
return j2;
}
unsigned
smoothing::monomial_from (const knot_diagram &d, const smoothing &from_s, unsigned j,
smallbitset skip) const
{
unsigned j2 = 0;
for (unsigned k = 1; k <= d.num_edges (); k ++)
{
if (skip % k)
continue;
if (unsigned_bittest (j, from_s.edge_circle[k]))
j2 = unsigned_bitset (j2, edge_circle[k]);
}
return j2;
}
void
smoothing::show_self (const knot_diagram &d, smallbitset state) const
{
printf ("smoothing ");
show (state);
printf (" ");
smallbitset done (d.num_edges ());
for (unsigned e = 1; e <= d.num_edges (); e ++)
{
if (done % e)
continue;
printf ("(");
bool first = 1;
for (unsigned f = e;;)
{
done.push (f);
unsigned p = edge_to (d, f);
unsigned c = d.ept_crossing (p);
assert (is_to_ept (d, p));
if (f == d.marked_edge)
printf ("*");
if (first)
first = 0;
else
printf (", ");
if (is_crossing_from_ept (d, state, p))
{
printf ("t%d%s",
c,
crossing_from_inside (d, state, c) ? "in" : "out");
}
else
{
printf ("h%d%s",
c,
crossing_to_inside (d, state, c) ? "in" : "out");
}
f = next_edge (d, state, f);
if (f == e)
break;
}
printf (")");
}
}