Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added coxeter_group_orbits/Auswertung.ods
Binary file not shown.
Binary file added coxeter_group_orbits/constantin/calc_orbit
Binary file not shown.
123 changes: 123 additions & 0 deletions coxeter_group_orbits/constantin/calc_orbit.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* Copyright (c) 2015
Constantin Fischer
cfischer@mailbox.tu-berlin.de

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version: http://www.gnu.org/licenses/gpl.txt.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
--------------------------------------------------------------------------------
*/

#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <array>
#include <numeric>
#include <cmath>
#include <set>
#include "orbit.h"
#include <iostream>
//#include <algorithm>
//#include "stdlib.h"

//determining the current RAM usage (from http://stackoverflow.com/questions/63166/how-to-determine-cpu-and-memory-consumption-from-inside-a-process)
#include "stdlib.h"
#include "stdio.h"
#include "string.h"

int parseLine(char* line){
int i = strlen(line);
while (*line < '0' || *line > '9') line++;
line[i-3] = '\0';
i = atoi(line);
return i;
}


int getValue(){ //Note: this value is in KB!
FILE* file = fopen("/proc/self/status", "r");
int result = -1;
char line[128];


while (fgets(line, 128, file) != NULL){
if (strncmp(line, "VmRSS:", 6) == 0){
result = parseLine(line);
break;
}
}
fclose(file);
return result;
}

int main(int argc, char *argv[])
{
std::ifstream iFile(argv[1]);
std::ofstream oFile(argv[2]);
std::string input = "";
char type;
int dim;
VectorType point;
bool print_flag = false;
if (argc == 4) {
std::string flag(argv[3]);
print_flag = flag == "-p";
}

//read the input file
if (iFile.is_open()) {
//read the type and dimension
if (iFile.good()) {
std::getline(iFile, input);
std::stringstream ss(input);
if (ss.good()) {
char t;
if (ss >> t) {
type = t;
}
int d;
if (ss >> d) {
dim = d;
}
}
}
//read the input point
if (iFile.good()) {
std::getline(iFile, input);
std::stringstream ss(input);
long double coo = 0;
while (ss.good()) {
if (ss >> coo) {
point.push_back(coo);
}
}
}
}

std::set<VectorType, Error_radius_comp> orb = orbit(simple_roots(type,dim),point);

//generate the output
if (oFile.is_open()) {
oFile << orb.size() << std::endl;
if (print_flag) {
for (auto p : orb) {
for (size_t i=0; i<p.size(); ++i) {
oFile << p[i] << " ";
}
oFile << std::endl;
}
}
}

std::cout << "orbit size = " << orb.size() << std::endl;
std::cout << "RAM usage = " << getValue()/1000 << "mB" << std::endl;

return 0;
}
4 changes: 4 additions & 0 deletions coxeter_group_orbits/constantin/exercise/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1 1
1
22.2 0
0 7.4
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2015
Constantin Fischer
cfischer@mailbox.tu-berlin.de

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version: http://www.gnu.org/licenses/gpl.txt.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
--------------------------------------------------------------------------------
*/

#include <fstream>
#include <sstream>
#include <string>
Expand All @@ -6,8 +22,6 @@
#include <numeric>
#include <cmath>
#include <set>
//#include <algorithm>
//#include "stdlib.h"

int main()
{
Expand Down Expand Up @@ -62,22 +76,14 @@ int main()
//normalize the normal vectors
for (int i=0; i<normals.size(); ++i) {
double euclidLength = 0;
//std::accumulate(normals[i].begin(), normals[i].end, 0);
//for (int j=0; j<normals[i].size(); ++j) {
// euclidLength += std::pow(normals[i][j],2);
//}
euclidLength = std::inner_product(normals[i].begin(), normals[i].end(), normals[i].begin(), euclidLength); //return type equals the type of the start value
test = euclidLength;
euclidLength = std::sqrt(euclidLength);
for (int j=0; j<normals[i].size(); ++j) {
normals[i][j] = normals[i][j] / euclidLength;
}
}

//generate all words in the generators given by the normal vectors with length up to wordLength
// // std::vector<int> words(normals.size()-1);
// words.reserve(normals.size()-1);
// std::iota(words.begin(), words.end(),0);

//generate the orbit (up to wordLength)
std::set<std::vector<double> > orbit = {point};
Expand Down Expand Up @@ -111,9 +117,6 @@ int main()
oFile << normals[i][j] << " ";
}
}
// for (int i=0; i<words.size(); ++i) {
// oFile << words[i] << " ";
// }
oFile << std::endl << "orbit:" << std::endl;
for (auto p : orbit) {
for (int i=0; i<p.size(); ++i) {
Expand Down
11 changes: 11 additions & 0 deletions coxeter_group_orbits/constantin/exercise/output
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
reference point:
1 1
number of iterated refelctions:
1
normalized normal vectors:
1 0
0 1
orbit:
-1 1
1 -1
1 1
Loading