Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

1035600 views
1
//
2
// main.cpp
3
// Bistellar
4
//
5
// Created by Alexander Thumm on 07.10.11.
6
// Copyright 2011 -. All rights reserved.
7
//
8
9
#include <iostream>
10
#include <sstream>
11
#include <string>
12
#include "types.h"
13
#include "movable_complex.h"
14
#include "face.h"
15
#include "util.h"
16
#include "randomize_complex.h"
17
#include "reduce_complex.h"
18
19
int main (int argc, const char * argv[])
20
{
21
std::istream & in = std::cin;
22
23
while (true)
24
{
25
std::string line;
26
std::getline(in, line);
27
std::stringstream sstream(line);
28
29
std::string command;
30
sstream >> command;
31
32
if (command.compare("randomize") == 0)
33
{
34
MovableComplex complex;
35
sstream >> complex;
36
37
std::vector< unsigned int > allowedMoves;
38
for (unsigned int i = 0; i < complex.dimension()+1; i++)
39
allowedMoves.push_back(i);
40
41
unsigned int rounds = 50;
42
43
std::string nextToken;
44
while (sstream >> nextToken)
45
{
46
std::stringstream token(nextToken);
47
48
if (token.str().compare(0,12,"allowedMoves") == 0)
49
{
50
token.ignore(token.str().length(),'=');
51
std::vector< unsigned int > newAllowedMoves;
52
list_read(token, newAllowedMoves);
53
allowedMoves = newAllowedMoves;
54
}
55
else if (token.str().compare(0,6,"rounds") == 0)
56
{
57
token.ignore(token.str().length(),'=');
58
token >> rounds;
59
}
60
}
61
62
randomize_complex(complex, allowedMoves, rounds);
63
64
std::cout << "resulting complex is " << complex << std::endl;
65
}
66
else if (command.compare("reduce") == 0)
67
{
68
MovableComplex complex;
69
sstream >> complex;
70
71
unsigned int rounds = 10000;
72
int heating = 0;
73
int relaxation = 4;
74
75
std::string nextToken;
76
while (sstream >> nextToken)
77
{
78
std::stringstream token(nextToken);
79
80
if (token.str().compare(0,6,"rounds") == 0)
81
{
82
token.ignore(token.str().length(),'=');
83
token >> rounds;
84
}
85
else if (token.str().compare(0,7,"heating") == 0)
86
{
87
token.ignore(token.str().length(),'=');
88
token >> heating;
89
}
90
else if (token.str().compare(0,9,"relaxation") == 0)
91
{
92
token.ignore(token.str().length(),'=');
93
token >> relaxation;
94
}
95
}
96
97
reduce_complex(complex, rounds, heating, relaxation);
98
99
std::cout << "resulting complex is " << complex << " with " << complex.f(0) << " vertices" << std::endl;
100
}
101
else if (command.compare("quit") == 0)
102
{
103
break;
104
}
105
else
106
{
107
std::cout << "possible commands are:" << std::endl;
108
std::cout << "- \"reduce %c with %o\", where %c is a complex given as facet list and %o are options." << std::endl;
109
std::cout << "\texample: \"reduce [[1,2],[2,3],[3,4],[4,1]] with rounds=10, heating=0 and relaxation=4\"" << std::endl;
110
std::cout << "- \"randomize %c with %o\", where %c is a complex given as facet list and %o are options." << std::endl;
111
std::cout << "\texample: \"randomize [[1,2,3],[1,2,4],[1,3,4],[2,3,4]] with rounds=10 and allowedMoves=[0,1]\"" << std::endl;
112
std::cout << "- \"quit\"" << std::endl;
113
}
114
}
115
116
return 0;
117
}
118
119
120