Skip to content

Galois does not support non-cyclic Reed-Solomon codes #605

@fyellin

Description

@fyellin

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:

  1. In _cyclic.py remove the assert remainder_poly == 0. If this polynomial is 0, then the RS is cyclic, otherwise it isn't.
  2. If the RS isn't cyclic, there really isn't a parity check polynomial. Should it just be set to None?
  3. The current constructor for the G field only works for cyclic RS. The construction needs to be changed to work for both cyclic and non-cyclic RS. It is straightforward.
  4. Do we want a new property is_cyclic indicating 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:

  1. If the user specified an n that isn't a divisor of field.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.
  2. Alternatively, require the user to specify cyclic=False to get a non-cyclic group. If they do specify cyclic=False, then alpha, if not specified, will be field.primitive_element and a possibly non-cyclic RS will be generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fecForward error correction

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions