diff --git a/permute.hh b/permute.hh index 82ee3a9..283ffbd 100644 --- a/permute.hh +++ b/permute.hh @@ -35,12 +35,14 @@ public: } }; -template -void BitReversalPermute(TYPE *array, int n) { - for (int i = 0, j = 0; i < n - 1; ++i) { +template +static void BitReversalPermute(TYPE *array) +{ + static_assert(SIZE > 0 && (SIZE & (SIZE - 1)) == 0, "SIZE not power of two"); + for (int i = 0, j = 0; i < SIZE - 1; ++i) { if (i < j) std::swap(array[i], array[j]); - int k = n >> 1; + int k = SIZE >> 1; while (j & k) { j ^= k; k >>= 1;