mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 22:35:44 +00:00
also return codeword unmodulated
This commit is contained in:
parent
5cf0ff2297
commit
05bd06ec0a
2 changed files with 8 additions and 7 deletions
|
|
@ -34,11 +34,12 @@ public:
|
||||||
{
|
{
|
||||||
return (msg << P) | par[msg];
|
return (msg << P) | par[msg];
|
||||||
}
|
}
|
||||||
void operator()(int8_t *code, int msg)
|
int operator()(int8_t *code, int msg)
|
||||||
{
|
{
|
||||||
int cw = (*this)(msg);
|
int cw = (*this)(msg);
|
||||||
for (int i = 0; i < N; ++i)
|
for (int i = 0; i < N; ++i)
|
||||||
code[i] = 1 - 2 * ((cw >> i) & 1);
|
code[i] = 1 - 2 * ((cw >> i) & 1);
|
||||||
|
return cw;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ int main()
|
||||||
float symb[CODE_LEN];
|
float symb[CODE_LEN];
|
||||||
|
|
||||||
int dat = data();
|
int dat = data();
|
||||||
encode(code, dat);
|
int enc = encode(code, dat);
|
||||||
|
|
||||||
for (int i = 0; i < CODE_LEN; ++i)
|
for (int i = 0; i < CODE_LEN; ++i)
|
||||||
orig[i] = code[i];
|
orig[i] = code[i];
|
||||||
|
|
@ -85,17 +85,17 @@ int main()
|
||||||
for (int i = 0; i < CODE_LEN; ++i)
|
for (int i = 0; i < CODE_LEN; ++i)
|
||||||
noisy[i] = code[i];
|
noisy[i] = code[i];
|
||||||
|
|
||||||
int dec = decode(code) >> (CODE_LEN - DATA_LEN);
|
int dec = decode(code);
|
||||||
|
|
||||||
for (int i = 0; i < CODE_LEN; ++i)
|
for (int i = 0; i < CODE_LEN; ++i)
|
||||||
awgn_errors += noisy[i] * orig[i] < 0;
|
awgn_errors += noisy[i] * orig[i] < 0;
|
||||||
for (int i = 0; i < CODE_LEN; ++i)
|
for (int i = 0; i < CODE_LEN; ++i)
|
||||||
quantization_erasures += !noisy[i];
|
quantization_erasures += !noisy[i];
|
||||||
uncorrected_errors += popcnt(dat^dec);
|
uncorrected_errors += popcnt(enc^dec);
|
||||||
for (int i = 0; i < DATA_LEN; ++i)
|
for (int i = 0; i < CODE_LEN; ++i)
|
||||||
decoder_errors += ((dec^dat)&(1<<i)) && orig[i] * noisy[i] > 0;
|
decoder_errors += ((enc^dec)&(1<<i)) && orig[i] * noisy[i] > 0;
|
||||||
}
|
}
|
||||||
float bit_error_rate = (float)uncorrected_errors / (float)(DATA_LEN * LOOPS);
|
float bit_error_rate = (float)uncorrected_errors / (float)(CODE_LEN * LOOPS);
|
||||||
if (bit_error_rate < 0.0001)
|
if (bit_error_rate < 0.0001)
|
||||||
min_SNR = std::min(min_SNR, SNR);
|
min_SNR = std::min(min_SNR, SNR);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue