Skip to content

Commit 691e93c

Browse files
author
grigory
committed
Refactor G-Fast-SCAN codec
1 parent ba57eaa commit 691e93c

File tree

6 files changed

+40
-127
lines changed

6 files changed

+40
-127
lines changed

python_polar_coding/polar_codes/fast_scan/node.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,3 @@ class FastSCANNode(RCSCANNode):
1010
NodeTypes.REPETITION,
1111
NodeTypes.SINGLE_PARITY_CHECK,
1212
)
13-
14-
@property
15-
def is_repetition(self):
16-
return self.node_type == NodeTypes.REPETITION
17-
18-
@property
19-
def is_parity(self):
20-
return self.node_type == NodeTypes.SINGLE_PARITY_CHECK
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
from .codec import *
22
from .decoder import *
3-
from .functions import *
43
from .node import *

python_polar_coding/polar_codes/g_fast_scan/codec.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,28 @@ def __init__(
1515
design_snr: float = 0.0,
1616
mask: Union[str, None] = None,
1717
pcc_method: str = RCSCANPolarCodec.BHATTACHARYYA,
18-
AF: int = 1,
18+
AF: int = 0,
1919
I: int = 1,
2020
* args, **kwargs,
2121
):
2222

2323
self.AF = AF
24-
super().__init__(N=N, K=K,
25-
design_snr=design_snr,
26-
mask=mask,
27-
pcc_method=pcc_method,
28-
I=I,)
24+
super().__init__(
25+
N=N,
26+
K=K,
27+
design_snr=design_snr,
28+
mask=mask,
29+
pcc_method=pcc_method,
30+
I=I,
31+
)
2932

3033
def init_decoder(self):
31-
return self.decoder_class(n=self.n,
32-
mask=self.mask,
33-
AF=self.AF,
34-
I=self.I)
34+
return self.decoder_class(
35+
n=self.n,
36+
mask=self.mask,
37+
AF=self.AF,
38+
I=self.I,
39+
)
3540

3641
def to_dict(self):
3742
d = super().to_dict()

python_polar_coding/polar_codes/g_fast_scan/decoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ def __init__(
1818
self.AF = AF
1919
super().__init__(n=n, mask=mask, I=I)
2020

21-
def setup_decoding_tree(self, N_min, **kwargs):
21+
def _setup_decoding_tree(self):
2222
"""Setup decoding tree."""
2323
return self.node_class(mask=self.mask, AF=self.AF)

python_polar_coding/polar_codes/g_fast_scan/functions.py

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,24 @@
1-
from python_polar_coding.polar_codes.fast_scan import (
2-
compute_repetition_beta,
3-
compute_spc_beta,
4-
)
5-
from python_polar_coding.polar_codes.g_fast_ssc import GeneralizedFastSSCNode
6-
from python_polar_coding.polar_codes.rc_scan import (
7-
compute_beta_one_node,
8-
compute_beta_zero_node,
9-
)
10-
11-
from .functions import compute_g_repetition, compute_rg_parity
12-
13-
14-
class GFastSCANNode(GeneralizedFastSSCNode):
15-
16-
def compute_leaf_beta(self):
17-
"""Do nothing for ZERO and ONE nodes.
18-
19-
Unlike SC-based decoders SCAN decoders does not make decisions
20-
in ZERO and ONE leaves.
21-
22-
"""
23-
if self.is_repetition:
24-
self.beta = compute_repetition_beta(self.alpha)
25-
if self.is_parity:
26-
self.beta = compute_spc_beta(self.alpha)
27-
if self.is_g_repetition:
28-
self.beta = compute_g_repetition(
29-
llr=self.alpha,
30-
mask_steps=self.mask_steps,
31-
last_chunk_type=self.last_chunk_type,
32-
N=self.N,
33-
)
34-
if self.is_rg_parity:
35-
self.beta = compute_rg_parity(
36-
llr=self.alpha,
37-
mask_steps=self.mask_steps,
38-
N=self.N,
39-
)
40-
41-
def initialize_leaf_beta(self):
42-
"""Initialize BETA values on tree building.
43-
44-
Initialize ZERO and ONE nodes following to Section III
45-
doi:10.1109/jsac.2014.140515
46-
47-
"""
48-
if not self.is_leaf:
49-
return
50-
51-
if self.is_zero:
52-
self._beta = compute_beta_zero_node(self.alpha)
53-
if self.is_one:
54-
self._beta = compute_beta_one_node(self.alpha)
1+
from typing import Dict
2+
3+
from python_polar_coding.polar_codes.fast_scan import FastSCANNode
4+
5+
from ..base import NodeTypes
6+
7+
8+
class GFastSCANNode(FastSCANNode):
9+
supported_nodes = (
10+
NodeTypes.ZERO,
11+
NodeTypes.ONE,
12+
NodeTypes.REPETITION,
13+
NodeTypes.SINGLE_PARITY_CHECK,
14+
NodeTypes.G_REPETITION,
15+
NodeTypes.RG_PARITY,
16+
)
17+
18+
def get_decoding_params(self) -> Dict:
19+
return dict(
20+
node_type=self.node_type,
21+
llr=self.alpha,
22+
mask_steps=self.mask_steps,
23+
last_chunk_type=self.last_chunk_type,
24+
)

0 commit comments

Comments
 (0)