#ifndef permutation_h #define permutation_h #include #include "bigint.h" std::vector permutation_gen(bigint); class permutation { std::vector pi; public: permutation(bigint n) : pi(permutation_gen(n)) { } permutation(bigint n,bigint plus) { plus %= n; if (plus < 0) plus += n; for (bigint i = 0; i < n; i++) pi.push_back((i + plus) % n); } template void permute(std::vector &v,bigint offset=0) { std::vector w = v; for (bigint i = 0; i < pi.size(); i++) w.at(i + offset) = v.at(pi.at(i) + offset); for (bigint i = 0; i < v.size(); i++) v.at(i) = w.at(i); } } ; #endif