Beispiel #1
0
        public void Divide()
        {
            //System.Diagnostics.Debugger.Launch();

              GaloisField field = new GaloisField(285, 256, 0);

              GaloisPolynomial divident = new GaloisPolynomial(field, new int[] {32, 49, 205, 69, 42, 20, 0, 236, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});

              GaloisPolynomial divider = new GaloisPolynomial(field, new int[] {1, 119, 66, 83, 120, 119, 22, 197, 83, 249, 41, 143, 134, 85, 53, 125, 99, 79});

              GaloisPolynomial quotient, remainder;
              divident.Divide(divider, out quotient, out remainder);

              int[] expectedQuotientCoefficients = new int[] { 32, 119, 212, 254, 109, 212, 30, 95, 117};
              int[] expectedRemainderCoefficients = new int[] { 3, 130, 179, 194, 0, 55, 211, 110, 79, 98, 72, 170, 96, 211, 137, 213};

              Assert.AreEqual(expectedQuotientCoefficients.Length, quotient.Coefficients.Length);
              Assert.AreEqual(expectedRemainderCoefficients.Length, remainder.Coefficients.Length);

              for (int i = 0; i < quotient.Coefficients.Length; i++)
            Assert.AreEqual(expectedQuotientCoefficients[i], quotient.Coefficients[i]);

              for (int i = 0; i < remainder.Coefficients.Length; i++)
            Assert.AreEqual(expectedRemainderCoefficients[i], remainder.Coefficients[i]);
        }
Beispiel #2
0
        public GaloisPolynomial(GaloisField field, int[] coefficients)
        {
            if (field == null)
              throw new NFXException(StringConsts.ARGUMENT_ERROR + GetType().Name + ".ctor(field=null)");

            if (coefficients == null || coefficients.Length == 0)
              throw new NFXException(StringConsts.ARGUMENT_ERROR + GetType().Name + ".ctor(coeff=null|empty)");

            m_Field = field;

            if (coefficients.Length > 1 && coefficients[0] == 0)
            {
              int firstNonZero = 1;
              while (firstNonZero < coefficients.Length && coefficients[firstNonZero] == 0)
            firstNonZero++;

              if (firstNonZero == coefficients.Length)
              {
            m_Coefficients = m_Field.Polynomial0.Coefficients;
              }
              else
              {
            m_Coefficients = new int[coefficients.Length - firstNonZero];
            Array.Copy(coefficients, firstNonZero, m_Coefficients, 0, m_Coefficients.Length);
              }
            }
            else
            {
              m_Coefficients = coefficients;
            }
        }
Beispiel #3
0
 public ReedSolomonEncoder(GaloisField field)
 {
     m_Field = field;
       m_PolySet.Add( new GaloisPolynomial(field, new int[] { 1 }) );
 }