109 references to BigIntegerCalculator
System.Runtime.Numerics (109)
System\Number.BigInteger.cs (20)
398double digitRatio = 0.10381025297 * 32.0 / BigIntegerCalculator.BitsPerLimb; // log_{2^BitsPerLimb}(10) 430double digitRatio = 0.10381025297 * 32.0 / BigIntegerCalculator.BitsPerLimb; 435leading = leading.Slice(0, BigIntegerCalculator.ActualLength(leading)); 452base1E9 = base1E9.Slice(0, BigIntegerCalculator.ActualLength(base1E9)); 470double digitRatio = 0.10381025297 * 32.0 / BigIntegerCalculator.BitsPerLimb; 476ReadOnlySpan<nuint> buffer2 = buffer.Slice(0, BigIntegerCalculator.ActualLength(buffer)); 478BigIntegerCalculator.Multiply(buffer2, multiplier, bitsUpper); 484BigIntegerCalculator.AddSelf(bits, buffer.Slice(0, BigIntegerCalculator.ActualLength(buffer))); 832double digitRatio = 1.070328873472 * BigIntegerCalculator.BitsPerLimb / 32.0; 988int ToStringNaiveThreshold = BigIntegerCalculator.DivideBurnikelZieglerThreshold; 1018while (bits.Length < powOfTen.Length + omittedLength || BigIntegerCalculator.Compare(bits.Slice(omittedLength), powOfTen) < 0) 1032BigIntegerCalculator.Divide(bits.Slice(omittedLength), powOfTen, upper, lower.Slice(omittedLength)); 1041lower.Slice(0, BigIntegerCalculator.ActualLength(lower)), 1052upper.Slice(0, BigIntegerCalculator.ActualLength(upper)), 1346BigIntegerCalculator.Square(src, dst); 1396return (MaxPartialDigits * (1 << index)) / BigIntegerCalculator.BitsPerLimb; 1429BigIntegerCalculator.Multiply(left, UInt32PowersOfTen[trailingZeroCount], bits.Slice(0, left.Length + 1)); 1467BigIntegerCalculator.Multiply(src, power, dst); 1485BigIntegerCalculator.Multiply(left, powersOfTen, bits2);
System\Numerics\BigInteger.cs (84)
38internal static int MaxLength => Array.MaxLength / BigIntegerCalculator.BitsPerLimb; 215int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 924BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor._sign), quotient, out nuint rest); 945BigIntegerCalculator.Divide(dividend._bits, divisor._bits, quotient, rest); 1036return BigIntegerCalculator.Gcd(NumericsHelpers.Abs(left._sign), NumericsHelpers.Abs(right._sign)); 1043? BigIntegerCalculator.Gcd(right._bits, NumericsHelpers.Abs(left._sign)) 1051? BigIntegerCalculator.Gcd(left._bits, NumericsHelpers.Abs(right._sign)) 1057return BigIntegerCalculator.Compare(left._bits, right._bits) < 0 1064Debug.Assert(BigIntegerCalculator.Compare(leftBits, rightBits) >= 0); 1071nuint temp = BigIntegerCalculator.Remainder(leftBits, rightBits[0]); 1072result = BigIntegerCalculator.Gcd(rightBits[0], temp); 1078BigIntegerCalculator.Remainder(leftBits, rightBits, bits); 1083result = BigIntegerCalculator.Gcd(left, right); 1090BigIntegerCalculator.Gcd(leftBits, rightBits, bits); 1120nuint bitsResult = trivialValue && trivialExponent ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) : 1121trivialValue ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent._bits!, NumericsHelpers.Abs(modulus._sign)) : 1122trivialExponent ? BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) : 1123BigIntegerCalculator.Pow(value._bits!, exponent._bits!, NumericsHelpers.Abs(modulus._sign)); 1135BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), modulus._bits!, bits); 1139BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent._bits!, modulus._bits!, bits); 1144BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent._sign), modulus._bits!, bits); 1148BigIntegerCalculator.Pow(value._bits!, exponent._bits!, modulus._bits!, bits); 1195int size = BigIntegerCalculator.PowBound(power, 1); 1198BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), power, bits); 1204int size = BigIntegerCalculator.PowBound(power, value._bits!.Length); 1207BigIntegerCalculator.Pow(value._bits, power, bits); 1388int bitsResult = BigIntegerCalculator.Compare(_bits, other._bits); 1756nuint highBitMask = (nuint)1 << (BigIntegerCalculator.BitsPerLimb - 1); 1813int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 1887BigIntegerCalculator.Add(rightBits, NumericsHelpers.Abs(leftSign), bits); 1898BigIntegerCalculator.Add(leftBits, NumericsHelpers.Abs(rightSign), bits); 1909BigIntegerCalculator.Add(rightBits, leftBits, bits); 1920BigIntegerCalculator.Add(leftBits, rightBits, bits); 1956BigIntegerCalculator.Subtract(rightBits, NumericsHelpers.Abs(leftSign), bits); 1967BigIntegerCalculator.Subtract(leftBits, NumericsHelpers.Abs(rightSign), bits); 1971else if (BigIntegerCalculator.Compare(leftBits, rightBits) < 0) 1976BigIntegerCalculator.Subtract(rightBits, leftBits, bits); 1987BigIntegerCalculator.Subtract(leftBits, rightBits, bits); 2027int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 2526return BitwiseOp<BigIntegerCalculator.BitwiseAndOp>(in left, in right, zLen); 2536return BitwiseOp<BigIntegerCalculator.BitwiseOrOp>(in left, in right, Math.Max(xLen, yLen) + 1); 2546return BitwiseOp<BigIntegerCalculator.BitwiseXorOp>(in left, in right, Math.Max(xLen, yLen) + 1); 2550where TOp : struct, BigIntegerCalculator.IBitwiseOp 2554BigIntegerCalculator.BitwiseOp<TOp>( 2583(int digitShift, int smallShift) = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb); 2598: bits[^1] >> (BigIntegerCalculator.BitsPerLimb - smallShift); 2616BigIntegerCalculator.LeftShiftSelf(zd, smallShift, out nuint carry); 2636: m >> (BigIntegerCalculator.BitsPerLimb - smallShift); 2677(int digitShift, int smallShift) = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb); 2708BigIntegerCalculator.RightShiftSelf(zd, smallShift, out nuint carry); 2745BigIntegerCalculator.Add(value._bits, 1, bits); 2754BigIntegerCalculator.Subtract(value._bits, 1, bits); 2780BigIntegerCalculator.Add(value._bits, 1, bits); 2788BigIntegerCalculator.Subtract(value._bits, 1, bits); 2809BigIntegerCalculator.Subtract(value._bits, 1, bits); 2818BigIntegerCalculator.Add(value._bits, 1, bits); 2859BigIntegerCalculator.Multiply(right, NumericsHelpers.Abs(leftSign), bits); 2870BigIntegerCalculator.Multiply(left, NumericsHelpers.Abs(rightSign), bits); 2879BigIntegerCalculator.Square(left, bits); 2890BigIntegerCalculator.Multiply(left, right, bits); 2923BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor._sign), quotient); 2943BigIntegerCalculator.Divide(dividend._bits, divisor._bits, quotient); 2972nuint remainder = BigIntegerCalculator.Remainder(dividend._bits, NumericsHelpers.Abs(divisor._sign)); 2986BigIntegerCalculator.Remainder(dividend._bits, divisor._bits, bits); 3089long bitLength = (long)bitsArrayLength * BigIntegerCalculator.BitsPerLimb - 3392BigIntegerCalculator.RightShiftSelf(zd, nuintSmallShift, out nuint carry); 3397BigIntegerCalculator.SwapUpperAndLower(zd, nuintDigitShift); 3401BigIntegerCalculator.LeftShiftSelf(zd, nuintSmallShift, out nuint carry); 3406BigIntegerCalculator.SwapUpperAndLower(zd, zd.Length - nuintDigitShift); 3420BigIntegerCalculator.RightShiftSelf(zd, smallShift32, out nuint carry); 3433BigIntegerCalculator.SwapUpperAndLower(words, effectiveDigitShift); 3443BigIntegerCalculator.LeftShiftSelf(zd, smallShift32, out _); 3458BigIntegerCalculator.SwapUpperAndLower(words, zWordCount - effectiveDigitShift); 3519&& (leadingZeroCount != bits.Length - 1 || bits[^1] != ((nuint)1 << (BigIntegerCalculator.BitsPerLimb - 1)))) 3537BigIntegerCalculator.RotateLeft(zd, rotateLeftAmount); 3573result += (uint)BigIntegerCalculator.BitsPerLimb; 3607int result = (bits.Length - 1) * BigIntegerCalculator.BitsPerLimb; 3611result += BigIntegerCalculator.BitsPerLimb - BitOperations.LeadingZeroCount(bits[^1]); 3626result += BigIntegerCalculator.BitsPerLimb + 1 - BitOperations.LeadingZeroCount(~part); 3843? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value._sign | 1)) 3844: (BigInteger)(((long)value._bits.Length * BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount(value._bits[^1])); 5225(int digitShift, int smallShift) = Math.DivRem(shiftAmount, BigIntegerCalculator.BitsPerLimb); 5264nuint signBit = (nuint)1 << (BigIntegerCalculator.BitsPerLimb - 1); 5314BigIntegerCalculator.RightShiftSelf(zd, smallShift, out _);
System\Numerics\BigIntegerCalculator.SquMul.cs (5)
708BigIntegerCalculator.Square(p0, r0); 709BigIntegerCalculator.Square(p1, r1); 710BigIntegerCalculator.Square(pm1, rm1); 711BigIntegerCalculator.Square(pm2, rm2); 712BigIntegerCalculator.Square(pInf, rInf);