mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 14:30:36 +00:00
added bit-reversal permutation
This commit is contained in:
parent
e0857552bb
commit
f6170cc923
1 changed files with 14 additions and 0 deletions
14
permute.hh
14
permute.hh
|
|
@ -35,5 +35,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
void BitReversalPermute(TYPE *array, int n) {
|
||||
for (int i = 0, j = 0; i < n - 1; ++i) {
|
||||
if (i < j)
|
||||
std::swap(array[i], array[j]);
|
||||
int k = n >> 1;
|
||||
while (j & k) {
|
||||
j ^= k;
|
||||
k >>= 1;
|
||||
}
|
||||
j ^= k;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue