Exemple #1
0
        public static QRPolynomial GetErrorCorrectPolynomial(int errorCorrectLength)
        {
            var a = new QRPolynomial(new int[] { 1 }, 0);

            for (int i = 0; i < errorCorrectLength; i++)
            {
                a = a.Multiply(new QRPolynomial(new int[] { 1, QRMath.GExp(i) }, 0));
            }
            return(a);
        }
Exemple #2
0
        public QRPolynomial Multiply(QRPolynomial other)
        {
            var num = new int[Length + other.Length - 1];

            for (int i = 0; i < Length; i++)
            {
                for (int j = 0; j < other.Length; j++)
                {
                    num[i + j] ^= QRMath.GExp(QRMath.GLog(this[i]) + QRMath.GLog(other[j]));
                }
            }

            return(new QRPolynomial(num, 0));
        }
Exemple #3
0
        public QRPolynomial Mod(QRPolynomial other)
        {
            if (Length - other.Length < 0)
            {
                return(this);
            }

            var ratio = QRMath.GLog(this[0]) - QRMath.GLog(other[0]);

            var num = new int[Length];

            Array.Copy(_num, num, Length);
            for (int i = 0; i < other.Length; i++)
            {
                num[i] ^= QRMath.GExp(QRMath.GLog(other[i]) + ratio);
            }

            return(new QRPolynomial(num, 0).Mod(other));
        }