Skip to content

Commit

Permalink
restructured to make constant values more obvious to see
Browse files Browse the repository at this point in the history
  • Loading branch information
xdsopl committed Dec 8, 2018
1 parent b24c195 commit 33c9735
Showing 1 changed file with 44 additions and 42 deletions.
86 changes: 44 additions & 42 deletions layered_decoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@ class LDPCDecoder
{
{
int cnt = cnc[0];
TYPE cnv = alg.sign(alg.one(), parity[0]);
for (int c = 0; c < cnt; ++c)
cnv = alg.sign(cnv, data[pos[c]]);
if (alg.bad(cnv, blocks))
return true;
}
for (int j = 1; j < M; ++j) {
int cnt = cnc[0];
TYPE cnv = alg.sign(alg.sign(alg.one(), parity[j+(q-1)*M-1]), parity[j]);
for (int c = 0; c < cnt; ++c)
cnv = alg.sign(cnv, data[pos[CNL*j+c]]);
if (alg.bad(cnv, blocks))
return true;
{
TYPE cnv = alg.sign(alg.one(), parity[0]);
for (int c = 0; c < cnt; ++c)
cnv = alg.sign(cnv, data[pos[c]]);
if (alg.bad(cnv, blocks))
return true;
}
for (int j = 1; j < M; ++j) {
TYPE cnv = alg.sign(alg.sign(alg.one(), parity[j+(q-1)*M-1]), parity[j]);
for (int c = 0; c < cnt; ++c)
cnv = alg.sign(cnv, data[pos[CNL*j+c]]);
if (alg.bad(cnv, blocks))
return true;
}
}
for (int i = 1; i < q; ++i) {
int cnt = cnc[i];
for (int j = 0; j < M; ++j) {
int cnt = cnc[i];
TYPE cnv = alg.sign(alg.sign(alg.one(), parity[M*(i-1)+j]), parity[M*i+j]);
for (int c = 0; c < cnt; ++c)
cnv = alg.sign(cnv, data[pos[CNL*(M*i+j)+c]]);
Expand All @@ -60,38 +61,39 @@ class LDPCDecoder
TYPE *bl = bnl;
{
int cnt = cnc[0];
int deg = cnt + 1;
TYPE inp[deg], out[deg];
for (int c = 0; c < cnt; ++c)
inp[c] = out[c] = alg.sub(data[pos[c]], bl[c]);
inp[cnt] = out[cnt] = alg.sub(parity[0], bl[cnt]);
alg.finalp(out, deg);
for (int c = 0; c < cnt; ++c)
data[pos[c]] = alg.add(inp[c], out[c]);
parity[0] = alg.add(inp[cnt], out[cnt]);
for (int d = 0; d < deg; ++d)
alg.update(bl++, out[d]);
}
for (int j = 1; j < M; ++j) {
int cnt = cnc[0];
{
int deg = cnt + 1;
TYPE inp[deg], out[deg];
for (int c = 0; c < cnt; ++c)
inp[c] = out[c] = alg.sub(data[pos[c]], bl[c]);
inp[cnt] = out[cnt] = alg.sub(parity[0], bl[cnt]);
alg.finalp(out, deg);
for (int c = 0; c < cnt; ++c)
data[pos[c]] = alg.add(inp[c], out[c]);
parity[0] = alg.add(inp[cnt], out[cnt]);
for (int d = 0; d < deg; ++d)
alg.update(bl++, out[d]);
}
int deg = cnt + 2;
TYPE inp[deg], out[deg];
for (int c = 0; c < cnt; ++c)
inp[c] = out[c] = alg.sub(data[pos[CNL*j+c]], bl[c]);
inp[cnt] = out[cnt] = alg.sub(parity[j+(q-1)*M-1], bl[cnt]);
inp[cnt+1] = out[cnt+1] = alg.sub(parity[j], bl[cnt+1]);
alg.finalp(out, deg);
for (int c = 0; c < cnt; ++c)
data[pos[CNL*j+c]] = alg.add(inp[c], out[c]);
parity[j+(q-1)*M-1] = alg.add(inp[cnt], out[cnt]);
parity[j] = alg.add(inp[cnt+1], out[cnt+1]);
for (int d = 0; d < deg; ++d)
alg.update(bl++, out[d]);
for (int j = 1; j < M; ++j) {
TYPE inp[deg], out[deg];
for (int c = 0; c < cnt; ++c)
inp[c] = out[c] = alg.sub(data[pos[CNL*j+c]], bl[c]);
inp[cnt] = out[cnt] = alg.sub(parity[j+(q-1)*M-1], bl[cnt]);
inp[cnt+1] = out[cnt+1] = alg.sub(parity[j], bl[cnt+1]);
alg.finalp(out, deg);
for (int c = 0; c < cnt; ++c)
data[pos[CNL*j+c]] = alg.add(inp[c], out[c]);
parity[j+(q-1)*M-1] = alg.add(inp[cnt], out[cnt]);
parity[j] = alg.add(inp[cnt+1], out[cnt+1]);
for (int d = 0; d < deg; ++d)
alg.update(bl++, out[d]);
}
}
for (int i = 1; i < q; ++i) {
int cnt = cnc[i];
int deg = cnt + 2;
for (int j = 0; j < M; ++j) {
int cnt = cnc[i];
int deg = cnt + 2;
TYPE inp[deg], out[deg];
for (int c = 0; c < cnt; ++c)
inp[c] = out[c] = alg.sub(data[pos[CNL*(M*i+j)+c]], bl[c]);
Expand Down

0 comments on commit 33c9735

Please sign in to comment.