Ejemplo n.º 1
0
        public QRPolynomial Multiply(QRPolynomial e)
        {
            var num = new DataCache(this.GetLength() + e.GetLength() - 1);

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

            return(new QRPolynomial(num, 0));
        }
Ejemplo n.º 2
0
        internal static QRPolynomial GetErrorCorrectPolynomial(int errorCorrectLength)
        {
            QRPolynomial a = new QRPolynomial(new DataCache()
            {
                1
            }, 0);

            for (int i = 0; i < errorCorrectLength; i++)
            {
                a = a.Multiply(new QRPolynomial(new DataCache()
                {
                    1, QRMath.GExp(i)
                }, 0));
            }

            return(a);
        }
Ejemplo n.º 3
0
        public QRPolynomial Mod(QRPolynomial e)
        {
            if (Convert.ToInt64(this.GetLength()) - Convert.ToInt64(e.GetLength()) < 0)
            {
                return(this);
            }

            int ratio = QRMath.GLog(this.Get(0)) - QRMath.GLog(e.Get(0));

            var num = new DataCache(this.GetLength());

            for (int i = 0; i < this.GetLength(); i++)
            {
                num[i] = this.Get(i);
            }

            for (int i = 0; i < e.GetLength(); i++)
            {
                num[i] ^= QRMath.GExp(QRMath.GLog(e.Get(i)) + ratio);
            }

            // recursive call
            return(new QRPolynomial(num, 0).Mod(e));
        }