mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 22:35:44 +00:00
handle data and parity seperate in both BCH and RS
This commit is contained in:
parent
6b3bc5e534
commit
f545b5d6ab
8 changed files with 145 additions and 105 deletions
|
|
@ -34,31 +34,37 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
int compute_syndromes(uint8_t *code, ValueType *syndromes)
|
int compute_syndromes(uint8_t *data, uint8_t *parity, ValueType *syndromes)
|
||||||
{
|
{
|
||||||
// $syndromes_i = code(pe^{FCR+i})$
|
// $syndromes_i = code(pe^{FCR+i})$
|
||||||
ValueType coeff(get_be_bit(code, 0));
|
ValueType coeff(get_be_bit(data, 0));
|
||||||
for (int i = 0; i < NR; ++i)
|
for (int i = 0; i < NR; ++i)
|
||||||
syndromes[i] = coeff;
|
syndromes[i] = coeff;
|
||||||
update_syndromes(code, syndromes, 1, N);
|
update_syndromes(data, syndromes, 1, K);
|
||||||
|
update_syndromes(parity, syndromes, 0, NP);
|
||||||
int nonzero = 0;
|
int nonzero = 0;
|
||||||
for (int i = 0; i < NR; ++i)
|
for (int i = 0; i < NR; ++i)
|
||||||
nonzero += !!syndromes[i];
|
nonzero += !!syndromes[i];
|
||||||
return nonzero;
|
return nonzero;
|
||||||
}
|
}
|
||||||
int compute_syndromes(uint8_t *code, value_type *syndromes)
|
int compute_syndromes(uint8_t *data, uint8_t *parity, value_type *syndromes)
|
||||||
{
|
{
|
||||||
return compute_syndromes(code, reinterpret_cast<ValueType *>(syndromes));
|
return compute_syndromes(data, parity, reinterpret_cast<ValueType *>(syndromes));
|
||||||
}
|
}
|
||||||
int operator()(uint8_t *code, value_type *erasures = 0, int erasures_count = 0)
|
int operator()(uint8_t *data, uint8_t *parity, value_type *erasures = 0, int erasures_count = 0)
|
||||||
{
|
{
|
||||||
assert(0 <= erasures_count && erasures_count <= NR);
|
assert(0 <= erasures_count && erasures_count <= NR);
|
||||||
if (0) {
|
if (0) {
|
||||||
for (int i = 0; i < erasures_count; ++i)
|
for (int i = 0; i < erasures_count; ++i) {
|
||||||
set_be_bit(code, erasures[i], 0);
|
int idx = (int)erasures[i];
|
||||||
|
if (idx < K)
|
||||||
|
set_be_bit(data, idx, 0);
|
||||||
|
else
|
||||||
|
set_be_bit(parity, idx-K, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ValueType syndromes[NR];
|
ValueType syndromes[NR];
|
||||||
if (!compute_syndromes(code, syndromes))
|
if (!compute_syndromes(data, parity, syndromes))
|
||||||
return 0;
|
return 0;
|
||||||
IndexType locations[NR];
|
IndexType locations[NR];
|
||||||
ValueType magnitudes[NR];
|
ValueType magnitudes[NR];
|
||||||
|
|
@ -68,8 +74,14 @@ public:
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
if (1 < (int)magnitudes[i])
|
if (1 < (int)magnitudes[i])
|
||||||
return -1;
|
return -1;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i) {
|
||||||
xor_be_bit(code, (int)locations[i], (bool)magnitudes[i]);
|
int idx = (int)locations[i];
|
||||||
|
bool err = (bool)magnitudes[i];
|
||||||
|
if (idx < K)
|
||||||
|
xor_be_bit(data, idx, err);
|
||||||
|
else
|
||||||
|
xor_be_bit(parity, idx-K, err);
|
||||||
|
}
|
||||||
int corrections_count = 0;
|
int corrections_count = 0;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
corrections_count += !!magnitudes[i];
|
corrections_count += !!magnitudes[i];
|
||||||
|
|
@ -99,27 +111,33 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
int compute_syndromes(ValueType *code, ValueType *syndromes)
|
int compute_syndromes(ValueType *data, ValueType *parity, ValueType *syndromes)
|
||||||
{
|
{
|
||||||
// $syndromes_i = code(pe^{FCR+i})$
|
// $syndromes_i = code(pe^{FCR+i})$
|
||||||
ValueType coeff(code[0]);
|
ValueType coeff(data[0]);
|
||||||
for (int i = 0; i < NR; ++i)
|
for (int i = 0; i < NR; ++i)
|
||||||
syndromes[i] = coeff;
|
syndromes[i] = coeff;
|
||||||
update_syndromes(code, syndromes, 1, N);
|
update_syndromes(data, syndromes, 1, K);
|
||||||
|
update_syndromes(parity, syndromes, 0, NP);
|
||||||
int nonzero = 0;
|
int nonzero = 0;
|
||||||
for (int i = 0; i < NR; ++i)
|
for (int i = 0; i < NR; ++i)
|
||||||
nonzero += !!syndromes[i];
|
nonzero += !!syndromes[i];
|
||||||
return nonzero;
|
return nonzero;
|
||||||
}
|
}
|
||||||
int operator()(ValueType *code, IndexType *erasures = 0, int erasures_count = 0)
|
int operator()(ValueType *data, ValueType *parity, IndexType *erasures = 0, int erasures_count = 0)
|
||||||
{
|
{
|
||||||
assert(0 <= erasures_count && erasures_count <= NR);
|
assert(0 <= erasures_count && erasures_count <= NR);
|
||||||
if (0) {
|
if (0) {
|
||||||
for (int i = 0; i < erasures_count; ++i)
|
for (int i = 0; i < erasures_count; ++i) {
|
||||||
code[(int)erasures[i]] = ValueType(0);
|
int idx = (int)erasures[i];
|
||||||
|
if (idx < K)
|
||||||
|
data[idx] = ValueType(0);
|
||||||
|
else
|
||||||
|
parity[idx-K] = ValueType(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ValueType syndromes[NR];
|
ValueType syndromes[NR];
|
||||||
if (!compute_syndromes(code, syndromes))
|
if (!compute_syndromes(data, parity, syndromes))
|
||||||
return 0;
|
return 0;
|
||||||
IndexType locations[NR];
|
IndexType locations[NR];
|
||||||
ValueType magnitudes[NR];
|
ValueType magnitudes[NR];
|
||||||
|
|
@ -129,8 +147,13 @@ public:
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
if (1 < (int)magnitudes[i])
|
if (1 < (int)magnitudes[i])
|
||||||
return -1;
|
return -1;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i) {
|
||||||
code[(int)locations[i]] += magnitudes[i];
|
int idx = (int)locations[i];
|
||||||
|
if (idx < K)
|
||||||
|
data[idx] += magnitudes[i];
|
||||||
|
else
|
||||||
|
parity[idx-K] += magnitudes[i];
|
||||||
|
}
|
||||||
int corrections_count = 0;
|
int corrections_count = 0;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
corrections_count += !!magnitudes[i];
|
corrections_count += !!magnitudes[i];
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class BoseChaudhuriHocquenghemEncoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const int N = LEN, K = MSG, NP = N - K;
|
static const int N = LEN, K = MSG, NP = N - K;
|
||||||
static const int G = ((NP+1+K%8)+7)/8;
|
static const int G = ((NP+1)+7)/8;
|
||||||
private:
|
private:
|
||||||
uint8_t generator[G];
|
uint8_t generator[G];
|
||||||
static constexpr uint8_t slb1(uint8_t *buf, int pos)
|
static constexpr uint8_t slb1(uint8_t *buf, int pos)
|
||||||
|
|
@ -55,36 +55,24 @@ public:
|
||||||
std::cerr << " " << get_be_bit(generator, NP-i);
|
std::cerr << " " << get_be_bit(generator, NP-i);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
if (K%8 == 1) {
|
for (int i = 0; i < NP; ++i)
|
||||||
set_be_bit(generator, 0, 0);
|
set_be_bit(generator, i, get_be_bit(generator, i+1));
|
||||||
} else if (K%8) {
|
set_be_bit(generator, NP, 0);
|
||||||
int shift = K%8-1;
|
|
||||||
set_be_bit(generator, 0, 0);
|
|
||||||
for (int i = NP; i >= 0; --i)
|
|
||||||
set_be_bit(generator, i+shift, get_be_bit(generator, i));
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i <= NP; ++i)
|
|
||||||
set_be_bit(generator, i, get_be_bit(generator, i+1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void operator()(uint8_t *code)
|
void operator()(uint8_t *data, uint8_t *parity)
|
||||||
{
|
{
|
||||||
// $code = data * x^{NP} + (data * x^{NP}) \mod{generator}$
|
// $code = data * x^{NP} + (data * x^{NP}) \mod{generator}$
|
||||||
static const uint8_t mask = (1<<(8-K%8))-1;
|
for (int l = 0; l < NP/8; ++l)
|
||||||
code[K/8] &= ~mask;
|
parity[l] = 0;
|
||||||
for (int l = K/8+1; l < N/8; ++l)
|
|
||||||
code[l] = 0;
|
|
||||||
for (int i = 0; i < K; ++i) {
|
for (int i = 0; i < K; ++i) {
|
||||||
if (get_be_bit(code, i) != get_be_bit(code, K)) {
|
if (get_be_bit(data, i) != get_be_bit(parity, 0)) {
|
||||||
code[K/8] = generator[0] ^ ((~mask&code[K/8])|(mask&slb1(code, K/8)));
|
for (int l = 0; l < (NP-1)/8; ++l)
|
||||||
for (int l = 1; l < NP/8; ++l)
|
parity[l] = generator[l] ^ slb1(parity, l);
|
||||||
code[l+K/8] = generator[l] ^ slb1(code, l+K/8);
|
parity[(NP-1)/8] = generator[(NP-1)/8] ^ (parity[(NP-1)/8]<<1);
|
||||||
code[(N-1)/8] = generator[NP/8] ^ (code[(N-1)/8]<<1);
|
|
||||||
} else {
|
} else {
|
||||||
code[K/8] = (~mask&code[K/8]) | (mask&slb1(code, K/8));
|
for (int l = 0; l < (NP-1)/8; ++l)
|
||||||
for (int l = K/8+1; l < (N-1)/8; ++l)
|
parity[l] = slb1(parity, l);
|
||||||
code[l] = slb1(code, l);
|
parity[(NP-1)/8] <<= 1;
|
||||||
code[(N-1)/8] <<= 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -137,20 +125,20 @@ public:
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void operator()(ValueType *code)
|
void operator()(ValueType *data, ValueType *parity)
|
||||||
{
|
{
|
||||||
// $code = data * x^{NP} + (data * x^{NP}) \mod{generator}$
|
// $code = data * x^{NP} + (data * x^{NP}) \mod{generator}$
|
||||||
for (int i = 0; i < NP; ++i)
|
for (int i = 0; i < NP; ++i)
|
||||||
code[K+i] = ValueType(0);
|
parity[i] = ValueType(0);
|
||||||
for (int i = 0; i < K; ++i) {
|
for (int i = 0; i < K; ++i) {
|
||||||
if (code[i] != code[K]) {
|
if (data[i] != parity[0]) {
|
||||||
for (int j = 1; j < NP; ++j)
|
for (int j = 1; j < NP; ++j)
|
||||||
code[K+j-1] = generator[NP-j] + code[K+j];
|
parity[j-1] = generator[NP-j] + parity[j];
|
||||||
code[N-1] = generator[0];
|
parity[NP-1] = generator[0];
|
||||||
} else {
|
} else {
|
||||||
for (int j = 1; j < NP; ++j)
|
for (int j = 1; j < NP; ++j)
|
||||||
code[K+j-1] = code[K+j];
|
parity[j-1] = parity[j];
|
||||||
code[N-1] = ValueType(0);
|
parity[NP-1] = ValueType(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,47 +33,58 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
int compute_syndromes(ValueType *code, ValueType *syndromes)
|
int compute_syndromes(ValueType *data, ValueType *parity, ValueType *syndromes)
|
||||||
{
|
{
|
||||||
// $syndromes_i = code(pe^{FCR+i})$
|
// $syndromes_i = code(pe^{FCR+i})$
|
||||||
ValueType coeff(code[0]);
|
ValueType coeff(data[0]);
|
||||||
for (int i = 0; i < NR; ++i)
|
for (int i = 0; i < NR; ++i)
|
||||||
syndromes[i] = coeff;
|
syndromes[i] = coeff;
|
||||||
update_syndromes(code, syndromes, 1, N);
|
update_syndromes(data, syndromes, 1, K);
|
||||||
|
update_syndromes(parity, syndromes, 0, NP);
|
||||||
int nonzero = 0;
|
int nonzero = 0;
|
||||||
for (int i = 0; i < NR; ++i)
|
for (int i = 0; i < NR; ++i)
|
||||||
nonzero += !!syndromes[i];
|
nonzero += !!syndromes[i];
|
||||||
return nonzero;
|
return nonzero;
|
||||||
}
|
}
|
||||||
int operator()(ValueType *code, IndexType *erasures = 0, int erasures_count = 0)
|
int operator()(ValueType *data, ValueType *parity, IndexType *erasures = 0, int erasures_count = 0)
|
||||||
{
|
{
|
||||||
assert(0 <= erasures_count && erasures_count <= NR);
|
assert(0 <= erasures_count && erasures_count <= NR);
|
||||||
if (0) {
|
if (0) {
|
||||||
for (int i = 0; i < erasures_count; ++i)
|
for (int i = 0; i < erasures_count; ++i) {
|
||||||
code[(int)erasures[i]] = ValueType(0);
|
int idx = (int)erasures[i];
|
||||||
|
if (idx < K)
|
||||||
|
data[idx] = ValueType(0);
|
||||||
|
else
|
||||||
|
parity[idx-K] = ValueType(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ValueType syndromes[NR];
|
ValueType syndromes[NR];
|
||||||
if (!compute_syndromes(code, syndromes))
|
if (!compute_syndromes(data, parity, syndromes))
|
||||||
return 0;
|
return 0;
|
||||||
IndexType locations[NR];
|
IndexType locations[NR];
|
||||||
ValueType magnitudes[NR];
|
ValueType magnitudes[NR];
|
||||||
int count = algorithm(syndromes, locations, magnitudes, erasures, erasures_count);
|
int count = algorithm(syndromes, locations, magnitudes, erasures, erasures_count);
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
return count;
|
return count;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i) {
|
||||||
code[(int)locations[i]] += magnitudes[i];
|
int idx = (int)locations[i];
|
||||||
|
if (idx < K)
|
||||||
|
data[idx] += magnitudes[i];
|
||||||
|
else
|
||||||
|
parity[idx-K] += magnitudes[i];
|
||||||
|
}
|
||||||
int corrections_count = 0;
|
int corrections_count = 0;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
corrections_count += !!magnitudes[i];
|
corrections_count += !!magnitudes[i];
|
||||||
return corrections_count;
|
return corrections_count;
|
||||||
}
|
}
|
||||||
int operator()(value_type *code, value_type *erasures = 0, int erasures_count = 0)
|
int operator()(value_type *data, value_type *parity, value_type *erasures = 0, int erasures_count = 0)
|
||||||
{
|
{
|
||||||
return (*this)(reinterpret_cast<ValueType *>(code), reinterpret_cast<IndexType *>(erasures), erasures_count);
|
return (*this)(reinterpret_cast<ValueType *>(data), reinterpret_cast<ValueType *>(parity), reinterpret_cast<IndexType *>(erasures), erasures_count);
|
||||||
}
|
}
|
||||||
int compute_syndromes(value_type *code, value_type *syndromes)
|
int compute_syndromes(value_type *data, value_type *parity, value_type *syndromes)
|
||||||
{
|
{
|
||||||
return compute_syndromes(reinterpret_cast<ValueType *>(code), reinterpret_cast<ValueType *>(syndromes));
|
return compute_syndromes(reinterpret_cast<ValueType *>(data), reinterpret_cast<ValueType *>(parity), reinterpret_cast<ValueType *>(syndromes));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,28 +48,28 @@ public:
|
||||||
for (int i = 0; i <= NR; ++i)
|
for (int i = 0; i <= NR; ++i)
|
||||||
generator[i] = index(tmp[i]);
|
generator[i] = index(tmp[i]);
|
||||||
}
|
}
|
||||||
void operator()(ValueType *code)
|
void operator()(ValueType *data, ValueType *parity)
|
||||||
{
|
{
|
||||||
// $code = data * x^{NR} + (data * x^{NR}) \mod{generator}$
|
// $code = data * x^{NR} + (data * x^{NR}) \mod{generator}$
|
||||||
for (int i = 0; i < NR; ++i)
|
for (int i = 0; i < NR; ++i)
|
||||||
code[K+i] = ValueType(0);
|
parity[i] = ValueType(0);
|
||||||
for (int i = 0; i < K; ++i) {
|
for (int i = 0; i < K; ++i) {
|
||||||
ValueType feedback = code[i] + code[K];
|
ValueType feedback = data[i] + parity[0];
|
||||||
if (feedback) {
|
if (feedback) {
|
||||||
IndexType fb = index(feedback);
|
IndexType fb = index(feedback);
|
||||||
for (int j = 1; j < NR; ++j)
|
for (int j = 1; j < NR; ++j)
|
||||||
code[K+j-1] = fma(fb, generator[NR-j], code[K+j]);
|
parity[j-1] = fma(fb, generator[NR-j], parity[j]);
|
||||||
code[N-1] = value(generator[0] * fb);
|
parity[NP-1] = value(generator[0] * fb);
|
||||||
} else {
|
} else {
|
||||||
for (int j = 1; j < NR; ++j)
|
for (int j = 1; j < NR; ++j)
|
||||||
code[K+j-1] = code[K+j];
|
parity[j-1] = parity[j];
|
||||||
code[N-1] = ValueType(0);
|
parity[NP-1] = ValueType(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void operator()(value_type *code)
|
void operator()(value_type *data, value_type *parity)
|
||||||
{
|
{
|
||||||
(*this)(reinterpret_cast<ValueType *>(code));
|
(*this)(reinterpret_cast<ValueType *>(data), reinterpret_cast<ValueType *>(parity));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,25 @@ int main()
|
||||||
// NASA INTRO BCH(15, 5) T=3
|
// NASA INTRO BCH(15, 5) T=3
|
||||||
typedef CODE::GaloisField<4, 0b10011, uint8_t> GF;
|
typedef CODE::GaloisField<4, 0b10011, uint8_t> GF;
|
||||||
typedef CODE::BoseChaudhuriHocquenghemDecoder<6, 1, 5, GF> BCH;
|
typedef CODE::BoseChaudhuriHocquenghemDecoder<6, 1, 5, GF> BCH;
|
||||||
const int L = (BCH::N + 7) / 8;
|
const int D = (BCH::K + 7) / 8;
|
||||||
|
const int P = (BCH::NP + 7) / 8;
|
||||||
|
const int L = D + P;
|
||||||
GF instance;
|
GF instance;
|
||||||
BCH decode;
|
BCH decode;
|
||||||
uint8_t target[L] = { 0b11001000, 0b11110100 };
|
uint8_t target[L] = { 0b11001000, 0b00011110, 0b10000000 };
|
||||||
uint8_t code[L];
|
uint8_t code[L];
|
||||||
for (int i = 0; i < L; ++i)
|
for (int i = 0; i < L; ++i)
|
||||||
code[i] = target[i];
|
code[i] = target[i];
|
||||||
std::uniform_int_distribution<int> distribution(0, BCH::N-1);
|
std::uniform_int_distribution<int> distribution(0, BCH::N-1);
|
||||||
auto noise = std::bind(distribution, generator);
|
auto noise = std::bind(distribution, generator);
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i) {
|
||||||
CODE::xor_be_bit(code, noise(), 1);
|
int n = noise();
|
||||||
decode(code);
|
if (n < BCH::K)
|
||||||
|
CODE::xor_be_bit(code, n, 1);
|
||||||
|
else
|
||||||
|
CODE::xor_be_bit(code+D, n-BCH::K, 1);
|
||||||
|
}
|
||||||
|
decode(code, code + D);
|
||||||
for (int i = 0; i < L; ++i)
|
for (int i = 0; i < L; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +45,9 @@ int main()
|
||||||
// DVB-S2 FULL BCH(65535, 65343) T=12
|
// DVB-S2 FULL BCH(65535, 65343) T=12
|
||||||
typedef CODE::GaloisField<16, 0b10000000000101101, uint16_t> GF;
|
typedef CODE::GaloisField<16, 0b10000000000101101, uint16_t> GF;
|
||||||
typedef CODE::BoseChaudhuriHocquenghemDecoder<24, 1, 65343, GF> BCH;
|
typedef CODE::BoseChaudhuriHocquenghemDecoder<24, 1, 65343, GF> BCH;
|
||||||
const int L = (BCH::N + 7) / 8;
|
const int D = (BCH::K + 7) / 8;
|
||||||
|
const int P = (BCH::NP + 7) / 8;
|
||||||
|
const int L = D + P;
|
||||||
GF *instance = new GF();
|
GF *instance = new GF();
|
||||||
BCH *decode = new BCH();
|
BCH *decode = new BCH();
|
||||||
uint8_t *target = new uint8_t[L];
|
uint8_t *target = new uint8_t[L];
|
||||||
|
|
@ -48,15 +57,20 @@ int main()
|
||||||
CODE::set_be_bit(target, i, (s^=s>>7)&1);
|
CODE::set_be_bit(target, i, (s^=s>>7)&1);
|
||||||
bool parity[BCH::NP] = { 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0 };
|
bool parity[BCH::NP] = { 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0 };
|
||||||
for (int i = 0; i < BCH::NP; ++i)
|
for (int i = 0; i < BCH::NP; ++i)
|
||||||
CODE::set_be_bit(target, BCH::K+i, parity[i]);
|
CODE::set_be_bit(target + D, i, parity[i]);
|
||||||
uint8_t *code = new uint8_t[L];
|
uint8_t *code = new uint8_t[L];
|
||||||
for (int i = 0; i < L; ++i)
|
for (int i = 0; i < L; ++i)
|
||||||
code[i] = target[i];
|
code[i] = target[i];
|
||||||
std::uniform_int_distribution<int> distribution(0, BCH::N-1);
|
std::uniform_int_distribution<int> distribution(0, BCH::N-1);
|
||||||
auto noise = std::bind(distribution, generator);
|
auto noise = std::bind(distribution, generator);
|
||||||
for (int i = 0; i < 12; ++i)
|
for (int i = 0; i < 12; ++i) {
|
||||||
CODE::xor_be_bit(code, noise(), 1);
|
int n = noise();
|
||||||
(*decode)(code);
|
if (n < BCH::K)
|
||||||
|
CODE::xor_be_bit(code, n, 1);
|
||||||
|
else
|
||||||
|
CODE::xor_be_bit(code+D, n-BCH::K, 1);
|
||||||
|
}
|
||||||
|
(*decode)(code, code + D);
|
||||||
for (int i = 0; i < L; ++i)
|
for (int i = 0; i < L; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
delete[] target;
|
delete[] target;
|
||||||
|
|
@ -64,7 +78,7 @@ int main()
|
||||||
delete decode;
|
delete decode;
|
||||||
delete instance;
|
delete instance;
|
||||||
}
|
}
|
||||||
if (0) {
|
if (1) {
|
||||||
// NASA INTRO BCH(15, 5) T=3
|
// NASA INTRO BCH(15, 5) T=3
|
||||||
typedef CODE::GaloisField<4, 0b10011, uint8_t> GF;
|
typedef CODE::GaloisField<4, 0b10011, uint8_t> GF;
|
||||||
typedef CODE::BoseChaudhuriHocquenghemDecoderReference<6, 1, 5, GF> BCH;
|
typedef CODE::BoseChaudhuriHocquenghemDecoderReference<6, 1, 5, GF> BCH;
|
||||||
|
|
@ -78,11 +92,11 @@ int main()
|
||||||
auto noise = std::bind(distribution, generator);
|
auto noise = std::bind(distribution, generator);
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
code[noise()] ^= 1;
|
code[noise()] ^= 1;
|
||||||
decode(reinterpret_cast<GF::ValueType *>(code));
|
decode(reinterpret_cast<GF::ValueType *>(code), reinterpret_cast<GF::ValueType *>(code) + BCH::K);
|
||||||
for (int i = 0; i < BCH::N; ++i)
|
for (int i = 0; i < BCH::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
}
|
}
|
||||||
if (0) {
|
if (1) {
|
||||||
// DVB-S2 FULL BCH(65535, 65343) T=12
|
// DVB-S2 FULL BCH(65535, 65343) T=12
|
||||||
typedef CODE::GaloisField<16, 0b10000000000101101, uint16_t> GF;
|
typedef CODE::GaloisField<16, 0b10000000000101101, uint16_t> GF;
|
||||||
typedef CODE::BoseChaudhuriHocquenghemDecoderReference<24, 1, 65343, GF> BCH;
|
typedef CODE::BoseChaudhuriHocquenghemDecoderReference<24, 1, 65343, GF> BCH;
|
||||||
|
|
@ -101,7 +115,7 @@ int main()
|
||||||
auto noise = std::bind(distribution, generator);
|
auto noise = std::bind(distribution, generator);
|
||||||
for (int i = 0; i < 12; ++i)
|
for (int i = 0; i < 12; ++i)
|
||||||
code[noise()] ^= 1;
|
code[noise()] ^= 1;
|
||||||
(*decode)(reinterpret_cast<GF::ValueType *>(code));
|
(*decode)(reinterpret_cast<GF::ValueType *>(code), reinterpret_cast<GF::ValueType *>(code) + BCH::K);
|
||||||
for (int i = 0; i < BCH::N; ++i)
|
for (int i = 0; i < BCH::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
delete[] target;
|
delete[] target;
|
||||||
|
|
|
||||||
|
|
@ -15,18 +15,22 @@ int main()
|
||||||
if (1) {
|
if (1) {
|
||||||
// NASA INTRO BCH(15, 5) T=3
|
// NASA INTRO BCH(15, 5) T=3
|
||||||
typedef CODE::BoseChaudhuriHocquenghemEncoder<15, 5> BCH;
|
typedef CODE::BoseChaudhuriHocquenghemEncoder<15, 5> BCH;
|
||||||
const int L = (BCH::N + 7) / 8;
|
const int D = (BCH::K + 7) / 8;
|
||||||
|
const int P = (BCH::NP + 7) / 8;
|
||||||
|
const int L = D + P;
|
||||||
BCH encode({0b10011, 0b11111, 0b00111});
|
BCH encode({0b10011, 0b11111, 0b00111});
|
||||||
uint8_t code[L] = { 0b11001000 };
|
uint8_t code[L] = { 0b11001000 };
|
||||||
uint8_t target[L] = { 0b11001000, 0b11110100 };
|
uint8_t target[L] = { 0b11001000, 0b00011110, 0b10000000 };
|
||||||
encode(code);
|
encode(code, code + D);
|
||||||
for (int i = 0; i < L; ++i)
|
for (int i = 0; i < L; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
}
|
}
|
||||||
if (1) {
|
if (1) {
|
||||||
// DVB-S2 FULL BCH(65535, 65343) T=12
|
// DVB-S2 FULL BCH(65535, 65343) T=12
|
||||||
typedef CODE::BoseChaudhuriHocquenghemEncoder<65535, 65343> BCH;
|
typedef CODE::BoseChaudhuriHocquenghemEncoder<65535, 65343> BCH;
|
||||||
const int L = (BCH::N + 7) / 8;
|
const int D = (BCH::K + 7) / 8;
|
||||||
|
const int P = (BCH::NP + 7) / 8;
|
||||||
|
const int L = D + P;
|
||||||
BCH *encode = new BCH({0b10000000000101101, 0b10000000101110011, 0b10000111110111101, 0b10101101001010101, 0b10001111100101111, 0b11111011110110101, 0b11010111101100101, 0b10111001101100111, 0b10000111010100001, 0b10111010110100111, 0b10011101000101101, 0b10001101011100011});
|
BCH *encode = new BCH({0b10000000000101101, 0b10000000101110011, 0b10000111110111101, 0b10101101001010101, 0b10001111100101111, 0b11111011110110101, 0b11010111101100101, 0b10111001101100111, 0b10000111010100001, 0b10111010110100111, 0b10011101000101101, 0b10001101011100011});
|
||||||
uint8_t *target = new uint8_t[L];
|
uint8_t *target = new uint8_t[L];
|
||||||
for (int i = 0; i < L; ++i)
|
for (int i = 0; i < L; ++i)
|
||||||
|
|
@ -38,15 +42,15 @@ int main()
|
||||||
code[i] = target[i];
|
code[i] = target[i];
|
||||||
bool parity[BCH::NP] = { 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0 };
|
bool parity[BCH::NP] = { 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0 };
|
||||||
for (int i = 0; i < BCH::NP; ++i)
|
for (int i = 0; i < BCH::NP; ++i)
|
||||||
CODE::set_be_bit(target, BCH::K+i, parity[i]);
|
CODE::set_be_bit(target + D, i, parity[i]);
|
||||||
(*encode)(code);
|
(*encode)(code, code + D);
|
||||||
for (int i = 0; i < L; ++i)
|
for (int i = 0; i < L; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
delete[] target;
|
delete[] target;
|
||||||
delete[] code;
|
delete[] code;
|
||||||
delete encode;
|
delete encode;
|
||||||
}
|
}
|
||||||
if (0) {
|
if (1) {
|
||||||
// NASA INTRO BCH(15, 5) T=3
|
// NASA INTRO BCH(15, 5) T=3
|
||||||
typedef CODE::GaloisField<4, 0b10011, uint8_t> GF;
|
typedef CODE::GaloisField<4, 0b10011, uint8_t> GF;
|
||||||
typedef CODE::BoseChaudhuriHocquenghemEncoderReference<6, 1, 5, GF> BCH;
|
typedef CODE::BoseChaudhuriHocquenghemEncoderReference<6, 1, 5, GF> BCH;
|
||||||
|
|
@ -54,11 +58,11 @@ int main()
|
||||||
BCH encode({0b10011, 0b11111, 0b00111});
|
BCH encode({0b10011, 0b11111, 0b00111});
|
||||||
BCH::value_type code[BCH::N] = { 1, 1, 0, 0, 1 };
|
BCH::value_type code[BCH::N] = { 1, 1, 0, 0, 1 };
|
||||||
BCH::value_type target[BCH::N] = { 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0 };
|
BCH::value_type target[BCH::N] = { 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0 };
|
||||||
encode(reinterpret_cast<GF::ValueType *>(code));
|
encode(reinterpret_cast<GF::ValueType *>(code), reinterpret_cast<GF::ValueType *>(code) + BCH::K);
|
||||||
for (int i = 0; i < BCH::N; ++i)
|
for (int i = 0; i < BCH::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
}
|
}
|
||||||
if (0) {
|
if (1) {
|
||||||
// DVB-S2 FULL BCH(65535, 65343) T=12
|
// DVB-S2 FULL BCH(65535, 65343) T=12
|
||||||
typedef CODE::GaloisField<16, 0b10000000000101101, uint16_t> GF;
|
typedef CODE::GaloisField<16, 0b10000000000101101, uint16_t> GF;
|
||||||
typedef CODE::BoseChaudhuriHocquenghemEncoderReference<24, 1, 65343, GF> BCH;
|
typedef CODE::BoseChaudhuriHocquenghemEncoderReference<24, 1, 65343, GF> BCH;
|
||||||
|
|
@ -71,7 +75,7 @@ int main()
|
||||||
BCH::value_type parity[BCH::NP] = { 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0 };
|
BCH::value_type parity[BCH::NP] = { 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0 };
|
||||||
for (int i = 0; i < BCH::NP; ++i)
|
for (int i = 0; i < BCH::NP; ++i)
|
||||||
target[BCH::K+i] = parity[i];
|
target[BCH::K+i] = parity[i];
|
||||||
(*encode)(reinterpret_cast<GF::ValueType *>(code));
|
(*encode)(reinterpret_cast<GF::ValueType *>(code), reinterpret_cast<GF::ValueType *>(code) + BCH::K);
|
||||||
for (int i = 0; i < BCH::N; ++i)
|
for (int i = 0; i < BCH::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
delete[] target;
|
delete[] target;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ int main()
|
||||||
auto val = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N), generator);
|
auto val = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N), generator);
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
code[pos()] = val();
|
code[pos()] = val();
|
||||||
decode(code);
|
decode(code, code + RS::K);
|
||||||
for (int i = 0; i < RS::N; ++i)
|
for (int i = 0; i < RS::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +51,7 @@ int main()
|
||||||
auto val = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N), generator);
|
auto val = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N), generator);
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
code[pos()] = val();
|
code[pos()] = val();
|
||||||
decode(code);
|
decode(code, code + RS::K);
|
||||||
for (int i = 0; i < RS::N; ++i)
|
for (int i = 0; i < RS::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -74,7 +74,7 @@ int main()
|
||||||
auto val = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N), generator);
|
auto val = std::bind(std::uniform_int_distribution<RS::value_type>(0, RS::N), generator);
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 32; ++i)
|
||||||
code[pos()] = val();
|
code[pos()] = val();
|
||||||
(*decode)(code);
|
(*decode)(code, code + RS::K);
|
||||||
for (int i = 0; i < RS::N; ++i)
|
for (int i = 0; i < RS::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
delete[] target;
|
delete[] target;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ int main()
|
||||||
RS encode;
|
RS encode;
|
||||||
RS::value_type code[RS::N] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
RS::value_type code[RS::N] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||||
RS::value_type target[RS::N] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 3, 12, 12 };
|
RS::value_type target[RS::N] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 3, 12, 12 };
|
||||||
encode(code);
|
encode(code, code + RS::K);
|
||||||
for (int i = 0; i < RS::N; ++i)
|
for (int i = 0; i < RS::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ int main()
|
||||||
RS::value_type parity[RS::NP] = { 1, 126, 147, 48, 155, 224, 3, 157, 29, 226, 40, 114, 61, 30, 244, 75 };
|
RS::value_type parity[RS::NP] = { 1, 126, 147, 48, 155, 224, 3, 157, 29, 226, 40, 114, 61, 30, 244, 75 };
|
||||||
for (int i = 0; i < RS::NP; ++i)
|
for (int i = 0; i < RS::NP; ++i)
|
||||||
target[RS::K+i] = parity[i];
|
target[RS::K+i] = parity[i];
|
||||||
encode(code);
|
encode(code, code + RS::K);
|
||||||
for (int i = 0; i < RS::N; ++i)
|
for (int i = 0; i < RS::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ int main()
|
||||||
RS::value_type parity[RS::NP] = { 25271, 26303, 22052, 31318, 31233, 6076, 40148, 29468, 47507, 32655, 12404, 13265, 23901, 38403, 50967, 50433, 40818, 226, 62296, 23636, 56393, 12952, 11476, 44416, 518, 50014, 10037, 57582, 33421, 42654, 54025, 7157, 4826, 52148, 17167, 23294, 6427, 40953, 11168, 35305, 18209, 1868, 39971, 54928, 27566, 1424, 4846, 25347, 34710, 42190, 56452, 21859, 49805, 28028, 41657, 25756, 22014, 24479, 28758, 17438, 12976, 61743, 46735, 1557 };
|
RS::value_type parity[RS::NP] = { 25271, 26303, 22052, 31318, 31233, 6076, 40148, 29468, 47507, 32655, 12404, 13265, 23901, 38403, 50967, 50433, 40818, 226, 62296, 23636, 56393, 12952, 11476, 44416, 518, 50014, 10037, 57582, 33421, 42654, 54025, 7157, 4826, 52148, 17167, 23294, 6427, 40953, 11168, 35305, 18209, 1868, 39971, 54928, 27566, 1424, 4846, 25347, 34710, 42190, 56452, 21859, 49805, 28028, 41657, 25756, 22014, 24479, 28758, 17438, 12976, 61743, 46735, 1557 };
|
||||||
for (int i = 0; i < RS::NP; ++i)
|
for (int i = 0; i < RS::NP; ++i)
|
||||||
target[RS::K+i] = parity[i];
|
target[RS::K+i] = parity[i];
|
||||||
(*encode)(code);
|
(*encode)(code, code + RS::K);
|
||||||
for (int i = 0; i < RS::N; ++i)
|
for (int i = 0; i < RS::N; ++i)
|
||||||
assert(code[i] == target[i]);
|
assert(code[i] == target[i]);
|
||||||
delete[] target;
|
delete[] target;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue