This class contains utility methods for performing mathematical operations over the Galois Fields. Operations use a given primitive polynomial in calculations.

Throughout this package, elements of the GF are represented as an {@code int} for convenience and speed (but at the cost of memory).

Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GenericGFPoly"/> class.
 /// </summary>
 /// <param name="field">the {@link GenericGF} instance representing the field to use
 /// to perform computations</param>
 /// <param name="coefficients">coefficients as ints representing elements of GF(size), arranged
 /// from most significant (highest-power term) coefficient to least significant</param>
 /// <exception cref="ArgumentException">if argument is null or empty,
 /// or if leading coefficient is 0 and this is not a
 /// constant polynomial (that is, it is not the monomial "0")</exception>
 internal GenericGFPoly(GenericGF field, int[] coefficients)
 {
    if (coefficients.Length == 0)
    {
       throw new ArgumentException();
    }
    this.field = field;
    int coefficientsLength = coefficients.Length;
    if (coefficientsLength > 1 && coefficients[0] == 0)
    {
       // Leading term must be non-zero for anything except the constant polynomial "0"
       int firstNonZero = 1;
       while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0)
       {
          firstNonZero++;
       }
       if (firstNonZero == coefficientsLength)
       {
          this.coefficients = field.Zero.coefficients;
       }
       else
       {
          this.coefficients = new int[coefficientsLength - firstNonZero];
          Array.Copy(coefficients,
              firstNonZero,
              this.coefficients,
              0,
              this.coefficients.Length);
       }
    }
    else
    {
       this.coefficients = coefficients;
    }
 }
Пример #2
0
 public ReedSolomon(GenericGF galoisField, int correctionBytes)
 {
     _messageLength      = galoisField.Size - 1;
     _correctionLength   = correctionBytes;
     _informationLength  = _messageLength - _correctionLength;
     _reedSolomonEncoder = new ReedSolomonEncoder(galoisField);
     _reedSolomonDecoder = new ReedSolomonDecoder(galoisField);
     _simpleRsDecoder    = new SimpleRSDecoder();
 }
 public ReedSolomon(GenericGF galoisField, int correctionBytes)
 {
     _messageLength = galoisField.Size - 1;
     _correctionLength = correctionBytes;
     _informationLength = _messageLength - _correctionLength;
     _reedSolomonEncoder = new ReedSolomonEncoder(galoisField);
     _reedSolomonDecoder = new ReedSolomonDecoder(galoisField);
     _simpleRsDecoder = new SimpleRSDecoder();
 }
Пример #4
0
 public ReedSolomonEncoder(GenericGF field)
 {
     if (!GenericGF.QR_CODE_FIELD_256.Equals(field))
      {
     throw new System.ArgumentException("Only QR Code is supported at this time");
      }
      this.field = field;
      this.cachedGenerators = new ArrayList();
      cachedGenerators.Add(new GenericGFPoly(field, new int[] { 1 }));
 }
Пример #5
0
 public ReedSolomonEncoder(GenericGF field)
 {
    this.field = field;
    this.cachedGenerators = new List<GenericGFPoly>();
    cachedGenerators.Add(new GenericGFPoly(field, new int[] { 1 }));
 }
Пример #6
0
 public ReedSolomonEncoder(GenericGF field)
 {
     this.field            = field;
     this.cachedGenerators = new List <GenericGFPoly>();
     cachedGenerators.Add(new GenericGFPoly(field, new int[] { 1 }));
 }