mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 14:30:36 +00:00
removed block shuffle
This commit is contained in:
parent
8a055ac2b2
commit
9e32042df8
1 changed files with 0 additions and 42 deletions
42
permute.hh
42
permute.hh
|
|
@ -41,48 +41,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <int SIZE, int BLOCK>
|
|
||||||
class ReversibleBlockShuffle
|
|
||||||
{
|
|
||||||
static_assert(SIZE >= 2 * BLOCK, "SIZE not large enough");
|
|
||||||
static_assert(SIZE % BLOCK == 0, "BLOCK does not divide SIZE");
|
|
||||||
static constexpr int BLOCKS = SIZE / BLOCK;
|
|
||||||
int seq[SIZE-1];
|
|
||||||
public:
|
|
||||||
ReversibleBlockShuffle()
|
|
||||||
{
|
|
||||||
CODE::Xorshift32 prng;
|
|
||||||
for (int j = 0; j < BLOCKS; ++j) {
|
|
||||||
if (j < BLOCKS-1)
|
|
||||||
seq[BLOCK*j] = j + prng() % (BLOCKS - j);
|
|
||||||
for (int i = 0; i < BLOCK-1; ++i)
|
|
||||||
seq[BLOCK*j+1+i] = i + prng() % (BLOCK - i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template <typename TYPE>
|
|
||||||
void forward(TYPE *array)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < BLOCKS; ++j) {
|
|
||||||
if (j < BLOCKS-1)
|
|
||||||
for (int i = 0; i < BLOCK; ++i)
|
|
||||||
std::swap(array[BLOCK*j+i], array[BLOCK*seq[BLOCK*j]+i]);
|
|
||||||
for (int i = 0; i < BLOCK-1; ++i)
|
|
||||||
std::swap(array[BLOCK*j+i], array[BLOCK*j+seq[BLOCK*j+1+i]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template <typename TYPE>
|
|
||||||
void reverse(TYPE *array)
|
|
||||||
{
|
|
||||||
for (int j = BLOCKS-1; j >= 0; --j) {
|
|
||||||
for (int i = BLOCK-2; i >= 0; --i)
|
|
||||||
std::swap(array[BLOCK*j+i], array[BLOCK*j+seq[BLOCK*j+1+i]]);
|
|
||||||
if (j < BLOCKS-1)
|
|
||||||
for (int i = 0; i < BLOCK; ++i)
|
|
||||||
std::swap(array[BLOCK*j+i], array[BLOCK*seq[BLOCK*j]+i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <int SIZE, typename TYPE>
|
template <int SIZE, typename TYPE>
|
||||||
static void BitReversalPermute(TYPE *array)
|
static void BitReversalPermute(TYPE *array)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue