コード例 #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 = new int[] { 0 };
         }
         else
         {
             this.coefficients = new int[coefficientsLength - firstNonZero];
             Array.Copy(coefficients,
                 firstNonZero,
                 this.coefficients,
                 0,
                 this.coefficients.Length);
         }
     }
     else
     {
         this.coefficients = coefficients;
     }
 }
コード例 #2
0
 public SimpleRSDecoder(GenericGF field)
 {
     _field = field;
     _cachedGenerators = new List<GenericGFPoly> { new GenericGFPoly(field, new int[] {1}) };
 }