Skip to content

Commit

Permalink
Adjust path for shared library
Browse files Browse the repository at this point in the history
  • Loading branch information
heat1q committed Nov 8, 2020
1 parent df11021 commit 5a6385d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pyLDPC/ldpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import threading
import numpy as np

LIB_PATH = f"{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}/libldpc.so"
LIB_PATH = f"{os.path.dirname(os.path.abspath(__file__))}/libldpc.so"

class sim_results_t(ct.Structure):
_fields_ = [("fer", ct.POINTER(ct.c_double)),
Expand All @@ -20,7 +20,7 @@ class decoder_param(ct.Structure):


class LDPC:
def __init__(self, pc_file: str, gen_file = "", lib_path = LIB_PATH):
def __init__(self, pc_file: str, gen_file = "", lib = LIB_PATH):
self.pc_file = pc_file
self.gen_file = gen_file
self.n = ct.c_int(0)
Expand All @@ -29,7 +29,7 @@ def __init__(self, pc_file: str, gen_file = "", lib_path = LIB_PATH):
self.sim_stop_flag = ct.c_ubyte(1)
self.results = {}

self.lib = ct.cdll.LoadLibrary(lib_path)
self.lib = ct.cdll.LoadLibrary(lib)
self.lib.argtypes = (ct.c_char_p, ct.c_char_p, ct.c_int, ct.c_int)
self.lib.ldpc_setup(pc_file.encode("utf-8"), gen_file.encode("utf-8"), ct.byref(self.n), ct.byref(self.m))

Expand All @@ -39,6 +39,17 @@ def __init__(self, pc_file: str, gen_file = "", lib_path = LIB_PATH):


def encode(self, info_word: np.array) -> np.array:
"""Encode a binary array.
Args:
info_word (np.array): Input binary array.
Raises:
RuntimeError: No generator matrix is initially provided.
Returns:
np.array: Encoded binary codeword.
"""
if not self.gen_file:
raise RuntimeError("No generator matrix provided for encoding")

Expand Down

0 comments on commit 5a6385d

Please sign in to comment.