Esempio n. 1
0
        // *************************************************
        // *             Public Class Methods              *
        // *************************************************

        public static BinaryGaloisFieldElement[] createGeneratorPolynomial(BinaryGaloisField gf, Int32 maxCorrectibleErrorCnt)
        {
            // Generator polynomial, g(x), is of order 2s, so has 2s+1 coefficients
            BinaryGaloisFieldElement[] g = new BinaryGaloisFieldElement[2 * maxCorrectibleErrorCnt + 1];

            // Make g(x) = 1
            g[0] = 1;
            for (int i = 1; i <= (2 * maxCorrectibleErrorCnt); i++)
            {
                // Always make coefficient of x^i term equal to 1
                g[i] = 1;

                // Below multiply (g(x) = g[0] + g[1]*x + ... + g[i]*(x^i)) by (x - alpha^i)
                for (int j = (i - 1); j > 0; j--)
                {
                    if (g[j] != 0)
                    {
                        g[j] = g[j - 1] - gf.Multiply(gf.AlphaFromIndex(i), g[j]);
                    }
                    else
                    {
                        g[j] = g[j - 1];
                    }
                }
                // Coefficient of x^0 term is alpha^(1+2+...+i)
                g[0] = gf.AlphaFromIndex(((i * (i + 1)) / 2));
            }
            return(g);
        }
Esempio n. 2
0
        // *************************************************
        // *           Public Instance Methods             *
        // *************************************************

        public Int32[] GenerateParity(Int32[] messageData)
        {
            Int32[] retArray = new Int32[2 * s];
            BinaryGaloisFieldElement[] data = new BinaryGaloisFieldElement[N];

            if (messageData.Length != k)
            {
                throw new ArgumentException("Wrong size.", "messageData");
            }

            // Parity is defined parityPoly(x) = x^2s * messagePoly(x) (mod generatorPoly(x))
            // Convert input message data to array of BinaryGaloisFieldElement (implicit cast)
            // Create x^2s * messagePoly(x) by shifting data up by 2s positions
            for (int i = 0; i < k; i++)
            {
                data[i + (2 * s)] = messageData[i];
            }

            // Now do long division using generatorPoly, remainder is parity data
            // Use synthetic division since generatorPoly is monic
            for (int i = N - 1; i >= (2 * s); i--)
            {
                if (data[i] != 0)
                {
                    for (int j = 1; j <= (2 * s); j++)
                    {
                        data[i - j] = data[i - j] - galoisField.Multiply(data[i], generatorPoly[2 * s - j]);
                    }
                    // Set to zero
                    data[i] = 0;
                }
            }

            // Copy 2*s pieces of data to the parity symbols array
            for (int i = 0; i < (2 * s); i++)
            {
                retArray[i] = (Int32)data[i];
            }

            // Return parity symbols
            return(retArray);
        }
Esempio n. 3
0
 // *************************************************
 // *             Public Class Methods              *
 // *************************************************
 
 public static BinaryGaloisFieldElement[] createGeneratorPolynomial(BinaryGaloisField gf, Int32 maxCorrectibleErrorCnt)
 {
   // Generator polynomial, g(x), is of order 2s, so has 2s+1 coefficients
   BinaryGaloisFieldElement[] g = new BinaryGaloisFieldElement[2*maxCorrectibleErrorCnt + 1];
   
   // Make g(x) = 1
   g[0] = 1;
   for (int i = 1; i<=(2*maxCorrectibleErrorCnt); i++)
   {
     // Always make coefficient of x^i term equal to 1
     g[i] = 1;
     
     // Below multiply (g(x) = g[0] + g[1]*x + ... + g[i]*(x^i)) by (x - alpha^i)
     for (int j=(i-1); j > 0; j--)
     {
       if (g[j] != 0)
         g[j] = g[j - 1] - gf.Multiply(gf.AlphaFromIndex(i),g[j]);
       else
         g[j] = g[j - 1];
     }
     // Coefficient of x^0 term is alpha^(1+2+...+i)
     g[0] = gf.AlphaFromIndex( ((i*(i+1))/2) );
   }
   return g;
 }