diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-03-02 19:42:36 +0100 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-03-02 19:42:36 +0100 |
commit | ca01d52a8658ed01301f14a4d294097d4db533cf (patch) | |
tree | 28b32499b6a849beda66c6ebc70239fbd9f21530 /controller/fw/ldpc_decoder_test.py | |
parent | 5effadcbaf66f476c8fffefa2c349676f41c3f52 (diff) | |
download | master-thesis-ca01d52a8658ed01301f14a4d294097d4db533cf.tar.gz master-thesis-ca01d52a8658ed01301f14a4d294097d4db533cf.tar.bz2 master-thesis-ca01d52a8658ed01301f14a4d294097d4db533cf.zip |
Finishing up freq meas
Diffstat (limited to 'controller/fw/ldpc_decoder_test.py')
-rw-r--r-- | controller/fw/ldpc_decoder_test.py | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/controller/fw/ldpc_decoder_test.py b/controller/fw/ldpc_decoder_test.py deleted file mode 100644 index 3b91bba..0000000 --- a/controller/fw/ldpc_decoder_test.py +++ /dev/null @@ -1,72 +0,0 @@ - -import pyldpc -import scipy.sparse -import numpy as np -import test_decoder -import os, sys -import ctypes as C -import argparse - -if __name__ != '__main__': - raise RuntimeError("Please don't import this module, this is a command-line program.") - -parser = argparse.ArgumentParser() -parser.add_argument('-r', '--reference', action='store_true', default=False, help='Run reference decoder instead of C implemention') -args = parser.parse_args() - -lib = C.CDLL('./ldpc_decoder_test.so') - -n = 5*19 -nodes, bits = 17, 19 -H, G = pyldpc.make_ldpc(n, nodes, bits, systematic=False, seed=0) -_1, bits_pos, _2 = scipy.sparse.find(H) -_, k = G.shape - -st = np.random.RandomState(seed=0) -test_data = st.randint(0, 2, k) -d = np.dot(G, test_data) % 2 -x = (-1) ** d -x[29:] = 0 - -bits_pos = bits_pos.astype(np.uint32) -x = x.astype(np.int8) - -lib.decode.argtypes = [C.c_size_t, C.c_size_t, C.c_size_t, C.POINTER(C.c_size_t), C.POINTER(C.c_int8), C.POINTER(C.c_int8), C.c_uint] -lib.get_message.argtypes = [C.c_size_t, C.c_size_t, C.POINTER(C.c_int8), C.POINTER(C.c_int8), C.POINTER(C.c_int8)] - -if args.reference: - ref_out = test_decoder.decode(H, x, 3) - print('decoder output:', ref_out, flush=True) - print('msg reconstruction:', test_decoder.get_message(G, ref_out)) - print('reference decoder: ', np.all(np.equal(test_decoder.get_message(G, ref_out), test_data)), flush=True) - np.set_printoptions(linewidth=220) - print(test_data) - print(test_decoder.get_message(G, ref_out)) - print(test_decoder.get_message(G, ref_out) ^ test_data) - -else: - out = np.zeros(n, dtype=np.uint8) - # print('python data:', x, flush=True) - print('decoder iterations:', lib.decode(n, nodes, bits, - bits_pos.ctypes.data_as(C.POINTER(C.c_ulong)), - x.ctypes.data_as(C.POINTER(C.c_int8)), - out.ctypes.data_as(C.POINTER(C.c_int8)), - 25), flush=True) - print('decoder output:', out) - print('msg reconstruction:', test_decoder.get_message(G, out.astype(np.int64))) - print('decoder under test:', np.all(np.equal(test_decoder.get_message(G, out.astype(np.int64)), test_data))) - np.set_printoptions(linewidth=220) - print(test_data) - print(test_decoder.get_message(G, out.astype(np.int64))) - G = G.astype(np.int8) - msg = np.zeros(k, dtype=np.int8) - lib.get_message( - n, k, - G.ctypes.data_as(C.POINTER(C.c_int8)), - out.astype(np.int8).ctypes.data_as(C.POINTER(C.c_int8)), - msg.ctypes.data_as(C.POINTER(C.c_int8))) - print(msg) - print(msg ^ test_data) - -print('codeword length:', len(x)) -print('data length:', len(test_data)) |