Ejemplo n.º 1
0
        /**
         *  Performs a<sup>2</sup>
         *  @param a The number to square.
         *  @param aLen The length of the number to square.
         */
        private static int[] Square(int[] a, int aLen, int[] res)
        {
            long carry;

            for (int i = 0; i < aLen; i++)
            {
                carry = 0;
                for (int j = i + 1; j < aLen; j++)
                {
                    carry      = UnsignedMultAddAdd(a[i], a[j], res[i + j], (int)carry);
                    res[i + j] = (int)carry;
                    carry      = Utils.URShift(carry, 32);
                }
                res[i + aLen] = (int)carry;
            }

            BitLevel.ShiftLeftOneBit(res, res, aLen << 1);

            carry = 0;
            for (int i = 0, index = 0; i < aLen; i++, index++)
            {
                carry      = UnsignedMultAddAdd(a[i], a[i], res[index], (int)carry);
                res[index] = (int)carry;
                carry      = Utils.URShift(carry, 32);
                index++;
                carry     += res[index] & 0xFFFFFFFFL;
                res[index] = (int)carry;
                carry      = Utils.URShift(carry, 32);
            }
            return(res);
        }
Ejemplo n.º 2
0
 internal BigInteger ShiftLeftOneBit()
 {
     return((sign == 0) ? this : BitLevel.ShiftLeftOneBit(this));
 }