summaryrefslogtreecommitdiff
path: root/gr-fec/python/fec/polar/helper_functions.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-fec/python/fec/polar/helper_functions.py')
-rw-r--r--gr-fec/python/fec/polar/helper_functions.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/gr-fec/python/fec/polar/helper_functions.py b/gr-fec/python/fec/polar/helper_functions.py
index 1d82457f17..ffa4fc17dc 100644
--- a/gr-fec/python/fec/polar/helper_functions.py
+++ b/gr-fec/python/fec/polar/helper_functions.py
@@ -70,6 +70,29 @@ def pack_byte(bits):
return res
+def get_frozen_bit_positions(directory, n, k, p):
+ import glob, os
+ os.chdir(directory)
+ prefix = 'frozen_bit_positions_'
+ prefix_len = len(prefix)
+ for file in glob.glob("*.npy"):
+ if file.find(prefix) < 0:
+ continue
+ filename = file
+ file = file[file.find(prefix) + prefix_len:]
+ file = file[:-4]
+ file = file.split('_')
+ nstr = [x for x in file if x.startswith('n')]
+ kstr = [x for x in file if x.startswith('k')]
+ pstr = [x for x in file if x.startswith('p')]
+ nstr = int(nstr[0][1:])
+ kstr = int(kstr[0][1:])
+ pstr = float(pstr[0][1:])
+ if n == nstr and k == kstr:
+ return np.load(filename)
+ return np.arange(k)
+
+
def main():
print 'helper functions'
@@ -79,6 +102,11 @@ def main():
k = n // 2
eta = 0.3
+ # frozen_bit_positions = get_frozen_bit_positions('.', 256, 128, 0.11)
+ # print(frozen_bit_positions)
+
+ print(np.arange(16))
+ print bit_reverse_vector(np.arange(16), 4)
if __name__ == '__main__':
main()