/// <param name="field">the {@link GF256} instance representing the field to use /// to perform computations /// </param> /// <param name="coefficients">coefficients as ints representing elements of GF(256), arranged /// from most significant (highest-power term) coefficient to least significant /// </param> /// <throws> IllegalArgumentException if argument is null or empty, </throws> /// <summary> or if leading coefficient is 0 and this is not a /// constant polynomial (that is, it is not the monomial "0") /// </summary> internal GF256Poly(GF256 field, int[] coefficients) { if (coefficients == null || coefficients.Length == 0) { throw new System.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; } }
public ReedSolomonEncoder(GF256 field) { if (!GF256.QR_CODE_FIELD.Equals(field)) { throw new System.ArgumentException("Only QR Code is supported at this time"); } this.field = field; this.cachedGenerators = new System.Collections.Generic.List<Object>(10); cachedGenerators.Add(new GF256Poly(field, new int[]{1})); }