forked from mirror/toddcox-faster
refactor into cmake project, tweak api
This commit is contained in:
80
include/tc/core.hpp
Normal file
80
include/tc/core.hpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
|
||||
#include<array>
|
||||
#include<vector>
|
||||
#include<string>
|
||||
|
||||
namespace tc {
|
||||
struct Action {
|
||||
int coset = -1;
|
||||
int gen = -1;
|
||||
int target = -1;
|
||||
|
||||
Action() = default;
|
||||
|
||||
Action(const Action &) = default;
|
||||
|
||||
Action(int coset, int gen, int target);
|
||||
};
|
||||
|
||||
struct Cosets {
|
||||
int ngens;
|
||||
std::vector<int> data;
|
||||
std::vector<Action> path;
|
||||
|
||||
Cosets(const Cosets &) = default;
|
||||
|
||||
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;
|
||||
|
||||
[[nodiscard]] size_t size() const;
|
||||
};
|
||||
|
||||
struct Rel {
|
||||
std::array<int, 2> gens;
|
||||
int mult;
|
||||
|
||||
Rel() = default;
|
||||
|
||||
Rel(const Rel &) = default;
|
||||
|
||||
Rel(int a, int b, int m);
|
||||
|
||||
[[nodiscard]] Rel shift(int off) const;
|
||||
};
|
||||
|
||||
struct Group {
|
||||
const int ngens;
|
||||
std::vector<std::vector<int>> _mults;
|
||||
std::string name;
|
||||
|
||||
Group(const Group &) = default;
|
||||
|
||||
explicit Group(int ngens, const std::vector<Rel> &rels = {}, std::string name = "G");
|
||||
|
||||
void set(const Rel &r);
|
||||
|
||||
[[nodiscard]] int get(int a, int b) const;
|
||||
|
||||
[[nodiscard]] std::vector<Rel> rels() const;
|
||||
|
||||
[[nodiscard]] Group product(const Group &other) const;
|
||||
|
||||
[[nodiscard]] Group power(int p) const;
|
||||
|
||||
[[nodiscard]] Cosets solve(const std::vector<int>& sub_gens = {}) const;
|
||||
};
|
||||
|
||||
Group operator*(const Group &g, const Group &h);
|
||||
|
||||
Group operator^(const Group &g, int p);
|
||||
}
|
||||
70
include/tc/groups.hpp
Normal file
70
include/tc/groups.hpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
#include "core.hpp"
|
||||
|
||||
|
||||
namespace tc {
|
||||
/**
|
||||
* 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, const std::string &name);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user