290 fail(
"LDPC graph not initialized");
294 SOFTWORD *expected =
new SOFTWORD[n_k / SWSIZE];
295 encode(table, cw, k,
n, expected,
false);
297 SOFTWORD *received =
new SOFTWORD[n_k / SWSIZE];
298 diff_bits(cw + k / SWSIZE, received, n_k / SWSIZE);
303 lfprintf(stderr,
"Initial score %d\n", (
int)tots);
311 score_threshold = (int)one * 2;
314 bool progress =
true;
315 while (progress && nflipped < max_bitflips)
321 for (
int b = 0; b <
n - k - 1; ++b)
327 lfprintf(stderr,
"flip parity %d\n", b);
336 for (
int e =
cnodes[b].nedges; e--; ++pe)
338 int d = prev_err * softwords_weight<SOFTBIT, SOFTWORD>(cw, *pe) *
PPCM /
vnodes[*pe].nedges;
345 for (
int e =
cnodes[b + 1].nedges; e--; ++pe)
347 int d = err * softwords_weight<SOFTBIT, SOFTWORD>(cw, *pe) *
PPCM /
vnodes[*pe].nedges;
363 for (
int v = 0; v <
k; ++v)
368 lfprintf(stderr,
"maxs %d\n", (
int)maxs);
370 for (
int v = 0; v <
k; ++v)
372 if (score[v] < score_threshold)
375 if (score[v] < maxs - 4)
377 lfprintf(stderr,
" flip %d score=%d\n", (
int)v, (
int)score[v]);
380 for (
int commit = 0; commit <= 1; ++commit)
383 for (
int e =
vnodes[v].nedges; e--; ++pe)
390 for (
int e =
cnodes[c].nedges; e--; ++pe)
392 int d = was_bad * softwords_weight<SOFTBIT, SOFTWORD>(cw, *pe) *
PPCM /
vnodes[*pe].nedges;
404 for (
int e =
cnodes[c].nedges; e--; ++pe)
406 int d = is_bad * softwords_weight<SOFTBIT, SOFTWORD>(cw, *pe) *
PPCM /
vnodes[*pe].nedges;
434 lfprintf(stderr,
"progress %d\n", progress);
436 fprintf(stderr,
"CHECKING TOTS INCREMENT (slow) %d\n", tots);
438 if ( tots2 != tots )
fail(
"bad tots update");
bool softwords_xor(const hard_sb p1[], const hard_sb p2[], int b)
score_t compute_scores(SOFTWORD *m, SOFTWORD *p, SOFTWORD *q, int nc, score_t *score, int k)
bool softbit_harden(bool b)
void softwords_flip(hard_sb p[], int b)
void encode(const ldpc_table< Taddr > *table, const SOFTWORD *msg, int k, int n, SOFTWORD *parity, int integrate=true)
static void diff_bits(const SOFTWORD *in, SOFTWORD *out, int nwords)
void softbit_set(bool *p, bool v)