diff options
author | Johannes Demel <ufcsy@student.kit.edu> | 2015-12-01 10:20:38 +0100 |
---|---|---|
committer | Johannes Demel <ufcsy@student.kit.edu> | 2015-12-01 10:20:38 +0100 |
commit | 3fb49b6d3887b2b7fbeb1bbda674b509f0b37d56 (patch) | |
tree | 08e1ecf8c6a22b0ff646ce5ef8ca7371731dd329 /gr-fec | |
parent | 97a87e0d6e863ff1e76ae37b2e1541f7c0ab1e7e (diff) |
polar: fixed channel construction naming error
Diffstat (limited to 'gr-fec')
-rw-r--r-- | gr-fec/grc/variable_polar_code_configurator.xml | 4 | ||||
-rw-r--r-- | gr-fec/python/fec/polar/CMakeLists.txt | 2 | ||||
-rw-r--r-- | gr-fec/python/fec/polar/__init__.py | 8 | ||||
-rw-r--r-- | gr-fec/python/fec/polar/channel_construction.py | 2 | ||||
-rwxr-xr-x | gr-fec/python/fec/polar/channel_construction_awgn.py (renamed from gr-fec/python/fec/polar/channel_construction_bsc.py) | 20 | ||||
-rw-r--r-- | gr-fec/python/fec/polar/decoder.py | 8 | ||||
-rw-r--r-- | gr-fec/python/fec/polar/helper_functions.py | 18 | ||||
-rw-r--r-- | gr-fec/python/fec/polar/polar_channel_construction | 2 |
8 files changed, 32 insertions, 32 deletions
diff --git a/gr-fec/grc/variable_polar_code_configurator.xml b/gr-fec/grc/variable_polar_code_configurator.xml index dd28e494c2..24004b8a03 100644 --- a/gr-fec/grc/variable_polar_code_configurator.xml +++ b/gr-fec/grc/variable_polar_code_configurator.xml @@ -17,8 +17,8 @@ <key>polar.CHANNEL_TYPE_BEC</key> </option> <option> - <name>BSC</name> - <key>polar.CHANNEL_TYPE_BSC</key> + <name>AWGN</name> + <key>polar.CHANNEL_TYPE_AWGN</key> </option> </param> diff --git a/gr-fec/python/fec/polar/CMakeLists.txt b/gr-fec/python/fec/polar/CMakeLists.txt index 1362ce18bb..a863995aff 100644 --- a/gr-fec/python/fec/polar/CMakeLists.txt +++ b/gr-fec/python/fec/polar/CMakeLists.txt @@ -24,7 +24,7 @@ GR_PYTHON_INSTALL( FILES __init__.py channel_construction.py - channel_construction_bsc.py + channel_construction_awgn.py channel_construction_bec.py helper_functions.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/fec/polar diff --git a/gr-fec/python/fec/polar/__init__.py b/gr-fec/python/fec/polar/__init__.py index 0b9c264a77..ce1b1459fb 100644 --- a/gr-fec/python/fec/polar/__init__.py +++ b/gr-fec/python/fec/polar/__init__.py @@ -26,20 +26,20 @@ from channel_construction_bec import bhattacharyya_bounds from helper_functions import is_power_of_two -CHANNEL_TYPE_BSC = 'BSC' +CHANNEL_TYPE_AWGN = 'AWGN' CHANNEL_TYPE_BEC = 'BEC' def get_z_params(is_prototype, channel, block_size, design_snr, mu): print('POLAR code channel construction called with parameters channel={0}, blocksize={1}, design SNR={2}, mu={3}'.format(channel, block_size, design_snr, mu)) - if not (channel == 'BSC' or channel == 'BEC'): - raise ValueError("channel is {0}, but only BEC and BSC are supported!".format(channel)) + if not (channel == 'AWGN' or channel == 'BEC'): + raise ValueError("channel is {0}, but only BEC and AWGN are supported!".format(channel)) if not is_power_of_two(block_size): raise ValueError("block size={0} is not a power of 2!".format(block_size)) if design_snr < -1.5917: raise ValueError("design SNR={0} < -1.5917. MUST be greater!".format(design_snr)) if not mu > 0: raise ValueError("mu={0} < 1. MUST be > 1!".format(mu)) - if not is_prototype and channel == 'BSC': + if not is_prototype and channel == 'AWGN': z_params = cc.load_z_parameters(block_size, design_snr, mu) print('Read Z-parameter file: {0}'.format(cc.default_dir() + cc.generate_filename(block_size, design_snr, mu))) return z_params diff --git a/gr-fec/python/fec/polar/channel_construction.py b/gr-fec/python/fec/polar/channel_construction.py index 7babb67854..a981007b45 100644 --- a/gr-fec/python/fec/polar/channel_construction.py +++ b/gr-fec/python/fec/polar/channel_construction.py @@ -27,7 +27,7 @@ foundational paper for polar codes. from channel_construction_bec import calculate_bec_channel_capacities from channel_construction_bec import design_snr_to_bec_eta from channel_construction_bec import bhattacharyya_bounds -from channel_construction_bsc import tal_vardy_tpm_algorithm +from channel_construction_awgn import tal_vardy_tpm_algorithm from helper_functions import * diff --git a/gr-fec/python/fec/polar/channel_construction_bsc.py b/gr-fec/python/fec/polar/channel_construction_awgn.py index 7be337960b..7d820b2883 100755 --- a/gr-fec/python/fec/polar/channel_construction_bsc.py +++ b/gr-fec/python/fec/polar/channel_construction_awgn.py @@ -34,24 +34,6 @@ from helper_functions import * from channel_construction_bec import bhattacharyya_bounds -def bsc_channel(p): - ''' - binary symmetric channel (BSC) - output alphabet Y = {0, 1} and - W(0|0) = W(1|1) and W(1|0) = W(0|1) - - this function returns a prob's vector for a BSC - p denotes an erroneous transistion - ''' - if not (p >= 0.0 and p <= 1.0): - print "given p is out of range!" - return np.array([], dtype=float) - - # 0 -> 0, 0 -> 1, 1 -> 0, 1 -> 1 - W = np.array([[1 - p, p], [p, 1 - p]], dtype=float) - return W - - def solver_equation(val, s): cw_lambda = codeword_lambda_callable(s) ic_lambda = instantanious_capacity_callable() @@ -267,7 +249,7 @@ def normalize_q(q, tpm): def main(): - print 'channel construction BSC main' + print 'channel construction AWGN main' n = 8 m = 2 ** n design_snr = 0.0 diff --git a/gr-fec/python/fec/polar/decoder.py b/gr-fec/python/fec/polar/decoder.py index 10eef9b6ed..ae62943275 100644 --- a/gr-fec/python/fec/polar/decoder.py +++ b/gr-fec/python/fec/polar/decoder.py @@ -31,11 +31,11 @@ class PolarDecoder(PolarCommon): PolarCommon.__init__(self, n, k, frozen_bit_position, frozenbits) self.error_probability = 0.1 # this is kind of a dummy value. usually chosen individually. - self.bsc_lr = ((1 - self.error_probability) / self.error_probability, self.error_probability / (1 - self.error_probability)) - self.bsc_llrs = np.log(self.bsc_lr) + self.lrs = ((1 - self.error_probability) / self.error_probability, self.error_probability / (1 - self.error_probability)) + self.llrs = np.log(self.lrs) def _llr_bit(self, bit): - return self.bsc_llrs[bit] + return self.llrs[bit] def _llr_odd(self, la, lb): # this functions uses the min-sum approximation @@ -63,7 +63,7 @@ class PolarDecoder(PolarCommon): return ui def _lr_bit(self, bit): - return self.bsc_lr[bit] + return self.lrs[bit] def _lr_odd(self, la, lb): # la is upper branch and lb is lower branch diff --git a/gr-fec/python/fec/polar/helper_functions.py b/gr-fec/python/fec/polar/helper_functions.py index 4ec02399cc..85140c856f 100644 --- a/gr-fec/python/fec/polar/helper_functions.py +++ b/gr-fec/python/fec/polar/helper_functions.py @@ -23,6 +23,24 @@ import time, sys import copy +def bsc_channel(p): + ''' + binary symmetric channel (BSC) + output alphabet Y = {0, 1} and + W(0|0) = W(1|1) and W(1|0) = W(0|1) + + this function returns a prob's vector for a BSC + p denotes an erroneous transistion + ''' + if not (p >= 0.0 and p <= 1.0): + print "given p is out of range!" + return np.array([], dtype=float) + + # 0 -> 0, 0 -> 1, 1 -> 0, 1 -> 1 + W = np.array([[1 - p, p], [p, 1 - p]], dtype=float) + return W + + def power_of_2_int(num): return int(np.log2(num)) diff --git a/gr-fec/python/fec/polar/polar_channel_construction b/gr-fec/python/fec/polar/polar_channel_construction index 0aca9c7ddc..448253659e 100644 --- a/gr-fec/python/fec/polar/polar_channel_construction +++ b/gr-fec/python/fec/polar/polar_channel_construction @@ -34,7 +34,7 @@ def setup_parser(): parser.add_option("-h", "--help", action="help", help="Displays this help message.") parser.add_option("-c", "--channel", action="store", type="string", dest="channel", - help="specify channel, currently BEC or BSC (default='BEC')", default='BEC') + help="specify channel, currently BEC or AWGN (default='BEC')", default='BEC') parser.add_option("-b", "--blocksize", action="store", type="int", dest="block_size", help="specify block size of polar code (default=16)", default=16) parser.add_option("-s", "--desgin-snr", action="store", type="float", dest="design_snr", |