mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 22:35:44 +00:00
use uint32_t for the frozen bits
This commit is contained in:
parent
687ae706d7
commit
631ec8beef
6 changed files with 312 additions and 44 deletions
|
|
@ -17,6 +17,11 @@ Copyright 2020 Ahmet Inan <inan@aicodix.de>
|
|||
#include "polar_encoder.hh"
|
||||
#include "polar_freezer.hh"
|
||||
|
||||
bool get_bit(const uint32_t *bits, int idx)
|
||||
{
|
||||
return (bits[idx/32] >> (idx%32)) & 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const int M = 20;
|
||||
|
|
@ -34,7 +39,7 @@ int main()
|
|||
typedef std::default_random_engine generator;
|
||||
typedef std::uniform_int_distribution<int> distribution;
|
||||
auto data = std::bind(distribution(0, 1), generator(rd()));
|
||||
auto frozen = new uint8_t[N];
|
||||
auto frozen = new uint32_t[(N+31)/32];
|
||||
auto codeword = new code_type[N];
|
||||
auto temp = new code_type[N];
|
||||
|
||||
|
|
@ -92,7 +97,7 @@ int main()
|
|||
CODE::PolarSysEnc<code_type> sysenc;
|
||||
sysenc(codeword, message, frozen, M);
|
||||
for (int i = 0, j = 0; i < N; ++i)
|
||||
if (!frozen[i])
|
||||
if (!get_bit(frozen, i))
|
||||
assert(codeword[i] == message[j++]);
|
||||
} else {
|
||||
CODE::PolarEncoder<code_type> encode;
|
||||
|
|
@ -129,7 +134,7 @@ int main()
|
|||
CODE::PolarEncoder<code_type> encode;
|
||||
encode(temp, decoded, frozen, M);
|
||||
for (int i = 0, j = 0; i < N; ++i)
|
||||
if (!frozen[i])
|
||||
if (!get_bit(frozen, i))
|
||||
decoded[j++] = temp[i];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue