Skip to content

Commit

Permalink
Store BCH and RS decoders in different namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed May 8, 2023
1 parent aac6a92 commit ea5c4e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/galois/_codes/_bch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 13 additions & 2 deletions src/galois/_codes/_reed_solomon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit ea5c4e7

Please sign in to comment.