Skip to content

Commit

Permalink
A few tweaks in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vbeffara committed Mar 16, 2016
1 parent 020010e commit 188ecae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion tests/test_cln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ double time () {

template <typename T> void test (string s, int n) {
double t = time(); T z = 0;
for (int i=0; i<n; ++i) z = cos(z);
for (int i=0; i<n; ++i) z = exp(-z);
ostringstream os; os << time()-t;
cout << s << " | time = " << os.str() << "\t | result = " << z << endl;
}
Expand Down
21 changes: 4 additions & 17 deletions tests/test_permutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,21 @@
using namespace vb;
using namespace std;

vector<Permutation> permutations (int n, bool p (Permutation &) = [](Permutation&){return true;}) {
Permutation s(n); vector<Permutation> output;
do { if (p(s)) output.push_back(s); } while (next_permutation(s.begin(),s.end()));
return output;
}

vector<int> signature (Permutation & s) {
vector<int> output;
for (auto c : s.cycles()) output.push_back(c.size());
sort (output.begin(),output.end());
return output;
}

vector<Hypermap> maps (vector<int> s, vector<int> a, vector<int> p) {
vector<Hypermap> maps (vector<unsigned> s, vector<unsigned> a, vector<unsigned> p) {
Cycles cs; int i=0;
for (int l : s) { vector<unsigned> c; for (int j=0; j<l; ++j) c.push_back(i++); cs.push_back (c); }
Permutation sigma (cs), alpha (sigma.size());
vector<Hypermap> output;
do {
if (signature(alpha) != a) continue;
Permutation phi = (sigma*alpha).inverse(); if (signature(phi) != p) continue;
if (alpha.signature() != a) continue;
Permutation phi = (sigma*alpha).inverse(); if (phi.signature() != p) continue;
output.push_back (Hypermap(sigma,alpha,phi)); cerr<<".";
} while (next_permutation(alpha.begin(),alpha.end()));
return output;
}

int main (int, char **) {
auto ms = maps (vector<int> {2,2,3}, vector<int> {2,2,3}, vector<int> {2,2,3});
auto ms = maps ({2,2,3}, {2,2,3}, {2,2,3});
for (auto m : ms) {
cout << m;
cout << " sigma: " << m.sigma;
Expand Down

0 comments on commit 188ecae

Please sign in to comment.