commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/18: polar: fixed channel construction na


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/18: polar: fixed channel construction naming error
Date: Tue, 8 Dec 2015 00:31:21 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 3fb49b6d3887b2b7fbeb1bbda674b509f0b37d56
Author: Johannes Demel <address@hidden>
Date:   Tue Dec 1 10:20:38 2015 +0100

    polar: fixed channel construction naming error
---
 gr-fec/grc/variable_polar_code_configurator.xml      |  4 ++--
 gr-fec/python/fec/polar/CMakeLists.txt               |  2 +-
 gr-fec/python/fec/polar/__init__.py                  |  8 ++++----
 gr-fec/python/fec/polar/channel_construction.py      |  2 +-
 ...struction_bsc.py => channel_construction_awgn.py} | 20 +-------------------
 gr-fec/python/fec/polar/decoder.py                   |  8 ++++----
 gr-fec/python/fec/polar/helper_functions.py          | 18 ++++++++++++++++++
 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 dd28e49..24004b8 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 1362ce1..a863995 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 0b9c264..ce1b145 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 7babb67..a981007 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
similarity index 94%
rename from gr-fec/python/fec/polar/channel_construction_bsc.py
rename to gr-fec/python/fec/polar/channel_construction_awgn.py
index 7be3379..7d820b2 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 10eef9b..ae62943 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 4ec0239..85140c8 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 0aca9c7..4482536 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",



reply via email to

[Prev in Thread] Current Thread [Next in Thread]