diff --git a/coxeter_group_orbits/Auswertung.ods b/coxeter_group_orbits/Auswertung.ods new file mode 100644 index 0000000..29ea76a Binary files /dev/null and b/coxeter_group_orbits/Auswertung.ods differ diff --git a/coxeter_group_orbits/constantin/calc_orbit b/coxeter_group_orbits/constantin/calc_orbit new file mode 100755 index 0000000..d6cfbc0 Binary files /dev/null and b/coxeter_group_orbits/constantin/calc_orbit differ diff --git a/coxeter_group_orbits/constantin/calc_orbit.cc b/coxeter_group_orbits/constantin/calc_orbit.cc new file mode 100644 index 0000000..aef5548 --- /dev/null +++ b/coxeter_group_orbits/constantin/calc_orbit.cc @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include "orbit.h" +#include +//#include +//#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 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 #include #include @@ -6,8 +22,6 @@ #include #include #include -//#include -//#include "stdlib.h" int main() { @@ -62,12 +76,7 @@ int main() //normalize the normal vectors for (int i=0; i words(normals.size()-1); -// words.reserve(normals.size()-1); -// std::iota(words.begin(), words.end(),0); //generate the orbit (up to wordLength) std::set > orbit = {point}; @@ -111,9 +117,6 @@ int main() oFile << normals[i][j] << " "; } } -// for (int i=0; i +#include +#include +#include "types.h" + + +GeneratorList simple_roots_type_A (const int n) +{ + /* + Read rowwise, these simple root vectors are + 1 -1 0 0 ... 0 0 + 0 1 -1 0 ... 0 0 + ... + 0 0 0 0 ... 1 -1 + In particular, they lie in the plane (sum of coordinates = 0) + */ + GeneratorList R(n, n+1); + for (int i=0; i n-1, + */ + VectorType v(n); + v[n-1] = 1; + GeneratorList G = simple_roots_type_A(n-1); + G.push_back(v); + return G; +} + +GeneratorList simple_roots_type_C (const int n) +{ + /* + Read rowwise, these simple root vectors are + 1 -1 0 0 ... 0 0 + 0 1 -1 0 ... 0 0 + ... + 0 0 0 0 ... 1 -1 + 0 0 0 0 ... 0 2 + + The Dynkin diagram is: + + 0 ---- 1 ---- ... ---- n-2 <--(4)-- n-1, + */ + VectorType v(n); + v[n-1] = 2; + GeneratorList G = simple_roots_type_A(n-1); + G.push_back(v); + return G; +} + +GeneratorList simple_roots_type_D (const int n) +{ + /* + Read rowwise, these simple root vectors are + 1 -1 0 0 ... 0 0 + 0 1 -1 0 ... 0 0 + ... + 0 0 0 0 ... 1 -1 + 0 0 0 0 ... 1 1 + The indexing of the Dynkin diagram is + + n-2 + / + 0 - 1 - 2 - ... - n-3 + \ + n-1 + + */ + VectorType v(n); + v[n-2] = v[n-1] = 1; + GeneratorList G = simple_roots_type_A(n-1); + G.push_back(v); + return G; +} + +GeneratorList simple_roots_type_E6() +{ + /* + Read rowwise, these simple root vectors are + 1 -1 0 0 0 0 + 0 1 -1 0 0 0 + 0 0 1 -1 0 0 + 0 0 0 1 -1 0 + 0 0 0 1 1 0 +-1/2(1 1 1 1 1 -sqrt(3)) + + The indexing of the Dynkin diagram is + + + 3 + | + | + 0 ---- 1 ---- 2 ---- 4 ---- 5 + + */ + VectorType v(6); + for (int i=0; i<5; ++i) + v[i] = -0.5; + v[5] = 0.5 * sqrt(3); + GeneratorList G = simple_roots_type_D(5); + for (int i=0; i<5; ++i) + G[i].push_back(0); + G.push_back(v); + return G; +} + +GeneratorList simple_roots_type_E7() +{ + /* + Read rowwise, these simple root vectors are + 1 -1 0 0 0 0 0 + 0 1 -1 0 0 0 0 + 0 0 1 -1 0 0 0 + 0 0 0 1 -1 0 0 + 0 0 0 0 1 -1 0 + 0 0 0 0 1 1 0 +-1/2(1 1 1 1 1 1 -sqrt(2)) + + The indexing of the Dynkin diagram is + + + 4 + | + | + 0 ---- 1 ---- 2 ---- 3 ---- 5 ---- 6 + + */ + VectorType v(7); + for (int i=0; i<6; ++i) + v[i] = -0.5; + v[6] = 0.5 * sqrt(2); + GeneratorList G = simple_roots_type_D(6); + for (int i=0; i<6; ++i) + G[i].push_back(0); + G.push_back(v); + return G; +} + +GeneratorList simple_roots_type_E8() +{ + /* + Read rowwise, these simple root vectors are + 1 -1 0 0 0 0 0 0 + 0 1 -1 0 0 0 0 0 + ... + 0 0 0 0 0 1 -1 0 + 0 0 0 0 0 1 1 0 +-1/2(1 1 1 1 1 1 1 1) + + These are the coordinates in the even coordinate system. + The indexing of the Dynkin diagram is + + + 5 + | + | + 0 ---- 1 ---- 2 ---- 3 ---- 4 ---- 6 ---- 7 + + */ + VectorType v(8); + for (int i=0; i<8; ++i) + v[i] = -0.5; + GeneratorList G = simple_roots_type_D(7); + for (int i=0; i<7; ++i) + G[i].push_back(0); + G.push_back(v); + return G; +} + +GeneratorList simple_roots_type_F4() +{ + /* + Read rowwise, these simple root vectors are + 1 -1 0 0 + 0 1 -1 0 + 0 0 1 0 + -1/2 -1/2 -1/2 -1/2 + + The Dynkin diagram is: + + 0 ---- 1 --(4)--> 2 ---- 3 + */ + GeneratorList R(4,4); + R(0,0) = R(1,1) = R(2,2) = 1; + R(0,1) = R(1,2) = -1; + R(3,0) = R(3,1) = R(3,2) = R(3,3) = -0.5; + return R; +} + +GeneratorList simple_roots_type_G2() +{ + /* + Read rowwise, these simple root vectors are + 1 -1 0 + -1 2 -1 + + Notice that each row sums to zero. + + The Dynkin diagram is: + + 0 <--(6)-- 1 + */ + GeneratorList R(2,3); + R(0,0) = 1; + R(0,1) = R(1,0) = R(1,2) = -1; + R(1,1) = 2; + return R; +} + +GeneratorList simple_roots_type_H3() +{ + const NumberType tau(0.5 + 0.5 * sqrt(5)); // golden ratio + + /* + For H_3, the Dynkin diagram is + + 0 --(5)-- 1 ---- 2, + + and the simple root vectors are, + + 2 0 0 + a b -1 + 0 0 2 + + with a=-tau and b=1/tau. Notice they all have length 2. + + */ + + GeneratorList R(3,3); + R(0,0) = R(2,2) = 2; + R(1,0) = -tau; R(1,1) = tau - 1; R(1,2) = -1; + return R; +} + +GeneratorList simple_roots_type_H4() +{ + const NumberType tau(0.5 + 0.5 * sqrt(5)); // golden ratio + + /* + For H_4, the Dynkin diagram is + + 0 --(5)-- 1 ---- 2 ---- 3, + + and the simple root vectors are, according to + [John H. Stembridge, A construction of H_4 without miracles, + Discrete Comput. Geom. 22, No.3, 425-427 (1999)], + + a b b b + -1 1 0 0 + 0 -1 1 0 + 0 0 -1 1 + + with a=(1+tau)/2 and b=(1-tau)/2, so that the length of each root is sqrt{2}. + + */ + GeneratorList R(4, 4); + + R(0,0) = (1+tau) * 0.5; + R(0,1) = R(0,2) = R(0,3) = (1-tau) * 0.5; + + for (int i=0; i<3; ++i) { + R(i+1, i) = -1; + R(i+1, i+1) = 1; + } + return R; +} + + + +GeneratorList simple_roots(char type, int dim) +{ + switch(type) { + case 'a': + case 'A': + return simple_roots_type_A(dim); + + case 'b': + case 'B': + return simple_roots_type_B(dim); + + case 'c': + case 'C': + return simple_roots_type_C(dim); + + case 'd': + case 'D': + return simple_roots_type_D(dim); + + case 'e': + case 'E': + switch(dim) { + case 6: + return simple_roots_type_E6(); + case 7: + return simple_roots_type_E7(); + case 8: + return simple_roots_type_E8(); + default: + throw InvalidGroupException(); + } + + case 'f': + case 'F': + switch(dim) { + case 4: + return simple_roots_type_F4(); + default: + throw InvalidGroupException(); + } + + case 'g': + case 'G': + switch(dim) { + case 2: + return simple_roots_type_G2(); + default: + throw InvalidGroupException(); + } + + case 'h': + case 'H': + switch(dim) { + case 3: + return simple_roots_type_H3(); + case 4: + return simple_roots_type_H4(); + default: + throw InvalidGroupException(); + } + + default: + throw NotImplementedException(); + } +} + +#endif // __GENERATORS_H_ + +// Local Variables: +// mode:C++ +// c-basic-offset:3 +// indent-tabs-mode:nil +// End: diff --git a/coxeter_group_orbits/constantin/input b/coxeter_group_orbits/constantin/input index b3f00ca..f1db73e 100644 --- a/coxeter_group_orbits/constantin/input +++ b/coxeter_group_orbits/constantin/input @@ -1,4 +1,2 @@ -1 1 -1 -22.2 0 -0 7.4 +B6 +1.4 0.2 4.3 4.4 17.5 4 diff --git a/coxeter_group_orbits/constantin/orbit.h b/coxeter_group_orbits/constantin/orbit.h new file mode 100644 index 0000000..19bb344 --- /dev/null +++ b/coxeter_group_orbits/constantin/orbit.h @@ -0,0 +1,86 @@ +/* Copyright (c) 2015 + Julian Pfeifle + julian.pfeifle@upc.edu + 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. +-------------------------------------------------------------------------------- +*/ + +#ifndef __ORBIT_H_ +#define __ORBIT_H_ + +#include +#include "types.h" +#include "generators.h" +#include +#include +# include +#include + +struct Error_radius_comp { + const NumberType error_radius = 0.00001; + bool operator() (const VectorType& lhs, const VectorType& rhs) const { + for (size_t i=0; i error_radius) { + return lhs[i] < rhs[i]; + } + } + + return false; + } +}; + +std::set orbit(const GeneratorList& generators, const VectorType& v) +{ + if (generators[0].size() != v.size()) { + throw DimensionMismatchException(); + } + + NumberType ip = 0; + GeneratorList scaled_generators(generators.size(),generators[0].size()); + for (size_t i=0; i(),2/ip)); //type sensitive operation + } + + std::set orbit({v}); + std::queue newPoints({v}); + VectorType mirrorPoint(v.size()); + NumberType weight = 0; + do { + mirrorPoint = newPoints.front(); + newPoints.pop(); + for (size_t i=0; i +#include +#include +#include + + +template +inline std::ostream& +operator<<(std::ostream& wrapped, const std::array& item) +{ + wrapped << '{'; + bool first = true; + for (auto const& element : item) { + wrapped << (!first ? "," : "") << element; + first = false; + } + return wrapped << '}'; +} + + +// teach Boost.Test how to print std::vector +template +inline std::ostream& +operator<<(std::ostream& wrapped, std::vector const& item) +{ + wrapped << '{'; + bool first = true; + for (auto const& element : item) { + wrapped << (!first ? "," : "") << element; + first = false; + } + return wrapped << '}'; +} + +template +inline std::ostream& +operator<<(std::ostream& wrapped, std::pair const& item) +{ + return wrapped << '<' << item.first << ',' << item.second << '>'; +} + +template +inline std::ostream& +operator<<(std::ostream& wrapped, std::map const& item) +{ + wrapped << '{'; + bool first = true; + for (auto const& element : item) { + wrapped << (!first ? "," : "") << element; + first = false; + } + return wrapped << '}'; +} + + +//#endif // __STL_WRAPPERS_H__ + + +// Local Variables: +// mode:C++ +// c-basic-offset:3 +// indent-tabs-mode:nil +// End: + diff --git a/coxeter_group_orbits/constantin/test_orbits.cc b/coxeter_group_orbits/constantin/test_orbits.cc new file mode 100644 index 0000000..d061d0c --- /dev/null +++ b/coxeter_group_orbits/constantin/test_orbits.cc @@ -0,0 +1,98 @@ +/* Copyright (c) 2015 + Julian Pfeifle + julian.pfeifle@upc.edu + + 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. +-------------------------------------------------------------------------------- +*/ + +#define BOOST_TEST_MODULE orbits +#include + +#include "orbit.h" +#include "stl_wrappers.h" + +BOOST_AUTO_TEST_CASE( generators ) +{ + std::ostringstream oss; + oss << simple_roots_type_A(4) << std::endl + << simple_roots_type_B(4) << std::endl + << simple_roots_type_C(4) << std::endl + << simple_roots_type_D(4) << std::endl + << simple_roots_type_E6() << std::endl + << simple_roots_type_E7() << std::endl + << simple_roots_type_E8() << std::endl + << simple_roots_type_F4() << std::endl + << simple_roots_type_H3() << std::endl + << simple_roots_type_H4() << std::endl; + + BOOST_CHECK_EQUAL(oss.str(), + "{{1,-1,0,0,0},{0,1,-1,0,0},{0,0,1,-1,0},{0,0,0,1,-1}}\n" + "{{1,-1,0,0},{0,1,-1,0},{0,0,1,-1},{0,0,0,1}}\n" + "{{1,-1,0,0},{0,1,-1,0},{0,0,1,-1},{0,0,0,2}}\n" + "{{1,-1,0,0},{0,1,-1,0},{0,0,1,-1},{0,0,1,1}}\n" + "{{1,-1,0,0,0,0},{0,1,-1,0,0,0},{0,0,1,-1,0,0},{0,0,0,1,-1,0},{0,0,0,1,1,0},{-0.5,-0.5,-0.5,-0.5,-0.5,0.866025}}\n" + "{{1,-1,0,0,0,0,0},{0,1,-1,0,0,0,0},{0,0,1,-1,0,0,0},{0,0,0,1,-1,0,0},{0,0,0,0,1,-1,0},{0,0,0,0,1,1,0},{-0.5,-0.5,-0.5,-0.5,-0.5,-0.5,0.707107}}\n" + "{{1,-1,0,0,0,0,0,0},{0,1,-1,0,0,0,0,0},{0,0,1,-1,0,0,0,0},{0,0,0,1,-1,0,0,0},{0,0,0,0,1,-1,0,0},{0,0,0,0,0,1,-1,0},{0,0,0,0,0,1,1,0},{-0.5,-0.5,-0.5,-0.5,-0.5,-0.5,-0.5,-0.5}}\n" + "{{1,-1,0,0},{0,1,-1,0},{0,0,1,0},{-0.5,-0.5,-0.5,-0.5}}\n" + "{{2,0,0},{-1.61803,0.618034,-1},{0,0,2}}\n" + "{{1.30902,-0.309017,-0.309017,-0.309017},{-1,1,0,0},{0,-1,1,0},{0,0,-1,1}}\n" + ); +} + +struct b3_fixture { + b3_fixture() + : generators(simple_roots('B', 3)) + {} + GeneratorList generators; +}; + +BOOST_FIXTURE_TEST_CASE( b3_orbit_012, b3_fixture ) +{ + BOOST_CHECK_EQUAL(orbit(generators, {1, 2, 3}).size(), (size_t) 48); +} + +BOOST_FIXTURE_TEST_CASE( b3_orbit_12, b3_fixture ) +{ + BOOST_CHECK_EQUAL(orbit(generators, {1, 1, 3}).size(), (size_t) 24); +} + +BOOST_FIXTURE_TEST_CASE( b3_orbit_02, b3_fixture ) +{ + BOOST_CHECK_EQUAL(orbit(generators, {1, 2, 2}).size(), (size_t) 24); +} + +BOOST_FIXTURE_TEST_CASE( b3_orbit_01, b3_fixture ) +{ + BOOST_CHECK_EQUAL(orbit(generators, {1, 2, 0}).size(), (size_t) 24); +} + +BOOST_FIXTURE_TEST_CASE( b3_orbit_0, b3_fixture ) +{ + BOOST_CHECK_EQUAL(orbit(generators, {1, 0, 0}).size(), (size_t) 6); +} + +BOOST_FIXTURE_TEST_CASE( b3_orbit_1, b3_fixture ) +{ + BOOST_CHECK_EQUAL(orbit(generators, {1, 1, 0}).size(), (size_t) 12); +} + +BOOST_FIXTURE_TEST_CASE( b3_orbit_2, b3_fixture ) +{ + BOOST_CHECK_EQUAL(orbit(generators, {1, 1, 1}).size(), (size_t) 8); +} + + +// Local Variables: +// mode:C++ +// c-basic-offset:3 +// indent-tabs-mode:nil +// End: diff --git a/coxeter_group_orbits/constantin/types.h b/coxeter_group_orbits/constantin/types.h new file mode 100644 index 0000000..0e32045 --- /dev/null +++ b/coxeter_group_orbits/constantin/types.h @@ -0,0 +1,57 @@ +/* Copyright (c) 2015 + Julian Pfeifle + julian.pfeifle@upc.edu + + 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. +-------------------------------------------------------------------------------- +*/ + +#ifndef __TYPES_H_ +#define __TYPES_H_ + +#include +#include + +class NotImplementedException : public std::exception {}; +class InvalidGroupException : public std::exception {}; +class DimensionMismatchException : public std::exception {}; + + +typedef long double NumberType; // this might work +typedef std::vector VectorType; +// typedef std::set Orbit; + +class GeneratorList : public std::vector { +public: + GeneratorList(int r, int c) + : std::vector(r) + { + for (int i=0; i