Repository navigation
Expand file tree
/
Copy pathelement.cpp
More file actions
46 lines (46 loc) · 1.58 KB
/
Copy pathelement.cpp
File metadata and controls
46 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// --------------------------------------- Perm ------------------------------------------ //
// constructor for permutation - also generates string name for element, and cycle_lengths
// TODO: huge performance boost via moving computation of string name to printing
// - have to do something about const in << operator!
//Perm::Perm(std::vector<int> p) {
// // dec true if 1-indexed
// bool dec = false;
// this->n = p.size(); this->p = p;
// TR(x, p) dec |= x == n;
// if (dec) TR(x, p) x--;
//
// // find all cycles
// bool used[n];
// memset(used, false, sizeof used);
// F(i,n) if (!used[i] and p[i] != i) {
// int curr = 1;
// name += "(" + std::to_string(i + 1);
// used[i] = true;
// while (!used[i = p[i]]) name += std::to_string(i + 1), used[i] = true, curr++;
// name += ")";
// cycle_lengths.push_back(curr);
// }
//
// cycle_lengths.insert(cycle_lengths.begin(), cycle_lengths.size());
//
// if (name.empty())
// name = "e";
//}
//
//Perm Perm::dot(Perm const &b) const {
// std::vector<int> res(n);
// // compose permutation
// F(i,n) res[i] = p[b.p[i]];
// return Perm(res);
//}
//
//// first compare number of cycles; fewer means smaller.
//// if equal, compare lexicographically lengths of cycles
//// if equal, finally compare actual permutation
//bool Perm::operator<(const Perm &rhs) const {
// return (cycle_lengths == rhs.cycle_lengths) ? p < rhs.p : cycle_lengths < rhs.cycle_lengths;
//}
//
//std::ostream &operator<<(std::ostream &os, const Perm &b) {
// return os << b.name;
//}