use compile time constant for size

This commit is contained in:
Ahmet Inan 2023-03-27 10:09:18 +02:00
commit 3a860b9c73

View file

@ -35,12 +35,14 @@ public:
}
};
template <typename TYPE>
void BitReversalPermute(TYPE *array, int n) {
for (int i = 0, j = 0; i < n - 1; ++i) {
template <int SIZE, typename TYPE>
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;