From ea5c4e76730daee3da34b5ee4bd4cba28d79522d Mon Sep 17 00:00:00 2001 From: mhostetter Date: Mon, 8 May 2023 11:15:14 -0400 Subject: [PATCH] Store BCH and RS decoders in different namespaces --- src/galois/_codes/_bch.py | 4 ++-- src/galois/_codes/_reed_solomon.py | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/galois/_codes/_bch.py b/src/galois/_codes/_bch.py index 500722ca1..2675eda4a 100644 --- a/src/galois/_codes/_bch.py +++ b/src/galois/_codes/_bch.py @@ -661,7 +661,7 @@ def decode(self, codeword, output="message", errors=False): return super().decode(codeword, output=output, errors=errors) def _decode_codeword(self, codeword: FieldArray) -> tuple[FieldArray, np.ndarray]: - func = decode_jit(self.field, self.extension_field) + func = bch_decode_jit(self.field, self.extension_field) dec_codeword, N_errors = func(codeword, self.n, int(self.alpha), self.c, self.roots) dec_codeword = dec_codeword.view(self.field) return dec_codeword, N_errors @@ -1192,7 +1192,7 @@ def _generator_poly_from_k( return best_generator_poly, best_roots -class decode_jit(Function): +class bch_decode_jit(Function): """ Performs general BCH and Reed-Solomon decoding. diff --git a/src/galois/_codes/_reed_solomon.py b/src/galois/_codes/_reed_solomon.py index b54d43d32..fbc2210d2 100644 --- a/src/galois/_codes/_reed_solomon.py +++ b/src/galois/_codes/_reed_solomon.py @@ -13,7 +13,7 @@ from .._math import ilog from .._polys import Poly, matlab_primitive_poly from ..typing import ArrayLike, ElementLike -from ._bch import decode_jit +from ._bch import bch_decode_jit from ._cyclic import _CyclicCode @@ -613,7 +613,7 @@ def decode(self, codeword, output="message", errors=False): return super().decode(codeword, output=output, errors=errors) def _decode_codeword(self, codeword: FieldArray) -> tuple[FieldArray, np.ndarray]: - func = decode_jit(self.field, self.field) + func = reed_solomon_decode_jit(self.field, self.field) dec_codeword, N_errors = func(codeword, self.n, int(self.alpha), self.c, self.roots) dec_codeword = dec_codeword.view(self.field) return dec_codeword, N_errors @@ -1033,3 +1033,14 @@ def is_narrow_sense(self) -> bool: @property def is_systematic(self) -> bool: return super().is_systematic + + +class reed_solomon_decode_jit(bch_decode_jit): + """ + Performs general BCH and Reed-Solomon decoding. + + References: + - Lin, S. and Costello, D. Error Control Coding. Section 7.4. + """ + + # NOTE: Making a subclass so that these compiled functions are stored in a new namespace