Merge remote-tracking branch 'origin/refactor'

# Conflicts:
#	solver.cpp
#	test.cpp
This commit is contained in:
2020-01-04 02:06:29 -05:00
24 changed files with 8626 additions and 361 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.idea
*.[oa]
cmake-build*/

6
.gitmodules vendored Normal file
View File

@@ -0,0 +1,6 @@
[submodule "vendor/glfw"]
path = vendor/glfw
url = https://github.com/glfw/glfw.git
[submodule "vendor/glm"]
path = vendor/glm
url = https://github.com/g-truc/glm.git

12
CMakeLists.txt Normal file
View File

@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.10)
project(toddcox-faster)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(vendor/glad)
add_subdirectory(vendor/glfw)
add_subdirectory(vendor/glm)
add_subdirectory(tc)
add_subdirectory(vis)
add_subdirectory(example)

5
example/CMakeLists.txt Normal file
View File

@@ -0,0 +1,5 @@
add_executable(bench bench.cpp)
target_link_libraries(bench PRIVATE tc)
add_executable(path path.cpp)
target_link_libraries(path PRIVATE tc)

31
example/bench.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include "tc/solver.h"
#include "tc/groups.h"
#include <ctime>
#include <iostream>
int main() {
std::vector<tc::Group> groups = {
tc::group::H(2),
tc::group::H(3),
tc::group::H(4),
tc::group::T(100),
tc::group::T(500),
tc::group::T(1000),
tc::group::E(6),
tc::group::E(7),
};
for (const auto &group : groups) {
auto s = std::clock(); // to measure CPU time
auto cosets = tc::solve(group);
auto e = std::clock();
double diff = (double) (e - s) / CLOCKS_PER_SEC;
int order = cosets.len;
std::cout << group.name << "," << order << "," << diff << std::endl;
}
return 0;
}

17
example/path.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include "tc/solver.h"
#include "tc/groups.h"
#include <ctime>
#include <iostream>
int main() {
auto cube = tc::group::B(3);
auto vars = tc::solve(cube, {});
for (int target = 1; target < vars.len; target++) {
auto &action = vars.path[target];
std::cout << action.coset << " " << action.gen << " " << target << std::endl;
}
return 0;
}

View File

@@ -1,52 +0,0 @@
#include "solver.cpp"
Group A(const int n) {
if (n == 0)
return Group(0);
return Group::schlafli(std::vector<int>(n-1,3));
}
Group B(const int n) {
std::vector<int> mults(n-1,3);
mults[0] = 4;
return Group::schlafli(mults);
}
Group D(const int n) {
std::vector<int> mults(n-1,3);
mults[n-2] = 2;
Group g = Group::schlafli(mults);
g.setmult({1,n-1,3});
return g;
}
Group E(const int n) {
std::vector<int> mults(n-1,3);
mults[n-2] = 2;
Group g = Group::schlafli(mults);
g.setmult({2,n-1,3});
return g;
}
Group F4() {
return Group::schlafli({3,4,3});
}
Group G2() {
return Group::schlafli({6});
}
Group H(const int n) {
std::vector<int> mults(n-1,3);
mults[0] = 5;
return Group::schlafli(mults);
}
Group I2(const int n) {
return Group::schlafli({n});
}
Group T(const int n) {
return I2(n)^2;
}

View File

@@ -1,290 +0,0 @@
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <functional>
#include <iostream>
struct Cosets {
int ngens;
std::vector<int> data;
int len;
Cosets(int ngens, std::vector<int> data): ngens(ngens), data(data) {
len = data.size() / ngens;
}
void add_row() {
len++;
data.resize(data.size()+ngens, -1);
}
void put(int coset, int gen, int target) {
data[coset * ngens + gen] = target;
data[target * ngens + gen] = coset;
}
void put(int idx, int target) {
int coset = idx / ngens;
int gen = idx % ngens;
data[idx] = target;
data[target * ngens + gen] = coset;
}
int get(int coset, int gen) {
return data[coset * ngens + gen];
}
int get(int idx) {
return data[idx];
}
};
struct Mult {
int gen0, gen1, mult;
};
struct RelTablesRow {
int* gnrs;
int** lst_ptrs;
RelTablesRow (int N, int* gnrs, int** lst_ptrs): gnrs(gnrs), lst_ptrs(lst_ptrs) {
for (int i = 0; i < N; i++) {
lst_ptrs[i] = nullptr;
}
}
};
struct TableInfo {
int gens[2];
int mult;
TableInfo(Mult m) {
gens[0] = m.gen0;
gens[1] = m.gen1;
mult = m.mult;
}
};
struct RelTables {
static const int ROW_BLOCK_SIZE = 128;
std::vector<TableInfo> table_info;
std::vector<RelTablesRow*> rows;
int start = 0;
int num_tables;
int buffer_rows = 0;
RelTables (std::vector<Mult> mults): num_tables(mults.size()) {
for (Mult m : mults) {
table_info.emplace_back(m);
}
}
void add_row() {
if (buffer_rows == 0) {
int* gnrs_alloc = new int[num_tables*RelTables::ROW_BLOCK_SIZE];
int** lst_ptrs_alloc = new int*[num_tables*RelTables::ROW_BLOCK_SIZE];
for (int i = 0; i < RelTables::ROW_BLOCK_SIZE; i++) {
rows.push_back(new RelTablesRow(num_tables, &gnrs_alloc[i*num_tables], &lst_ptrs_alloc[i*num_tables]));
}
buffer_rows = RelTables::ROW_BLOCK_SIZE;
}
buffer_rows--;
}
void del_rows_to(int idx) {
const int del_to = (idx/RelTables::ROW_BLOCK_SIZE)*RelTables::ROW_BLOCK_SIZE;
for (int i = start; i < del_to; i += RelTables::ROW_BLOCK_SIZE) {
delete[] rows[i]->gnrs;
delete[] rows[i]->lst_ptrs;
for (int j = 0; j < RelTables::ROW_BLOCK_SIZE; j++) {
delete rows[i+j];
}
start += RelTables::ROW_BLOCK_SIZE;
}
}
};
struct Group {
int ngens;
std::vector<std::vector<int>> _mults;
Group(int ngens, std::vector<Mult> rels = {}): ngens(ngens) {
_mults.resize(ngens);
for (int i = 0; i < ngens; i++) {
_mults[i].resize(ngens, 2);
}
for (Mult m : rels) {
if (m.gen0 < m.gen1)
_mults[m.gen0][m.gen1] = m.mult;
else
_mults[m.gen1][m.gen0] = m.mult;
}
}
void setmult(Mult m) {
if (m.gen0 < m.gen1)
_mults[m.gen0][m.gen1] = m.mult;
else
_mults[m.gen1][m.gen0] = m.mult;
}
std::vector<Mult> get_mults() const {
std::vector<Mult> mults;
for (int i = 0; i < ngens - 1; i++) {
for (int j = i+1; j < ngens; j++) {
mults.push_back({i,j,_mults[i][j]});
}
}
return mults;
}
Group operator*(const Group &other) {
int off = ngens;
Group g(ngens + other.ngens, get_mults());
for (Mult m : other.get_mults()) {
g.setmult({off + m.gen0, off + m.gen1, m.mult});
}
return g;
}
Group operator^(int p) {
Group g(ngens * p);
for (Mult m : get_mults()) {
for (int off = 0; off < g.ngens; off += ngens) {
g.setmult({off + m.gen0, off + m.gen1, m.mult});
}
}
return g;
}
static Group schlafli(std::vector<int> mults) {
int ngens = mults.size() + 1;
Group g(ngens);
for (int i = 0; i < mults.size(); i++) {
g.setmult({i, i+1, mults[i]});
}
return g;
}
Cosets solve(std::vector<int> sub_gens = {}) {
std::vector<int> init_row(ngens, -1);
for (int i : sub_gens) {
init_row[i] = 0;
}
Cosets cosets(ngens, init_row);
RelTables rel_tables(get_mults());
std::vector<std::vector<int>> gen_map(ngens);
int rel_idx = 0;
for (Mult m : get_mults()) {
gen_map[m.gen0].push_back(rel_idx);
gen_map[m.gen1].push_back(rel_idx);
rel_idx++;
}
int null_lst_ptr;
rel_tables.add_row();
RelTablesRow &row = *(rel_tables.rows[0]);
for (int table_idx = 0; table_idx < rel_tables.num_tables; table_idx++) {
TableInfo &ti = rel_tables.table_info[table_idx];
if (cosets.get(ti.gens[0]) + cosets.get(ti.gens[1]) == -2) {
row.lst_ptrs[table_idx] = new int;
row.gnrs[table_idx] = 0;
}
else {
row.lst_ptrs[table_idx] = &null_lst_ptr;
row.gnrs[table_idx] = -1;
}
}
int idx = 0;
int coset, gen, target, fact_idx, lst, gen_;
while (true) {
while (idx < cosets.data.size() and cosets.get(idx) >= 0)
idx++;
if (idx == cosets.data.size()) {
rel_tables.del_rows_to(idx / ngens);
break;
}
target = cosets.len;
cosets.add_row();
rel_tables.add_row();
std::vector<int> facts;
facts.push_back(idx);
coset = idx / ngens;
gen = idx % ngens;
rel_tables.del_rows_to(coset);
RelTablesRow &target_row = *(rel_tables.rows[target]);
while (!facts.empty()) {
fact_idx = facts.back();
facts.pop_back();
if (cosets.get(fact_idx) != -1)
continue;
cosets.put(fact_idx, target);
coset = fact_idx / ngens;
gen = fact_idx % ngens;
RelTablesRow &coset_row = *(rel_tables.rows[coset]);
for (int table_idx : gen_map[gen]) {
if ( target_row.lst_ptrs[table_idx] == nullptr ) {
TableInfo &ti = rel_tables.table_info[table_idx];
target_row.lst_ptrs[table_idx] = coset_row.lst_ptrs[table_idx];
target_row.gnrs[table_idx] = coset_row.gnrs[table_idx] + 1;
if (coset_row.gnrs[table_idx] < 0)
target_row.gnrs[table_idx] -= 2;
if (target_row.gnrs[table_idx] == ti.mult) {
lst = *(target_row.lst_ptrs[table_idx]);
delete target_row.lst_ptrs[table_idx];
gen_ = ti.gens[(int)(ti.gens[0] == gen)];
facts.push_back(lst*ngens + gen_);
}
else if (target_row.gnrs[table_idx] == -ti.mult) {
gen_ = ti.gens[ti.gens[0] == gen];
facts.push_back(target*ngens + gen_);
}
else if (target_row.gnrs[table_idx] == ti.mult - 1) {
*(target_row.lst_ptrs[table_idx]) = target;
}
}
}
std::sort(facts.begin(), facts.end(), std::greater<int>());
}
for (int table_idx = 0; table_idx < rel_tables.num_tables; table_idx++) {
TableInfo &ti = rel_tables.table_info[table_idx];
if (target_row.lst_ptrs[table_idx] == nullptr) {
if ( (cosets.get(target, ti.gens[0]) != target) and
(cosets.get(target, ti.gens[1]) != target) ) {
target_row.lst_ptrs[table_idx] = new int;
target_row.gnrs[table_idx] = 0;
}
else {
target_row.lst_ptrs[table_idx] = &null_lst_ptr;
target_row.gnrs[table_idx] = -1;
}
}
}
}
return cosets;
}
};

6
tc/CMakeLists.txt Normal file
View File

@@ -0,0 +1,6 @@
add_library(tc STATIC
src/groups.cpp
src/solver.cpp
src/cosets.cpp)
target_include_directories(tc PUBLIC include)

30
tc/include/tc/cosets.h Normal file
View File

@@ -0,0 +1,30 @@
#pragma once
#include "groups.h"
#include <vector>
namespace tc {
struct Action {
int coset = -1;
int gen = -1;
};
struct Cosets {
int ngens;
std::vector<int> data;
std::vector<Action> path;
int len;
explicit Cosets(int ngens);
void add_row();
void put(int coset, int gen, int target);
void put(int idx, int target);
[[nodiscard]] int get(int coset, int gen) const;
[[nodiscard]] int get(int idx) const;
};
}

92
tc/include/tc/groups.h Normal file
View File

@@ -0,0 +1,92 @@
#pragma once
#include <array>
#include <vector>
namespace tc {
struct Rel {
std::array<int, 2> gens;
int mult;
};
/**
* A presentation of a coxeter group. Contains a number of generators and some relations of the form (ab)^n = e
*/
struct Group {
const int ngens;
std::vector<std::vector<int>> _mults; // lookup table for multiplicities
std::string name;
explicit Group(int ngens, const std::vector<Rel> &rels = {}, std::string name = "G");
void setmult(Rel rel);
[[nodiscard]] std::vector<Rel> get_rels() const;
[[nodiscard]] Group product(const Group &other) const;
[[nodiscard]] Group power(int p) const;
};
Group operator*(const Group &g, const Group &h);
Group operator^(const Group &g, const int &p);
/**
* Construct a group from a (simplified) Schlafli Symbol of the form [a, b, ..., c]
* @param mults: The sequence of multiplicites between adjacent generators.
*/
Group schlafli(const std::vector<int> &mults);
namespace group {
/**
* Simplex
*/
Group A(int dim);
/**
* Cube, Orthoplex
*/
Group B(int dim);
/**
* Demicube, Orthoplex
*/
Group D(int dim);
/**
* E groups
*/
Group E(int dim);
/**
* 24 Cell
*/
Group F4();
/**
* Hexagon
*/
Group G2();
/**
* Icosahedron
*/
Group H(int dim);
/**
* Polygonal
*/
Group I2(int n);
/**
* Toroidal. I2(n) * I2(m)
*/
Group T(int n, int m);
/**
* Toroidal. T(n, n)
*/
Group T(int n);
}
}

7
tc/include/tc/solver.h Normal file
View File

@@ -0,0 +1,7 @@
#pragma once
#include "cosets.h"
namespace tc {
Cosets solve(const Group &g, const std::vector<int> &sub_gens = {});
}

41
tc/src/cosets.cpp Normal file
View File

@@ -0,0 +1,41 @@
#include "tc/cosets.h"
namespace tc {
Cosets::Cosets(int ngens) : ngens(ngens), len(0) {
}
void Cosets::add_row() {
len++;
data.resize(data.size() + ngens, -1);
path.resize(path.size() + 1);
}
void Cosets::put(int coset, int gen, int target) {
data[coset * ngens + gen] = target;
data[target * ngens + gen] = coset;
if (path[target].coset == -1) {
path[target] = {coset, gen};
}
}
void Cosets::put(int idx, int target) {
int coset = idx / ngens;
int gen = idx % ngens;
data[idx] = target;
data[target * ngens + gen] = coset;
if (path[target].coset == -1) {
path[target] = {coset, gen};
}
}
int Cosets::get(int coset, int gen) const {
return data[coset * ngens + gen];
}
int Cosets::get(int idx) const {
return data[idx];
}
}

196
tc/src/groups.cpp Normal file
View File

@@ -0,0 +1,196 @@
#include "tc/groups.h"
#include <iterator>
#include <sstream>
namespace tc {
Group::Group(int ngens, const std::vector<Rel> &rels, std::string name) : ngens(ngens), name(std::move(name)) {
_mults.resize(ngens);
for (int i = 0; i < ngens; i++) {
_mults[i].resize(ngens, 2);
}
for (Rel rel : rels) {
if (rel.gens[0] < rel.gens[1])
_mults[rel.gens[0]][rel.gens[1]] = rel.mult;
else
_mults[rel.gens[1]][rel.gens[0]] = rel.mult;
}
}
void Group::setmult(Rel rel) {
if (rel.gens[0] < rel.gens[1])
_mults[rel.gens[0]][rel.gens[1]] = rel.mult;
else
_mults[rel.gens[1]][rel.gens[0]] = rel.mult;
}
std::vector<Rel> Group::get_rels() const {
std::vector<Rel> rels;
for (int i = 0; i < ngens - 1; i++) {
for (int j = i + 1; j < ngens; j++) {
rels.push_back({i, j, _mults[i][j]});
}
}
return rels;
}
Group Group::product(const Group &other) const {
int off = ngens;
Group g(ngens + other.ngens, get_rels());
for (Rel rel : other.get_rels()) {
g.setmult({off + rel.gens[0], off + rel.gens[1], rel.mult});
}
std::stringstream ss;
ss << name << "*" << other.name;
g.name = ss.str();
return g;
}
Group Group::power(int p) const {
Group g(ngens * p);
for (Rel rel : get_rels()) {
for (int off = 0; off < g.ngens; off += ngens) {
g.setmult({off + rel.gens[0], off + rel.gens[1], rel.mult});
}
}
std::stringstream ss;
ss << name << "^" << p;
g.name = ss.str();
return g;
}
Group operator*(const Group &g, const Group &h) {
return g.product(h);
}
Group operator^(const Group &g, const int &p) {
return g.power(p);
}
Group schlafli(const std::vector<int> &mults, const std::string& name) {
int ngens = (int) mults.size() + 1;
Group g(ngens, {}, name);
for (int i = 0; i < (int) mults.size(); i++) {
g.setmult({i, i + 1, mults[i]});
}
return g;
}
Group schlafli(const std::vector<int> &mults) {
std::stringstream ss;
ss << "[";
if (!mults.empty()) {
copy(mults.begin(), mults.end() - 1, std::ostream_iterator<int>(ss, ","));
ss << mults.back();
}
ss << "]";
return schlafli(mults, ss.str());
}
namespace group {
Group A(const int dim) {
if (dim == 0)
return Group(0, {}, "A(0)");
const std::vector<int> &mults = std::vector<int>(dim - 1, 3);
std::stringstream ss;
ss << "A(" << dim << ")";
return schlafli(mults, ss.str());
}
Group B(const int dim) {
std::vector<int> mults(dim - 1, 3);
mults[0] = 4;
std::stringstream ss;
ss << "B(" << dim << ")";
return schlafli(mults, ss.str());
}
Group D(const int dim) {
std::vector<int> mults(dim - 1, 3);
mults[dim - 2] = 2;
Group g = schlafli(mults);
g.setmult({1, dim - 1, 3});
std::stringstream ss;
ss << "D(" << dim << ")";
g.name = ss.str();
return g;
}
Group E(const int dim) {
std::vector<int> mults(dim - 1, 3);
mults[dim - 2] = 2;
Group g = schlafli(mults);
g.setmult({2, dim - 1, 3});
std::stringstream ss;
ss << "E(" << dim << ")";
g.name = ss.str();
return g;
}
Group F4() {
return schlafli({3, 4, 3}, "F4");
}
Group G2() {
return schlafli({6}, "G2");
}
Group H(const int dim) {
std::vector<int> mults(dim - 1, 3);
mults[0] = 5;
std::stringstream ss;
ss << "H(" << dim << ")";
return schlafli(mults, ss.str());
}
Group I2(const int n) {
std::stringstream ss;
ss << "I2(" << n << ")";
return schlafli({n}, ss.str());
}
Group T(const int n, const int m) {
Group g = I2(n) * I2(m);
std::stringstream ss;
ss << "T(" << n << "," << m << ")";
g.name = ss.str();
return g;
}
Group T(const int n) {
Group g = I2(n) ^2;
std::stringstream ss;
ss << "T(" << n << ")";
g.name = ss.str();
return g;
}
}
}

135
tc/src/solver.cpp Normal file
View File

@@ -0,0 +1,135 @@
#include "tc/solver.h"
#include <algorithm>
namespace tc {
struct RelTable {
Rel rel;
std::vector<int *> lst_ptr;
std::vector<int> gen;
int &mult = rel.mult;
std::array<int, 2> &gens = rel.gens;
explicit RelTable(Rel rel) : rel(rel) {
}
int add_row() {
int idx = lst_ptr.size();
lst_ptr.push_back(nullptr);
gen.push_back(-1);
return idx;
}
};
struct RelationSet {
const Cosets &cosets;
std::vector<RelTable> tables;
std::vector<std::vector<RelTable *>> gen_map; // which relations involve which generators
explicit RelationSet(const Group &g, const Cosets &cosets) : gen_map(g.ngens), cosets(cosets) {
const std::vector<Rel> &rels = g.get_rels();
tables.reserve(rels.size());
for (const auto &rel : rels) {
RelTable &table = tables.emplace_back(rel);
gen_map[rel.gens[0]].push_back(&table);
gen_map[rel.gens[1]].push_back(&table);
}
}
void add_row() {
for (auto &table : tables) {
table.add_row();
}
}
void fill_row(int idx) {
for (auto &table : tables) {
if (table.lst_ptr[idx] != nullptr) continue;
table.lst_ptr[idx] = new int;
if ((cosets.get(idx, table.gens[0]) != idx) and
(cosets.get(idx, table.gens[1]) != idx)) {
table.gen[idx] = 0;
} else {
table.gen[idx] = -1;
}
}
}
};
Cosets solve(const Group &group, const std::vector<int> &sub_gens) {
Cosets cosets(group.ngens);
cosets.add_row();
for (const auto &i : sub_gens) {
cosets.put(0, i, 0);
}
RelationSet rels(group, cosets);
rels.add_row();
rels.fill_row(0);
int idx = 0;
int coset, gen, target, fact_idx, lst, gen_;
while (true) {
while (idx < cosets.data.size() and cosets.get(idx) >= 0)
idx++;
if (idx == cosets.data.size())
break;
target = cosets.len;
cosets.add_row();
rels.add_row();
std::vector<int> facts = {idx};
while (!facts.empty()) {
fact_idx = facts.back();
facts.pop_back();
if (cosets.get(fact_idx) != -1)
continue;
cosets.put(fact_idx, target);
coset = fact_idx / group.ngens;
gen = fact_idx % group.ngens;
for (RelTable *pTable : rels.gen_map[gen]) {
RelTable &table = *pTable;
if (table.lst_ptr[target] == nullptr) {
table.lst_ptr[target] = table.lst_ptr[coset];
table.gen[target] = table.gen[coset] + 1;
if (table.gen[coset] < 0)
table.gen[target] -= 2;
if (table.gen[target] == table.rel.mult) {
lst = *(table.lst_ptr[target]);
delete table.lst_ptr[target];
gen_ = table.gens[table.gens[0] == gen];
facts.push_back(lst * group.ngens + gen_);
} else if (table.gen[target] == -table.mult) {
gen_ = table.gens[table.gens[0] == gen];
facts.push_back(target * group.ngens + gen_);
} else if (table.gen[target] == table.mult - 1) {
*(table.lst_ptr[target]) = target;
}
}
}
std::sort(facts.begin(), facts.end(), std::greater<>());
}
rels.fill_row(target);
}
return cosets;
}
}

View File

@@ -1,19 +0,0 @@
#include "groups.cpp"
#include <chrono>
#include <iostream>
int main() {
Group g = B(8);
auto s = std::chrono::system_clock::now();
auto cosets = g.solve();
auto e = std::chrono::system_clock::now();
std::chrono::duration<double> diff = e - s;
int order = cosets.len;
std::cout << order << std::endl;
std::cout << diff.count() << std::endl;
return 0;
}

2
vendor/glad/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,2 @@
add_library(glad src/glad.c)
target_include_directories(glad PUBLIC include)

290
vendor/glad/include/KHR/khrplatform.h vendored Normal file
View File

@@ -0,0 +1,290 @@
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2018 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* The master copy of khrplatform.h is maintained in the Khronos EGL
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
* The last semantic modification to khrplatform.h was at commit ID:
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by filing pull requests or issues on
* the EGL Registry repository linked above.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
# define KHRONOS_STATIC 1
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(KHRONOS_STATIC)
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
* header compatible with static linking. */
# define KHRONOS_APICALL
#elif defined(_WIN32)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#elif defined(__ANDROID__)
# define KHRONOS_APICALL __attribute__((visibility("default")))
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(KHRONOS_STATIC)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
/*
* Types that differ between LLP64 and LP64 architectures - in LLP64,
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use.
*/
#ifdef _WIN64
typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t;
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#endif
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */

5157
vendor/glad/include/glad/glad.h vendored Normal file

File diff suppressed because it is too large Load Diff

2532
vendor/glad/src/glad.c vendored Normal file

File diff suppressed because it is too large Load Diff

1
vendor/glfw vendored Submodule

Submodule vendor/glfw added at fe57e3c292

1
vendor/glm vendored Submodule

Submodule vendor/glm added at 8828c3f1fd

3
vis/CMakeLists.txt Normal file
View File

@@ -0,0 +1,3 @@
add_executable(vis src/main.cpp)
target_include_directories(vis PRIVATE include)
target_link_libraries(vis PRIVATE tc glad glm glfw)

58
vis/src/main.cpp Normal file
View File

@@ -0,0 +1,58 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <tc/groups.h>
#include <tc/solver.h>
#ifdef _WIN32
extern "C" {
__attribute__((unused)) __declspec(dllexport) int NvOptimusEnablement = 0x00000001;
}
#endif
int main(int argc, char *argv[]) {
if (!glfwInit()) {
std::cerr << "Failed to initialize GLFW" << std::endl;
return EXIT_FAILURE;
}
auto window = glfwCreateWindow(
1920, 1080,
"Coset Visualization",
nullptr, nullptr);
if (!window) {
std::cerr << "Failed to create window" << std::endl;
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
glfwSwapInterval(0);
std::cout
<< "Graphics Information:" << std::endl
<< " Vendor: " << glGetString(GL_VENDOR) << std::endl
<< " Renderer: " << glGetString(GL_RENDERER) << std::endl
<< " OpenGL version: " << glGetString(GL_VERSION) << std::endl
<< " Shading version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
auto group = tc::group::A(5);
auto res = tc::solve(group);
std::cout
<< "Coset Solution Test:" << std::endl
<< " Group: " << group.name << std::endl
<< " Order: " << res.len << std::endl;
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return EXIT_SUCCESS;
}