当前位置: 首页>>代码示例>>C#>>正文


C# BigInteger.UnCache方法代码示例

本文整理汇总了C#中BigInteger.UnCache方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.UnCache方法的具体用法?C# BigInteger.UnCache怎么用?C# BigInteger.UnCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigInteger的用法示例。


在下文中一共展示了BigInteger.UnCache方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InplaceShiftRight

        /// <summary>
        /// Performs Value >>= count where Value is a positive number.
        /// </summary>
        /// 
        /// <param name="Value">The source BigIntger</param>
        /// <param name="N">Shift distance</param>
        internal static void InplaceShiftRight(BigInteger Value, int N)
        {
            int sign = Value.Signum();

            if (N == 0 || Value.Signum() == 0)
                return;

            int intCount = N >> 5; // count of integers
            Value._numberLength -= intCount;
            if (!ShiftRight(Value._digits, Value._numberLength, Value._digits, intCount, N & 31) && sign < 0)
            {
                // remainder not zero: add one to the result
                int i;
                for (i = 0; (i < Value._numberLength) && (Value._digits[i] == -1); i++)
                    Value._digits[i] = 0;

                if (i == Value._numberLength)
                    Value._numberLength++;

                Value._digits[i]++;
            }
            Value.CutOffLeadingZeroes();
            Value.UnCache();
        }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:30,代码来源:BitLevel.cs

示例2: InplaceSubtract

 /// <summary>
 /// Performs Op1 -= Op2. 
 /// <para>Op1 must have enough place to store the result (i.e. Op1.BitLength() >= Op2.BitLength()).
 /// Both should be positive (what implies that Op1 >= Op2).</para>
 /// </summary>
 /// 
 /// <param name="A">The input minuend, and the output result</param>
 /// <param name="B">The subtrahend</param>
 internal static void InplaceSubtract(BigInteger A, BigInteger B)
 {
     // PRE: op1 >= op2 > 0
     Subtract(A._digits, A._digits, A._numberLength, B._digits,
             B._numberLength);
     A.CutOffLeadingZeroes();
     A.UnCache();
 }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:16,代码来源:Elementary.cs

示例3: InplaceShiftLeft

 /// <summary>
 /// Performs val &lt;= count, val should have enough place (and one digit more)
 /// </summary>
 /// 
 /// <param name="Value">The source BigIntger</param>
 /// <param name="N">Shift distance</param>
 internal static void InplaceShiftLeft(BigInteger Value, int N)
 {
     int intCount = N >> 5; // count of integers
     Value._numberLength += intCount + (IntUtils.NumberOfLeadingZeros(Value._digits[Value._numberLength - 1]) - (N & 31) >= 0 ? 0 : 1);
     ShiftLeft(Value._digits, Value._digits, intCount, N & 31);
     Value.CutOffLeadingZeroes();
     Value.UnCache();
 }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:14,代码来源:BitLevel.cs

示例4: InplaceAdd

 /// <summary>
 /// Performs Op1 += Op2.
 /// <para>Op1 must have enough place to store the result (i.e. Op1.BitLength() >= Op2.BitLength()). 
 /// Both should be positive (i.e. Op1 >= Op2).</para>
 /// </summary>
 /// 
 /// <param name="A">The input minuend, and the output result</param>
 /// <param name="B">The addend</param>
 internal static void InplaceAdd(BigInteger A, BigInteger B)
 {
     // op1 >= op2 > 0
     Add(A._digits, A._digits, A._numberLength, B._digits, B._numberLength);
     A._numberLength = System.Math.Min(System.Math.Max(A._numberLength, B._numberLength) + 1, A._digits.Length);
     A.CutOffLeadingZeroes();
     A.UnCache();
 }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:16,代码来源:Elementary.cs

示例5: CompleteInPlaceAdd

 /// <summary>
 /// Same as InplaceAdd(BigInteger, BigInteger), but without the restriction of non-positive values
 /// </summary>
 /// 
 /// <param name="A">The operand</param>
 /// <param name="B">The addend</param>
 internal static void CompleteInPlaceAdd(BigInteger A, BigInteger B)
 {
     if (A._sign == 0)
     {
         Array.Copy(B._digits, 0, A._digits, 0, B._numberLength);
     }
     else if (B._sign == 0)
     {
         return;
     }
     else if (A._sign == B._sign)
     {
         Add(A._digits, A._digits, A._numberLength, B._digits, B._numberLength);
     }
     else
     {
         int sign = UnsignedArraysCompare(A._digits, B._digits, A._numberLength, B._numberLength);
         if (sign > 0)
         {
             Subtract(A._digits, A._digits, A._numberLength, B._digits, B._numberLength);
         }
         else
         {
             InverseSubtract(A._digits, A._digits, A._numberLength, B._digits, B._numberLength);
             A._sign = -A._sign;
         }
     }
     A._numberLength = System.Math.Max(A._numberLength, B._numberLength) + 1;
     A.CutOffLeadingZeroes();
     A.UnCache();
 }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:37,代码来源:Elementary.cs

示例6: CompleteInPlaceSubtract

        /// <summary>
        /// Same as InplaceSubtract(BigInteger, BigInteger), but without the restriction of non-positive values
        /// <para>Op1 should have enough space to save the result</para>
        /// </summary>
        /// 
        /// <param name="A">The input minuend, and the output result</param>
        /// <param name="B">The subtrahend</param>
        internal static void CompleteInPlaceSubtract(BigInteger A, BigInteger B)
        {
            int resultSign = A.CompareTo(B);

            if (A._sign == 0)
            {
                Array.Copy(B._digits, 0, A._digits, 0, B._numberLength);
                A._sign = -B._sign;
            }
            else if (A._sign != B._sign)
            {
                Add(A._digits, A._digits, A._numberLength, B._digits, B._numberLength);
                A._sign = resultSign;
            }
            else
            {
                int sign = UnsignedArraysCompare(A._digits,
                        B._digits, A._numberLength, B._numberLength);
                if (sign > 0)
                {
                    Subtract(A._digits, A._digits, A._numberLength, B._digits, B._numberLength);	// op1 = op1 - op2
                    // op1.sign remains equal
                }
                else
                {
                    InverseSubtract(A._digits, A._digits, A._numberLength, B._digits, B._numberLength);	// op1 = op2 - op1
                    A._sign = -A._sign;
                }
            }
            A._numberLength = System.Math.Max(A._numberLength, B._numberLength) + 1;
            A.CutOffLeadingZeroes();
            A.UnCache();
        }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:40,代码来源:Elementary.cs

示例7: inplaceAdd

 /**
  * Performs: {@code op1 += addend}. The number must to have place to hold a
  * possible carry.
  */
 internal static void inplaceAdd(BigInteger op1, int addend)
 {
     int carry = inplaceAdd(op1.Digits, op1.numberLength, addend);
     if (carry == 1) {
         op1.Digits[op1.numberLength] = 1;
         op1.numberLength++;
     }
     op1.UnCache();
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:13,代码来源:Elementary.cs

示例8: inplaceSubtract

 /**
  * Performs {@code op1 -= op2}. {@code op1} must have enough place to store
  * the result (i.e. {@code op1.bitLength() >= op2.bitLength()}). Both
  * should be positive (what implies that {@code op1 >= op2}).
  *
  * @param op1
  *            the input minuend, and the output result.
  * @param op2
  *            the subtrahend
  */
 internal static void inplaceSubtract(BigInteger op1, BigInteger op2)
 {
     // PRE: op1 >= op2 > 0
     subtract(op1.Digits, op1.Digits, op1.numberLength, op2.Digits,
             op2.numberLength);
     op1.CutOffLeadingZeroes();
     op1.UnCache();
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:18,代码来源:Elementary.cs

示例9: completeInPlaceSubtract

 /**
  * Same as
  *
  * @link #inplaceSubtract(BigInteger, BigInteger), but without the
  *       restriction of non-positive values
  * @param op1
  *            should have enough space to save the result
  * @param op2
  */
 internal static void completeInPlaceSubtract(BigInteger op1, BigInteger op2)
 {
     int resultSign = op1.CompareTo(op2);
     if (op1.Sign == 0) {
         Array.Copy(op2.Digits, 0, op1.Digits, 0, op2.numberLength);
         op1.Sign = -op2.Sign;
     } else if (op1.Sign != op2.Sign) {
         add(op1.Digits, op1.Digits, op1.numberLength, op2.Digits,
             op2.numberLength);
         op1.Sign = resultSign;
     } else {
         int sign = unsignedArraysCompare(op1.Digits,
                 op2.Digits, op1.numberLength, op2.numberLength);
         if (sign > 0) {
             subtract(op1.Digits, op1.Digits, op1.numberLength, op2.Digits,
                     op2.numberLength);	// op1 = op1 - op2
             // op1.sign remains equal
         } else {
             inverseSubtract(op1.Digits, op1.Digits, op1.numberLength,
                     op2.Digits, op2.numberLength);	// op1 = op2 - op1
             op1.Sign = -op1.Sign;
         }
     }
     op1.numberLength = System.Math.Max(op1.numberLength, op2.numberLength) + 1;
     op1.CutOffLeadingZeroes();
     op1.UnCache();
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:36,代码来源:Elementary.cs

示例10: completeInPlaceAdd

 /**
  * Same as @link #inplaceAdd(BigInteger, BigInteger), but without the restriction of
  *       non-positive values
  * @param op1 any number
  * @param op2 any number
  */
 internal static void completeInPlaceAdd(BigInteger op1, BigInteger op2)
 {
     if (op1.Sign == 0)
         Array.Copy(op2.Digits, 0, op1.Digits, 0, op2.numberLength);
     else if (op2.Sign == 0)
         return;
     else if (op1.Sign == op2.Sign)
         add(op1.Digits, op1.Digits, op1.numberLength, op2.Digits,
                 op2.numberLength);
     else {
         int sign = unsignedArraysCompare(op1.Digits,
                 op2.Digits, op1.numberLength, op2.numberLength);
         if (sign > 0)
             subtract(op1.Digits, op1.Digits, op1.numberLength, op2.Digits,
                     op2.numberLength);
         else {
             inverseSubtract(op1.Digits, op1.Digits, op1.numberLength,
                     op2.Digits, op2.numberLength);
             op1.Sign = -op1.Sign;
         }
     }
     op1.numberLength = System.Math.Max(op1.numberLength, op2.numberLength) + 1;
     op1.CutOffLeadingZeroes();
     op1.UnCache();
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:31,代码来源:Elementary.cs

示例11: InplaceShiftRight

 /**
  * Performs {@code val >>= count} where {@code val} is a positive number.
  */
 public static void InplaceShiftRight(BigInteger val, int count)
 {
     int sign = val.Sign;
     if (count == 0 || val.Sign == 0)
         return;
     int intCount = count >> 5; // count of integers
     val.numberLength -= intCount;
     if (!ShiftRight(val.Digits, val.numberLength, val.Digits, intCount, count & 31)
         && sign < 0) {
         // remainder not zero: add one to the result
         int i;
         for (i = 0; (i < val.numberLength) && (val.Digits[i] == -1); i++) {
             val.Digits[i] = 0;
         }
         if (i == val.numberLength) {
             val.numberLength++;
         }
         val.Digits[i]++;
     }
     val.CutOffLeadingZeroes();
     val.UnCache();
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:25,代码来源:BitLevel.cs

示例12: InplaceShiftLeft

 // val should have enough place (and one digit more)
 /// <summary>
 /// Performs <c>val &lt;&lt;= count<c></c>.
 /// </summary>
 /// <param name="val"></param>
 /// <param name="count"></param>
 public static void InplaceShiftLeft(BigInteger val, int count)
 {
     int intCount = count >> 5; // count of integers
     val.numberLength += intCount
                         + (Utils.NumberOfLeadingZeros(val.Digits[val.numberLength - 1])
                            - (count & 31) >= 0
                             ? 0
                             : 1);
     ShiftLeft(val.Digits, val.Digits, intCount, count & 31);
     val.CutOffLeadingZeroes();
     val.UnCache();
 }
开发者ID:tupunco,项目名称:deveel-math,代码行数:18,代码来源:BitLevel.cs


注:本文中的BigInteger.UnCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。