-
Notifications
You must be signed in to change notification settings - Fork 1
/
fenchelnielsenconstructor.cpp
364 lines (301 loc) · 12.1 KB
/
fenchelnielsenconstructor.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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
#include "fenchelnielsenconstructor.h"
#include "canvas.h"
#include "h2canvasdelegate.h"
PantsTree::PantsTree(uint index, const std::vector<double> &CoshHalfLengthsAugmented,
const std::vector<double> &SinhHalfLengthsAugmented, const std::string & genericCurveName) : index(index)
{
double Cup = CoshHalfLengthsAugmented[index-1];
double Cleft = CoshHalfLengthsAugmented[2*index-1];
double Cright = CoshHalfLengthsAugmented[2*index];
double Sup = SinhHalfLengthsAugmented[index-1];
double Sleft = SinhHalfLengthsAugmented[2*index-1];
double Sright = SinhHalfLengthsAugmented[2*index];
std::string sup = Tools::convertToString(index), sleft = Tools::convertToString(2*index), sright = Tools::convertToString(2*index + 1);
generatorName up, left, right;
up.append(genericCurveName).append(sup).append("down");
left.append(genericCurveName).append(sleft).append("up");
right.append(genericCurveName).append(sright).append("up");
rho.setNormalizedPairOfPantsRepresentation(up, left, right, Cup, Cleft, Cright, Sup, Sleft, Sright, up);
H2Isometry fRight;
rho.getGeneratorImage(right, fRight);
H2Geodesic L;
fRight.axis(L);
twistCorrection = H2Isometry::geodesicNormalizer(L);
}
PantsTreeNode::PantsTreeNode(uint index, const std::vector<double> & coshHalfLengthsAugmented, const std::vector<double> & sinhHalfLengthsAugmented,
const std::vector<double> & twistsNormalized, const std::string & genericCurveName)
: PantsTree(index, coshHalfLengthsAugmented, sinhHalfLengthsAugmented, genericCurveName)
{
uint N = twistsNormalized.size();
if(8*index >= N)
{
leftChild = new PantsTreeLeaf(2*index, coshHalfLengthsAugmented, sinhHalfLengthsAugmented, twistsNormalized, genericCurveName);
}
else
{
leftChild = new PantsTreeNode(2*index, coshHalfLengthsAugmented, sinhHalfLengthsAugmented, twistsNormalized, genericCurveName);
}
if(8*index +4 >= N)
{
rightChild = new PantsTreeLeaf(2*index+1, coshHalfLengthsAugmented, sinhHalfLengthsAugmented, twistsNormalized, genericCurveName);
}
else
{
rightChild = new PantsTreeNode(2*index+1, coshHalfLengthsAugmented, sinhHalfLengthsAugmented, twistsNormalized, genericCurveName);
}
double twistCorrectionLeft = leftChild->twistCorrection, twistCorrectionright = rightChild->twistCorrection;
std::vector<H2Isometry> upleftright = rho.getGeneratorImages();
H2Isometry fUp = upleftright[0], fLeft = upleftright[1], fRight= upleftright[2];
conjugatorLeft.setByNormalizingPairOnLeftHandSide(fLeft, fUp);
H2Isometry twister;
twister.setVerticalTranslation(-twistsNormalized[2*index-1], twistCorrectionLeft);
conjugatorLeft = twister*conjugatorLeft;
conjugatorLeft = conjugatorLeft.inverse();
conjugatorRight.setByNormalizingPairOnLeftHandSide(fRight, fLeft);
twister.setVerticalTranslation(-twistsNormalized[2*index], twistCorrectionright);
conjugatorRight = twister*conjugatorRight;
conjugatorRight = conjugatorRight.inverse();
}
PantsTreeNode::~PantsTreeNode()
{
delete leftChild;
delete rightChild;
}
GroupRepresentation<H2Isometry> PantsTreeNode::getRepresentation(H2Isometry &totalConjugator, const std::string &genericCurveName)
{
H2Isometry totalConjugatorLeft = totalConjugator*conjugatorLeft;
H2Isometry totalConjugatorRight = totalConjugator*conjugatorRight;
std::vector<generatorName> generators = rho.getDiscreteGroup().getGenerators();
GroupRepresentation<H2Isometry> rhobis = rho.conjugate(totalConjugator);
GroupRepresentation<H2Isometry> leftrho = leftChild->getRepresentation(totalConjugatorLeft, genericCurveName);
GroupRepresentation<H2Isometry> rightrho = rightChild->getRepresentation(totalConjugatorRight, genericCurveName);
GroupRepresentation<H2Isometry> temprho = GroupRepresentation<H2Isometry>::amalgamateOverInverse(rhobis,generators[1],leftrho,
leftChild->rho.getDiscreteGroup().getGenerators()[0]);
return GroupRepresentation<H2Isometry>::amalgamateOverInverse(temprho,generators[2],rightrho,rightChild->rho.getDiscreteGroup().getGenerators()[0]);
}
PantsTreeLeaf::PantsTreeLeaf(uint index, const std::vector<double> &coshHalfLengthsAugmented, const std::vector<double> &sinhHalfLengthsAugmented,
const std::vector<double> &twistsNormalized, const std::string & genericCurveName) :
PantsTree(index, coshHalfLengthsAugmented, sinhHalfLengthsAugmented, genericCurveName)
{
std::vector<H2Isometry> upleftright = rho.getGeneratorImages();
H2Isometry fLeft = upleftright[1], fUp = upleftright[0], fRight= upleftright[2];
hNNconjugator = H2Isometry::findConjugatorForGluing(fRight, fLeft, fLeft, fUp, twistsNormalized[2*index-1]);
}
PantsTreeLeaf::~PantsTreeLeaf()
{
}
GroupRepresentation<H2Isometry> PantsTreeLeaf::getRepresentation(H2Isometry &totalConjugator, const std::string & genericCurveName)
{
std::string s = Tools::convertToString(index);
generatorName stableLetter;
stableLetter.append(genericCurveName).append("s").append(s);
auto generators = rho.getDiscreteGroup().getGenerators();
return (GroupRepresentation<H2Isometry>::HNNextensionOverInverse(rho, generators[2], generators[1], stableLetter, hNNconjugator)).conjugate(totalConjugator);
}
FenchelNielsenConstructor::FenchelNielsenConstructor(const std::vector<double> &lengths, const std::vector<double> &twists)
{
this->lengths = lengths;
this->twists = twists;
genus=lengths.size()/3 + 1;
gLeft = genus/2;
gRight = genus - gLeft;
setNormalizedLengths();
setNormalizedTwists();
splitAugmentedLengthsAndTwists();
firstTwist = nTwists[0];
if(gLeft>1)
{
LeftTree = new PantsTreeNode(1, cLengthsLeft, sLengthsLeft, nTwistsLeft, "c");
}
else
{
LeftTree = new PantsTreeLeaf(1, cLengthsLeft, sLengthsLeft, nTwistsLeft, "c");
}
if(gRight>1)
{
RightTree = new PantsTreeNode(1, cLengthsRight, sLengthsRight, nTwistsRight, "d");
}
else
{
RightTree = new PantsTreeLeaf(1, cLengthsRight, sLengthsRight, nTwistsRight, "d");
}
}
FenchelNielsenConstructor::~FenchelNielsenConstructor()
{
delete LeftTree;
delete RightTree;
}
void FenchelNielsenConstructor::setNormalizedTwists()
{
double l, twistOut;
nTwists.clear();
nTwists.reserve(twists.size());
for (auto twist : twists)
{
l = cosh(twist);
twistOut = sqrt((l-1.0)/(l+1.0));
if (twist < 0)
{
twistOut = -twistOut;
}
nTwists.push_back(twistOut);
}
}
void FenchelNielsenConstructor::setNormalizedLengths()
{
cLengths.clear();
sLengths.clear();
cLengths.reserve(lengths.size());
sLengths.reserve(lengths.size());
for (const auto length : lengths)
{
cLengths.push_back(cosh(0.5*length));
sLengths.push_back(sinh(0.5*length));
}
}
void FenchelNielsenConstructor::splitAugmentedLengthsAndTwists()
{
for (uint i1=0; i1 != 2*gLeft - 1; ++i1)
{
cLengthsLeft.push_back(cLengths[i1]);
sLengthsLeft.push_back(sLengths[i1]);
nTwistsLeft.push_back(nTwists[i1]);
}
// what follows is for the leaves
for (uint i2=2*gLeft-1; i2 != 3*gLeft - 1; ++i2)
{
cLengthsLeft.push_back(cLengths[i2]);
sLengthsLeft.push_back(sLengths[i2]);
nTwistsLeft.push_back(nTwists[i2]);
cLengthsLeft.push_back(cLengths[i2]);
sLengthsLeft.push_back(sLengths[i2]);
nTwistsLeft.push_back(nTwists[i2]);
}
cLengthsRight.push_back(cLengthsLeft[0]);
sLengthsRight.push_back(sLengthsLeft[0]);
nTwistsRight.push_back(nTwists[0]);
for (uint j1=0; j1 != 2*gRight - 2; j1++)
{
cLengthsRight.push_back(cLengths[j1 + 3*gLeft - 1]);
sLengthsRight.push_back(sLengths[j1 + 3*gLeft - 1]);
nTwistsRight.push_back(nTwists[j1 + 3*gLeft - 1]);
}
// what follows is for the leaves
for (uint j2=2*gRight-2; j2 != 3*gRight - 2; j2++)
{
cLengthsRight.push_back(cLengths[j2 + 3*gLeft - 1]);
sLengthsRight.push_back(sLengths[j2 + 3*gLeft - 1]);
nTwistsRight.push_back(nTwists[j2 + 3*gLeft - 1]);
cLengthsRight.push_back(cLengths[j2 + 3*gLeft - 1]);
sLengthsRight.push_back(sLengths[j2 + 3*gLeft - 1]);
nTwistsRight.push_back(nTwists[j2 + 3*gLeft -1]);
}
}
GroupRepresentation<H2Isometry> FenchelNielsenConstructor::getUnnormalizedRepresentation()
{
H2Isometry id;
id.setIdentity();
/*H2Isometry twister;
twister.setVerticalTranslation(firstTwist, LeftTree->twistCorrection, - RightTree->twistCorrection);
H2Isometry halfTurn;
halfTurn.setDiskCoordinates(-1.0, 0.0);*/
H2Isometry c, c2;
c.setVerticalTranslation(firstTwist);
H2Isometry halfTurn;
halfTurn.setDiskCoordinates(-1.0, 0.0);
c2.setVerticalTranslation(RightTree->twistCorrection);
c2 = halfTurn*c2;
H2Isometry totalConjugatorRight = c*c2;
H2Isometry totalConjugatorLeft;
totalConjugatorLeft.setVerticalTranslation(LeftTree->twistCorrection);
GroupRepresentation<H2Isometry> rhoLeft = LeftTree->getRepresentation(totalConjugatorLeft, "c");
GroupRepresentation<H2Isometry> rhoRight = RightTree->getRepresentation(totalConjugatorRight, "d");
return GroupRepresentation<H2Isometry>::amalgamateOverInverse(rhoLeft, "c1down", rhoRight, "d1down");
}
GroupRepresentation<H2Isometry> FenchelNielsenConstructor::getRepresentation()
{
GroupRepresentation<H2Isometry> rhoU = getUnnormalizedRepresentation();
GroupRepresentation<H2Isometry> rho(DiscreteGroup(TopologicalSurface(genus, 0)));
std::string s;
generatorName ai, bi;
uint gleft = genus/2;
uint gright = genus - gleft;
std::vector<H2Isometry> rhoIsometry;
H2Isometry tempIsom;
uint powerOfTwo=1;
while(powerOfTwo<gright)
{
powerOfTwo*=2;
}
for(uint i = powerOfTwo ; i!=2*gleft; ++i)
{
s = Tools::convertToString(i);
ai = "c";
ai.append("s").append(s);
rhoU.getGeneratorImage(ai,tempIsom);
rhoIsometry.push_back(tempIsom.inverse());
s = Tools::convertToString(2*(i)+1);
bi = "c";
bi.append(s).append("up");
rhoU.getGeneratorImage(bi,tempIsom);
rhoIsometry.push_back(tempIsom);
}
for(uint i = gleft ; i!=powerOfTwo ;++i)
{
s = Tools::convertToString(i);
ai = "c";
ai.append("s").append(s);
rhoU.getGeneratorImage(ai,tempIsom);
rhoIsometry.push_back(tempIsom.inverse());
s = Tools::convertToString(2*(i)+1);
bi = "c";
bi.append(s).append("up");
rhoU.getGeneratorImage(bi,tempIsom);
rhoIsometry.push_back(tempIsom);
}
powerOfTwo=1;
while(powerOfTwo<gright)
{
powerOfTwo*=2;
}
for(uint i = powerOfTwo ; i!=2*gright; ++i)
{
s = Tools::convertToString(i);
bi = "d";
bi.append("s").append(s);
if(!rhoU.getGeneratorImage(bi,tempIsom))
{
throw(QString("Error in FenchelNielsenConstructor::getRepresentation"));
}
rhoIsometry.push_back(tempIsom.inverse());
s = Tools::convertToString(2*(i)+1);
ai = "d";
ai.append(s).append("up");
if(!rhoU.getGeneratorImage(ai,tempIsom))
{
throw(QString("Error in FenchelNielsenConstructor::getRepresentation"));
}
rhoIsometry.push_back(tempIsom);
}
for(uint i = gright ; i != powerOfTwo; ++i)
{
s = Tools::convertToString(i);
bi = "d";
bi.append("s").append(s);
if(!rhoU.getGeneratorImage(bi,tempIsom))
{
throw(QString("Error in FenchelNielsenConstructor::getRepresentation"));
}
rhoIsometry.push_back(tempIsom.inverse());
s = Tools::convertToString(2*(i)+1);
ai = "d";
ai.append(s).append("up");
if(!rhoU.getGeneratorImage(ai,tempIsom))
{
throw(QString("Error in FenchelNielsenConstructor::getRepresentation"));
}
rhoIsometry.push_back(tempIsom);
}
rho.generatorImages = rhoIsometry;
return rho;
}