mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 14:30:36 +00:00
removed collapsing of rate-0 nodes
This commit is contained in:
parent
77c46caa42
commit
761449d9d9
1 changed files with 15 additions and 72 deletions
|
|
@ -11,30 +11,8 @@ Copyright 2025 Ahmet Inan <inan@aicodix.de>
|
|||
|
||||
namespace CODE {
|
||||
|
||||
template <typename TYPE, int M>
|
||||
struct PACListNode
|
||||
{
|
||||
typedef PolarHelper<TYPE> PH;
|
||||
typedef typename PH::PATH PATH;
|
||||
typedef typename PH::MAP MAP;
|
||||
static const int N = 1 << M;
|
||||
static MAP rate0(PATH *metric, TYPE *hard, TYPE *soft)
|
||||
{
|
||||
for (int i = 0; i < N; ++i)
|
||||
hard[i] = PH::one();
|
||||
for (int i = 0; i < N; ++i)
|
||||
for (int k = 0; k < TYPE::SIZE; ++k)
|
||||
if (soft[i+N].v[k] < 0)
|
||||
metric[k] -= soft[i+N].v[k];
|
||||
MAP map;
|
||||
for (int k = 0; k < TYPE::SIZE; ++k)
|
||||
map.v[k] = k;
|
||||
return map;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
struct PACListNode<TYPE, 0>
|
||||
struct PACListLeaf
|
||||
{
|
||||
typedef PolarHelper<TYPE> PH;
|
||||
typedef typename PH::PATH PATH;
|
||||
|
|
@ -128,17 +106,10 @@ struct PACListTree<TYPE, 6>
|
|||
{
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::prod(soft[i+N], soft[i+N/2+N]);
|
||||
MAP lmap, rmap;
|
||||
if (frozen[0] == 0xffffffff)
|
||||
lmap = PACListNode<TYPE, M-1>::rate0(metric, hard, soft);
|
||||
else
|
||||
lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen[0]);
|
||||
MAP lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen[0]);
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::madd(hard[i], vshuf(soft[i+N], lmap), vshuf(soft[i+N/2+N], lmap));
|
||||
if (frozen[1] == 0xffffffff)
|
||||
rmap = PACListNode<TYPE, M-1>::rate0(metric, hard+N/2, soft);
|
||||
else
|
||||
rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen[1]);
|
||||
MAP rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen[1]);
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
hard[i] = PH::qmul(vshuf(hard[i], rmap), hard[i+N/2]);
|
||||
return vshuf(lmap, rmap);
|
||||
|
|
@ -157,17 +128,10 @@ struct PACListTree<TYPE, 5>
|
|||
{
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::prod(soft[i+N], soft[i+N/2+N]);
|
||||
MAP lmap, rmap;
|
||||
if ((frozen & ((1<<(1<<(M-1)))-1)) == ((1<<(1<<(M-1)))-1))
|
||||
lmap = PACListNode<TYPE, M-1>::rate0(metric, hard, soft);
|
||||
else
|
||||
lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen & ((1<<(1<<(M-1)))-1));
|
||||
MAP lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen & ((1<<(1<<(M-1)))-1));
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::madd(hard[i], vshuf(soft[i+N], lmap), vshuf(soft[i+N/2+N], lmap));
|
||||
if (frozen >> (N/2) == ((1<<(1<<(M-1)))-1))
|
||||
rmap = PACListNode<TYPE, M-1>::rate0(metric, hard+N/2, soft);
|
||||
else
|
||||
rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen >> (N/2));
|
||||
MAP rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen >> (N/2));
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
hard[i] = PH::qmul(vshuf(hard[i], rmap), hard[i+N/2]);
|
||||
return vshuf(lmap, rmap);
|
||||
|
|
@ -186,17 +150,10 @@ struct PACListTree<TYPE, 4>
|
|||
{
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::prod(soft[i+N], soft[i+N/2+N]);
|
||||
MAP lmap, rmap;
|
||||
if ((frozen & ((1<<(1<<(M-1)))-1)) == ((1<<(1<<(M-1)))-1))
|
||||
lmap = PACListNode<TYPE, M-1>::rate0(metric, hard, soft);
|
||||
else
|
||||
lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen & ((1<<(1<<(M-1)))-1));
|
||||
MAP lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen & ((1<<(1<<(M-1)))-1));
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::madd(hard[i], vshuf(soft[i+N], lmap), vshuf(soft[i+N/2+N], lmap));
|
||||
if (frozen >> (N/2) == ((1<<(1<<(M-1)))-1))
|
||||
rmap = PACListNode<TYPE, M-1>::rate0(metric, hard+N/2, soft);
|
||||
else
|
||||
rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen >> (N/2));
|
||||
MAP rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen >> (N/2));
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
hard[i] = PH::qmul(vshuf(hard[i], rmap), hard[i+N/2]);
|
||||
return vshuf(lmap, rmap);
|
||||
|
|
@ -215,17 +172,10 @@ struct PACListTree<TYPE, 3>
|
|||
{
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::prod(soft[i+N], soft[i+N/2+N]);
|
||||
MAP lmap, rmap;
|
||||
if ((frozen & ((1<<(1<<(M-1)))-1)) == ((1<<(1<<(M-1)))-1))
|
||||
lmap = PACListNode<TYPE, M-1>::rate0(metric, hard, soft);
|
||||
else
|
||||
lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen & ((1<<(1<<(M-1)))-1));
|
||||
MAP lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen & ((1<<(1<<(M-1)))-1));
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::madd(hard[i], vshuf(soft[i+N], lmap), vshuf(soft[i+N/2+N], lmap));
|
||||
if (frozen >> (N/2) == ((1<<(1<<(M-1)))-1))
|
||||
rmap = PACListNode<TYPE, M-1>::rate0(metric, hard+N/2, soft);
|
||||
else
|
||||
rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen >> (N/2));
|
||||
MAP rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen >> (N/2));
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
hard[i] = PH::qmul(vshuf(hard[i], rmap), hard[i+N/2]);
|
||||
return vshuf(lmap, rmap);
|
||||
|
|
@ -244,17 +194,10 @@ struct PACListTree<TYPE, 2>
|
|||
{
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::prod(soft[i+N], soft[i+N/2+N]);
|
||||
MAP lmap, rmap;
|
||||
if ((frozen & ((1<<(1<<(M-1)))-1)) == ((1<<(1<<(M-1)))-1))
|
||||
lmap = PACListNode<TYPE, M-1>::rate0(metric, hard, soft);
|
||||
else
|
||||
lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen & ((1<<(1<<(M-1)))-1));
|
||||
MAP lmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard, soft, frozen & ((1<<(1<<(M-1)))-1));
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
soft[i+N/2] = PH::madd(hard[i], vshuf(soft[i+N], lmap), vshuf(soft[i+N/2+N], lmap));
|
||||
if (frozen >> (N/2) == ((1<<(1<<(M-1)))-1))
|
||||
rmap = PACListNode<TYPE, M-1>::rate0(metric, hard+N/2, soft);
|
||||
else
|
||||
rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen >> (N/2));
|
||||
MAP rmap = PACListTree<TYPE, M-1>::decode(metric, message, maps, count, state, hard+N/2, soft, frozen >> (N/2));
|
||||
for (int i = 0; i < N/2; ++i)
|
||||
hard[i] = PH::qmul(vshuf(hard[i], rmap), hard[i+N/2]);
|
||||
return vshuf(lmap, rmap);
|
||||
|
|
@ -272,14 +215,14 @@ struct PACListTree<TYPE, 1>
|
|||
soft[1] = PH::prod(soft[2], soft[3]);
|
||||
MAP lmap, rmap;
|
||||
if (frozen & 1)
|
||||
lmap = PACListNode<TYPE, 0>::rate0(metric, hard, soft);
|
||||
lmap = PACListLeaf<TYPE>::rate0(metric, hard, soft);
|
||||
else
|
||||
lmap = PACListNode<TYPE, 0>::rate1(metric, message, maps, count, state, hard, soft);
|
||||
lmap = PACListLeaf<TYPE>::rate1(metric, message, maps, count, state, hard, soft);
|
||||
soft[1] = PH::madd(hard[0], vshuf(soft[2], lmap), vshuf(soft[3], lmap));
|
||||
if (frozen >> 1)
|
||||
rmap = PACListNode<TYPE, 0>::rate0(metric, hard+1, soft);
|
||||
rmap = PACListLeaf<TYPE>::rate0(metric, hard+1, soft);
|
||||
else
|
||||
rmap = PACListNode<TYPE, 0>::rate1(metric, message, maps, count, state, hard+1, soft);
|
||||
rmap = PACListLeaf<TYPE>::rate1(metric, message, maps, count, state, hard+1, soft);
|
||||
hard[0] = PH::qmul(vshuf(hard[0], rmap), hard[1]);
|
||||
return vshuf(lmap, rmap);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue