-
Notifications
You must be signed in to change notification settings - Fork 37
Description
This package only supports cyclic Reed-Solomon codes. For a Reed-Solomon code RS(n, k, field, alpha), the RS code can only be created if n is a divisor of field.order. If alpha is given, it must be an nth root of unity. This was the original implementation of RS encoding, but it is no longer necessary.
Many common RS codes are not cyclic. In particular, the RS code used by QR Codes uses field=GF(2**8), alpha=2 (a primitive root of multiplicative order 255) and many different combinations of n and k. For example to encode https://github.com/mhostetter/galois.git"it used RS(70, 44). Since 70 isn't a divisor of 255, galois.ReedSolomon will give an error.
In terms of implementation, it would be fairly straightforward to allow non-cyclic implementations. The main changes are:
- In
_cyclic.pyremove theassert remainder_poly == 0. If this polynomial is 0, then the RS is cyclic, otherwise it isn't. - If the RS isn't cyclic, there really isn't a parity check polynomial. Should it just be set to
None? - The current constructor for the
Gfield only works for cyclic RS. The construction needs to be changed to work for both cyclic and non-cyclic RS. It is straightforward. - Do we want a new property
is_cyclicindicating whether the RS is cyclic?
At present, ReedSolomon is a direct superclass of _CyclicCode. Not sure whether to leave this as the direct superclass or not. Most of what's in there is okay.
There is also a question of API visible to the user. There are two possibilities:
- If the user specified an
nthat isn't a divisor offield.order - 1, or if the user specifies a particular alpha that isn't an n'th root, then we suppose the user knows what they want and generate the specified RS code. - Alternatively, require the user to specify
cyclic=Falseto get a non-cyclic group. If they do specifycyclic=False, then alpha, if not specified, will befield.primitive_elementand a possibly non-cyclic RS will be generated.