|
| 1 | +from python_polar_coding.polar_codes.rc_scan import ( |
| 2 | + RCSCANNode, |
| 3 | + compute_beta_one_node, |
| 4 | + compute_beta_zero_node, |
| 5 | +) |
| 6 | + |
| 7 | +from .functions import compute_repetition_beta, compute_spc_beta |
| 8 | + |
| 9 | + |
| 10 | +class FastSCANNode(RCSCANNode): |
| 11 | + |
| 12 | + def compute_leaf_beta(self): |
| 13 | + """Compute leaf beta.""" |
| 14 | + if self.is_repetition: |
| 15 | + self.beta = compute_repetition_beta(self.alpha) |
| 16 | + if self.is_parity: |
| 17 | + self.beta = compute_spc_beta(self.alpha) |
| 18 | + |
| 19 | + def initialize_leaf_beta(self): |
| 20 | + """Initialize BETA values on tree building. |
| 21 | +
|
| 22 | + Initialize ZERO and ONE nodes following to Section III |
| 23 | + doi:10.1109/jsac.2014.140515 |
| 24 | +
|
| 25 | + """ |
| 26 | + if not self.is_leaf: |
| 27 | + return |
| 28 | + |
| 29 | + if self.is_parity or self.is_repetition: |
| 30 | + return |
| 31 | + |
| 32 | + if self.is_zero: |
| 33 | + self._beta = compute_beta_zero_node(self.alpha) |
| 34 | + if self.is_one: |
| 35 | + self._beta = compute_beta_one_node(self.alpha) |
| 36 | + |
| 37 | + def get_node_type(self): |
| 38 | + """Get the type of Fast SCAN Node. |
| 39 | +
|
| 40 | + * Zero node - [0, 0, 0, 0, 0, 0, 0, 0]; |
| 41 | + * One node - [1, 1, 1, 1, 1, 1, 1, 1]; |
| 42 | + * Single parity check node - [0, 1, 1, 1, 1, 1, 1, 1]; |
| 43 | + * Repetition node - [0, 0, 0, 0, 0, 0, 0, 1]. |
| 44 | +
|
| 45 | + Or other type. |
| 46 | +
|
| 47 | + """ |
| 48 | + if self._check_is_zero(self._mask): |
| 49 | + return self.ZERO_NODE |
| 50 | + if self._check_is_one(self._mask): |
| 51 | + return self.ONE_NODE |
| 52 | + if self._check_is_rep(self._mask): |
| 53 | + return self.REPETITION |
| 54 | + if self._check_is_spc(self._mask): |
| 55 | + return self.SINGLE_PARITY_CHECK |
| 56 | + return self.OTHER |
0 commit comments