add bound to support for infinite groups and free relations

special values tc::UNBOUND and tc::FREE used for this.
This commit is contained in:
David Allemang
2022-09-16 11:49:09 -04:00
parent a867631393
commit c7c6784643
5 changed files with 70 additions and 22 deletions

View File

@@ -10,5 +10,7 @@
#include "group.hpp"
namespace tc {
Cosets solve(const Group &group, const std::vector<Gen> &sub_gens);
constexpr Coset UNBOUNDED = (Coset) (-1);
Cosets solve(const Group &group, const std::vector<Gen> &sub_gens, const Coset &bound = UNBOUNDED);
}

View File

@@ -8,15 +8,16 @@ namespace tc {
using Coset = uint32_t;
using Gen = uint8_t;
using Mult = uint16_t;
constexpr Mult FREE = Mult(-1);
constexpr Coset UNSET = Coset(-1);
using Rel = std::tuple<Gen, Gen, Mult>;
struct Cosets {
const Coset UNSET = Coset(-1);
Gen ngens;
std::vector<int> data;
Path path;
bool complete = false;
Cosets(const Cosets &) = default;

View File

@@ -8,6 +8,23 @@ namespace tc {
struct Group;
struct SubGroup;
/**
* @brief Manage the presentation of a Coxeter group and enforce constraints
* on the multiplicities of its relations.
* <ul>
* <li>
* <code>m_ij = 1</code> iff <code>i != j</code>
* </li>
* <li>
* <code>m_ij = m_ji</code>
* </li>
* <li>
* If <code>m_ij == inf</code> (<code>tc::FREE</code>) then no relation is imposed.
* </li>
* </ul>
* @see
* <a href="https://en.wikipedia.org/wiki/Coxeter_group#Definition">Coxeter Group (Wikipedia)</a>
*/
struct Group {
int ngens;
tc::pair_map<int> _mults;
@@ -17,6 +34,10 @@ namespace tc {
explicit Group(int ngens, const std::vector<Rel> &rels = {})
: ngens(ngens), _mults(ngens, 2) {
for (int i = 0; i < ngens; ++i) {
set(Rel{i, i, 1});
}
for (const auto &rel: rels) {
set(rel);
}
@@ -24,6 +45,9 @@ namespace tc {
void set(const Rel &r) {
auto &[i, j, m] = r;
if (i == j && m != 1) {
throw std::runtime_error("Coxeter groups must satisfy m_ii=1.");
}
_mults(i, j) = m;
}
@@ -31,16 +55,6 @@ namespace tc {
return _mults(i, j);
}
[[nodiscard]] std::vector<Rel> rels() const {
std::vector<Rel> res;
for (int i = 0; i < ngens - 1; ++i) {
for (int j = i + 1; j < ngens; ++j) {
res.emplace_back(i, j, get(i, j));
}
}
return res;
}
[[nodiscard]] SubGroup subgroup(const std::vector<int> &gens) const;
};