remove unused files

This commit is contained in:
2019-12-11 10:30:26 -05:00
parent 01f0dc6ea6
commit 666c5d46f9
5 changed files with 0 additions and 517 deletions

View File

@@ -1,110 +0,0 @@
#pragma once
#include <types.hpp>
struct Mult {
int from, to, multiplicity;
};
Table mults(const std::vector<Mult>& ms) {
Table res;
for (const auto &m : ms) {
int N = res.size();
res.emplace_back(m.multiplicity * 2, m.to);
for (int i = 0; i < m.multiplicity * 2; i += 2) {
res[N][i] = m.from;
}
}
return res;
}
std::vector<Mult> ezmults(int ngens, const std::vector<Mult> &ms) {
bool table[ngens][ngens];
for (int i = 0; i < ngens; i++) {
for (int j = 0; j < ngens; j++) {
table[i][j] = false;
}
}
for (const auto &m : ms) {
table[m.from][m.to] = true;
table[m.to][m.from] = true;
}
std::vector<Mult> res(ms);
for (int i = 0; i < ngens; i++) {
for (int j = i + 1; j < ngens; j++) {
if (!table[i][j]) {
res.push_back({i, j, 2});
}
}
}
return res;
}
/*
* Order 4*res*res
*/
std::pair<Table, int> torus(int res) {
return std::make_pair(mults(ezmults(4, {
{0, 1, res},
{2, 3, res},
})), 4);
}
/*
* Order 14,400
*/
std::pair<Table, int> H4() {
return std::make_pair(mults(ezmults(4, {
{0, 1, 5},
{1, 2, 3},
{2, 3, 3},
})), 4);
}
/*
* Order 51,840
*/
std::pair<Table, int> E6() {
return std::make_pair(mults(ezmults(6, {
{0, 1, 3},
{1, 2, 3},
{2, 3, 3},
{2, 4, 3},
{4, 5, 3},
})), 6);
}
/*
* Order 2,903,040
*/
std::pair<Table, int> E7() {
return std::make_pair(mults(ezmults(7, {
{0, 1, 3},
{1, 2, 3},
{2, 3, 3},
{2, 4, 3},
{4, 5, 3},
{5, 6, 3},
})), 7);
}
/*
* Order 696,729,600
*/
std::pair<Table, int> E8() {
return std::make_pair(mults(ezmults(8, {
{0, 1, 3},
{1, 2, 3},
{2, 3, 3},
{2, 4, 3},
{4, 5, 3},
{5, 6, 3},
{6, 7, 3},
})), 8);
}

View File

@@ -1,4 +0,0 @@
#pragma once
using Gens=std::vector<int>;
using Table=std::vector<Gens>;

View File

@@ -1,195 +0,0 @@
#pragma once
#include <map>
#include <vector>
#include <algorithm>
struct Mults;
struct Table;
struct IRow;
struct Mults {
const int dim;
std::map<std::tuple<int, int>, int> mults;
explicit Mults(const int dim) : dim(dim) {
mults = std::map<std::tuple<int, int>, int>();
}
void set(int a, int b, int mult) {
if (a > b) std::swap(a, b);
mults[std::make_tuple(a, b)] = mult;
}
[[nodiscard]] int get(int a, int b) const {
if (a == b) return 1;
if (a > b) std::swap(a, b);
const auto &tup = std::make_tuple(a, b);
const auto &res = mults.find(tup);
if (res == mults.end()) return 2;
return res->second;
}
[[nodiscard]] std::vector<int> irelation(int a, int b) const {
std::vector<int> res{};
int mult = get(a, b);
for (int i = 0; i < mult; ++i) {
res.push_back(a);
res.push_back(b);
}
return res;
}
[[nodiscard]] Mults sub(const std::vector<int> &igens) const {
Mults res(igens.size());
for (int a = 0; a < (int) igens.size(); ++a) {
for (int b = a + 1; b < (int) igens.size(); ++b) {
res.set(a, b, get(igens[a], igens[b]));
}
}
return res;
}
[[nodiscard]] Table *isolve(const std::vector<int> &isubgens) const;
};
struct Table {
const Mults mults;
std::vector<std::vector<int>> fwd;
explicit Table(Mults mults) : mults(mults) {
add_row();
}
void add_row() {
fwd.emplace_back(mults.dim, -1);
}
int add_coset() {
for (int from = 0; from < (int) size(); ++from) {
for (int igen = 0; igen < (int) mults.dim; igen++) {
if (iget(from, igen) < 0) {
int to = (int) size();
add_row();
iset(from, igen, to);
return to;
}
}
}
return 0;
}
[[nodiscard]] unsigned size() const {
return fwd.size();
}
void iset(int from, int igen, int to) {
fwd[from][igen] = to;
fwd[to][igen] = from;
}
[[nodiscard]] int iget(int from, int igen) const {
return fwd[from][igen];
}
[[nodiscard]] int irget(int igen, int to) const {
return fwd[to][igen];
}
};
struct IRow {
std::vector<int>::const_iterator l;
std::vector<int>::const_iterator r;
int from;
int to;
IRow(const std::vector<int> &rel, int cos)
: l(rel.begin()), r(rel.end() - 1), from(cos), to(cos) {
}
[[nodiscard]] bool learn(Table *table) {
if (r - l == 0) {
return false;
}
while (r - l > 0) {
int next = table->iget(from, *l);
if (next < 0) break;
l++;
from = next;
}
while (r - l > 0) {
int next = table->irget(*r, to);
if (next < 0) break;
r--;
to = next;
}
if (r - l == 0) {
table->iset(from, *l, to);
return true;
}
return false;
}
};
Mults schlafli(const std::vector<int> &symbol) {
unsigned int dim = symbol.size();
Mults mults(dim + 1);
for (int i = 0; i < dim; ++i) {
mults.set(i, i + 1, symbol[i]);
}
return mults;
}
Table *Mults::isolve(const std::vector<int> &isubgens) const {
auto *table = new Table(*this);
for (int igen : isubgens)
table->iset(0, igen, 0);
std::vector<std::vector<int>> irels{};
for (unsigned a = 0; a < dim; ++a) {
for (unsigned b = a + 1; b < dim; ++b) {
irels.push_back(irelation(a, b));
}
}
std::vector<IRow> irows;
irows.reserve(irels.size());
for (const auto &irel : irels)
irows.emplace_back(irel, 0);
while (!irows.empty()) {
while (true) {
bool learned = false;
for (int i = (int) irows.size() - 1; i >= 0; i--) {
if (irows[i].learn(table)) {
learned = true;
irows.erase(irows.begin() + i);
}
}
if (!learned)
break;
}
int i = (int) table->size();
if (table->add_coset() > 0) {
for (const auto &irel : irels)
irows.emplace_back(irel, i);
} else {
break;
}
}
return table;
}

View File

@@ -1,104 +0,0 @@
//#include <cstdio>
//#include <cstdlib>
//
//#include <thrust/host_vector.h>
//#include <thrust/device_vector.h>
//#include <thrust/sequence.h>
//
//#define N 50
//
//__global__
//void vector_add(float* out, float* a, float* b, int n) {
// for(int i = 0; i < n; i++){
// out[i] = a[i] + b[i];
// }
//}
//
//int main(){
// thrust::host_vector<float> a(N);
// thrust::sequence(a.begin(), a.end());
//
// thrust::host_vector<float> b(N);
// thrust::sequence(b.begin(), b.end());
// thrust::reverse(b.begin(), b.end());
//
// for (int i = 0; i < N; ++i) {
// printf("%.1f ", a[i]);
// } printf("\n");
//
// for (int i = 0; i < N; ++i) {
// printf("%.1f ", b[i]);
// } printf("\n");
//
// thrust::device_vector<float> aD = a;
// thrust::device_vector<float> bD = b;
// thrust::device_vector<float> outD(N);
//
// vector_add<<<1, 1>>>(
// thrust::raw_pointer_cast(&outD[0]),
// thrust::raw_pointer_cast(&aD[0]),
// thrust::raw_pointer_cast(&bD[0]),
// N);
//
// thrust::host_vector<float> out = outD;
//
// for (int i = 0; i < N; ++i) {
// printf("%.1f ", out[i]);
// } printf("\n");
//
// return 0;
//}
#include <cstdio>
#include <cstdlib>
#include <chrono>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/sequence.h>
void add_proc(int *c, int *a, int *b) {
*c = *a + *b;
}
void test_proc(){
int a = 0;
int b = 1;
auto start = std::chrono::system_clock::now();
for (int i = 0; i < 1000000; ++i) {
add_proc(&a, &a, &b);
}
auto end = std::chrono::system_clock::now();
std::chrono::duration<float, std::micro> diff = end - start;
printf("proc: %d: 1B in %.3f micro\n", a, diff.count());
}
__global__
void add_gpu(int *c, int *a, int *b) {
*c = *a + *b;
}
void test_gpu(){
thrust::device_vector<int> vals(2, 0);
vals[0] = 0;
vals[1] = 1;
printf(" gpu: %d: 1B in %.3f micro\n", vals[0], 0.0f);
int *a = thrust::raw_pointer_cast(&vals[0]);
int *b = thrust::raw_pointer_cast(&vals[1]);
add_gpu<<<1, 1>>>(a, a, a);
printf(" gpu: %d: 1B in %.3f micro\n", vals[0], 0.0f);
}
int main(int argc, char *argv[]) {
test_proc();
test_gpu();
}

View File

@@ -1,104 +0,0 @@
//#include <cstdio>
//#include <cstdlib>
//
//#include <thrust/host_vector.h>
//#include <thrust/device_vector.h>
//#include <thrust/sequence.h>
//
//#define N 50
//
//__global__
//void vector_add(float* out, float* a, float* b, int n) {
// for(int i = 0; i < n; i++){
// out[i] = a[i] + b[i];
// }
//}
//
//int main(){
// thrust::host_vector<float> a(N);
// thrust::sequence(a.begin(), a.end());
//
// thrust::host_vector<float> b(N);
// thrust::sequence(b.begin(), b.end());
// thrust::reverse(b.begin(), b.end());
//
// for (int i = 0; i < N; ++i) {
// printf("%.1f ", a[i]);
// } printf("\n");
//
// for (int i = 0; i < N; ++i) {
// printf("%.1f ", b[i]);
// } printf("\n");
//
// thrust::device_vector<float> aD = a;
// thrust::device_vector<float> bD = b;
// thrust::device_vector<float> outD(N);
//
// vector_add<<<1, 1>>>(
// thrust::raw_pointer_cast(&outD[0]),
// thrust::raw_pointer_cast(&aD[0]),
// thrust::raw_pointer_cast(&bD[0]),
// N);
//
// thrust::host_vector<float> out = outD;
//
// for (int i = 0; i < N; ++i) {
// printf("%.1f ", out[i]);
// } printf("\n");
//
// return 0;
//}
#include <cstdio>
#include <cstdlib>
#include <chrono>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/sequence.h>
void add_proc(int *c, int *a, int *b) {
*c = *a + *b;
}
void test_proc(){
int a = 0;
int b = 1;
auto start = std::chrono::system_clock::now();
for (int i = 0; i < 1000000; ++i) {
add_proc(&a, &a, &b);
}
auto end = std::chrono::system_clock::now();
std::chrono::duration<float, std::micro> diff = end - start;
printf("proc: %d: 1B in %.3f micro\n", a, diff.count());
}
__global__
void add_gpu(int *c, int *a, int *b) {
*c = *a + *b;
}
void test_gpu(){
thrust::device_vector<int> vals(2, 0);
vals[0] = 0;
vals[1] = 1;
printf(" gpu: %d: 1B in %.3f micro\n", vals[0], 0.0f);
int *a = thrust::raw_pointer_cast(&vals[0]);
int *b = thrust::raw_pointer_cast(&vals[1]);
add_gpu<<<1, 1>>>(a, a, a);
printf(" gpu: %d: 1B in %.3f micro\n", vals[0], 0.0f);
}
int main(int argc, char *argv[]) {
test_proc();
test_gpu();
}