180 references to BigIntegerCalculator
System.Runtime.Numerics (180)
System\Number.BigInteger.cs (20)
443double digitRatio = 0.10381025297 * 32.0 / BigIntegerCalculator.BitsPerLimb; // log_{2^BitsPerLimb}(10) 475double digitRatio = 0.10381025297 * 32.0 / BigIntegerCalculator.BitsPerLimb; 480leading = leading.Slice(0, BigIntegerCalculator.ActualLength(leading)); 497base1E9 = base1E9.Slice(0, BigIntegerCalculator.ActualLength(base1E9)); 515double digitRatio = 0.10381025297 * 32.0 / BigIntegerCalculator.BitsPerLimb; 521ReadOnlySpan<nuint> buffer2 = buffer.Slice(0, BigIntegerCalculator.ActualLength(buffer)); 523BigIntegerCalculator.Multiply(buffer2, multiplier, bitsUpper); 529BigIntegerCalculator.AddSelf(bits, buffer.Slice(0, BigIntegerCalculator.ActualLength(buffer))); 868double digitRatio = 1.070328873472 * BigIntegerCalculator.BitsPerLimb / 32.0; 1039int ToStringNaiveThreshold = BigIntegerCalculator.DivideBurnikelZieglerThreshold; 1069while (bits.Length < powOfTen.Length + omittedLength || BigIntegerCalculator.Compare(bits.Slice(omittedLength), powOfTen) < 0) 1083BigIntegerCalculator.Divide(bits.Slice(omittedLength), powOfTen, upper, lower.Slice(omittedLength)); 1092lower.Slice(0, BigIntegerCalculator.ActualLength(lower)), 1103upper.Slice(0, BigIntegerCalculator.ActualLength(upper)), 1397BigIntegerCalculator.Square(src, dst); 1447return (MaxPartialDigits * (1 << index)) / BigIntegerCalculator.BitsPerLimb; 1480BigIntegerCalculator.Multiply(left, UInt32PowersOfTen[trailingZeroCount], bits.Slice(0, left.Length + 1)); 1518BigIntegerCalculator.Multiply(src, power, dst); 1534BigIntegerCalculator.Multiply(left, powersOfTen, bits2);
System\Numerics\BigInteger.cs (155)
42internal static int MaxLength => Array.MaxLength / BigIntegerCalculator.BitsPerLimb; 219int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 946BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor._sign), quotient, out nuint rest); 962? BigIntegerCalculator.GetCommonLimbOffset(dividend._bits, divisor._bits) 983BigIntegerCalculator.DivideSpecial(dividendBits, divisorBits, quotient, remainderBits); 987BigIntegerCalculator.Divide(dividendBits, divisorBits, quotient, remainderBits); 1099return BigIntegerCalculator.Gcd(NumericsHelpers.Abs(left._sign), NumericsHelpers.Abs(right._sign)); 1106? BigIntegerCalculator.Gcd(right._bits, NumericsHelpers.Abs(left._sign)) 1114? BigIntegerCalculator.Gcd(left._bits, NumericsHelpers.Abs(right._sign)) 1126? BigIntegerCalculator.GetCommonLimbOffset(leftBits, rightBits) 1131return BigIntegerCalculator.Compare(reducedLeft, reducedRight) < 0 1138Debug.Assert(BigIntegerCalculator.Compare(leftBits, rightBits) >= 0); 1145nuint temp = BigIntegerCalculator.Remainder(leftBits, rightBits[0]); 1146result = BigIntegerCalculator.Gcd(rightBits[0], temp); 1152BigIntegerCalculator.Remainder(leftBits, rightBits, bits); 1157result = BigIntegerCalculator.Gcd(left, right); 1164BigIntegerCalculator.Gcd(leftBits, rightBits, bits[resultOffset..]); 1173result <<= checked(resultOffset * BigIntegerCalculator.BitsPerLimb); 1232exponent = checked((nonZeroIndex * BigIntegerCalculator.BitsPerLimb) 1261int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 1285int length = BigIntegerCalculator.ActualLength(bits); 1286int digitShift = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb, out int smallShift); 1293BigIntegerCalculator.LeftShiftSelf(shiftedBits, smallShift, out nuint carry); 1342nuint bitsResult = trivialValue && trivialExponent ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) : 1343trivialValue ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent._bits!, NumericsHelpers.Abs(modulus._sign)) : 1344trivialExponent ? BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) : 1345BigIntegerCalculator.Pow(value._bits!, exponent._bits!, NumericsHelpers.Abs(modulus._sign)); 1357BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), modulus._bits!, bits); 1361BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent._bits!, modulus._bits!, bits); 1366BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent._sign), modulus._bits!, bits); 1370BigIntegerCalculator.Pow(value._bits!, exponent._bits!, modulus._bits!, bits); 1441int genericSize = BigIntegerCalculator.PowBound(power, 1); 1444BigIntegerCalculator.Pow(magnitude, power, genericBits); 1451? BigIntegerCalculator.ExtractFactorPower( 1452ref remainingMagnitude, 3, BigIntegerCalculator.Pow3FactorizationPowers) 1455? BigIntegerCalculator.ExtractFactorPower( 1456ref remainingMagnitude, 5, BigIntegerCalculator.Pow5FactorizationPowers) 1459? BigIntegerCalculator.ExtractFactorPower( 1460ref remainingMagnitude, 7, BigIntegerCalculator.Pow7FactorizationPowers) 1471powerIndices = BigIntegerCalculator.Pow3TableIndices; 1472powers = BigIntegerCalculator.Pow3Table; 1473powerTableStartIndex = BigIntegerCalculator.Pow3TableStartIndex; 1478powerIndices = BigIntegerCalculator.Pow5TableIndices; 1479powers = BigIntegerCalculator.Pow5Table; 1480powerTableStartIndex = BigIntegerCalculator.Pow5TableStartIndex; 1485powerIndices = BigIntegerCalculator.Pow7TableIndices; 1486powers = BigIntegerCalculator.Pow7Table; 1487powerTableStartIndex = BigIntegerCalculator.Pow7TableStartIndex; 1501bitLengthBounds = BigIntegerCalculator.GetPowBitLengthBounds( 1504if (((bitLengthBounds.LowerBound + (uint)BigIntegerCalculator.BitsPerLimb - 1) 1505/ (uint)BigIntegerCalculator.BitsPerLimb) > (uint)MaxLength) 1517ReadOnlySpan<nuint> exactBits = BigIntegerCalculator.GetPower( 1538ulong finalSize = (bitLengthBounds.UpperBound + (uint)BigIntegerCalculator.BitsPerLimb - 1) 1539/ (uint)BigIntegerCalculator.BitsPerLimb; 1545size = BigIntegerCalculator.PowBound(power, 1); 1552BigIntegerCalculator.Pow( 1577firstTableStartIndex = BigIntegerCalculator.Pow3TableStartIndex; 1578firstPowerIndices = BigIntegerCalculator.Pow3TableIndices; 1579firstPowers = BigIntegerCalculator.Pow3Table; 1585firstTableStartIndex = BigIntegerCalculator.Pow5TableStartIndex; 1586firstPowerIndices = BigIntegerCalculator.Pow5TableIndices; 1587firstPowers = BigIntegerCalculator.Pow5Table; 1593? BigIntegerCalculator.Pow7TableStartIndex 1594: BigIntegerCalculator.Pow5TableStartIndex; 1596? BigIntegerCalculator.Pow7TableIndices 1597: BigIntegerCalculator.Pow5TableIndices; 1599? BigIntegerCalculator.Pow7Table 1600: BigIntegerCalculator.Pow5Table; 1604ulong firstBitLength = BigIntegerCalculator.GetPowBitLengthBounds( 1610ulong secondBitLength = BigIntegerCalculator.GetPowBitLengthBounds( 1617+ (uint)BigIntegerCalculator.BitsPerLimb - 1) / (uint)BigIntegerCalculator.BitsPerLimb) + 1); 1619+ (uint)BigIntegerCalculator.BitsPerLimb - 1) / (uint)BigIntegerCalculator.BitsPerLimb) + 1); 1622BigIntegerCalculator.Pow( 1631BigIntegerCalculator.Pow( 1639int firstLength = BigIntegerCalculator.ActualLength(firstBits); 1640int secondLength = BigIntegerCalculator.ActualLength(secondBits); 1642BigIntegerCalculator.Multiply( 1657BigIntegerCalculator.Pow(magnitude, power, bits); 1665int size = BigIntegerCalculator.PowBound(power, value._bits!.Length); 1668BigIntegerCalculator.Pow(value._bits, power, bits); 1849int bitsResult = BigIntegerCalculator.Compare(_bits, other._bits); 2217nuint highBitMask = (nuint)1 << (BigIntegerCalculator.BitsPerLimb - 1); 2274int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 2357BigIntegerCalculator.Add(rightBits, NumericsHelpers.Abs(leftSign), bits); 2368BigIntegerCalculator.Add(leftBits, NumericsHelpers.Abs(rightSign), bits); 2379BigIntegerCalculator.Add(rightBits, leftBits, bits); 2390BigIntegerCalculator.Add(leftBits, rightBits, bits); 2435BigIntegerCalculator.Subtract(rightBits, NumericsHelpers.Abs(leftSign), bits); 2446BigIntegerCalculator.Subtract(leftBits, NumericsHelpers.Abs(rightSign), bits); 2450else if (BigIntegerCalculator.Compare(leftBits, rightBits) < 0) 2455BigIntegerCalculator.Subtract(rightBits, leftBits, bits); 2466BigIntegerCalculator.Subtract(leftBits, rightBits, bits); 2480int commonOffset = BigIntegerCalculator.GetCommonLimbOffset(leftBits, rightBits); 2495BigIntegerCalculator.Add(reducedRight, reducedLeft, reducedBits); 2499BigIntegerCalculator.Add(reducedLeft, reducedRight, reducedBits); 2513int commonOffset = BigIntegerCalculator.GetCommonLimbOffset(leftBits, rightBits); 2522int compare = BigIntegerCalculator.Compare(reducedLeft, reducedRight); 2528BigIntegerCalculator.Subtract(large, small, bits.Slice(commonOffset, large.Length)); 2570if (bits.Length <= 64 / BigIntegerCalculator.BitsPerLimb) 2600int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 2708Debug.Assert((uint)bits.Length <= 64 / BigIntegerCalculator.BitsPerLimb); 2712if (BigIntegerCalculator.BitsPerLimb == 32 && bits.Length > 1) 2755if (bits.Length <= 64 / BigIntegerCalculator.BitsPerLimb) 2902if (bits.Length <= 64 / BigIntegerCalculator.BitsPerLimb) 3240return BitwiseOp<BigIntegerCalculator.BitwiseAndOp>(in left, in right, zLen); 3250return BitwiseOp<BigIntegerCalculator.BitwiseOrOp>(in left, in right, Math.Max(xLen, yLen) + 1); 3260return BitwiseOp<BigIntegerCalculator.BitwiseXorOp>(in left, in right, Math.Max(xLen, yLen) + 1); 3264where TOp : struct, BigIntegerCalculator.IBitwiseOp 3268BigIntegerCalculator.BitwiseOp<TOp>( 3297(int digitShift, int smallShift) = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb); 3312: bits[^1] >> (BigIntegerCalculator.BitsPerLimb - smallShift); 3340BigIntegerCalculator.LeftShiftSelf(zd, smallShift, out nuint carry); 3360: m >> (BigIntegerCalculator.BitsPerLimb - smallShift); 3411(int digitShift, int smallShift) = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb); 3442BigIntegerCalculator.RightShiftSelf(zd, smallShift, out nuint carry); 3479BigIntegerCalculator.Add(value._bits, 1, bits); 3488BigIntegerCalculator.Subtract(value._bits, 1, bits); 3514BigIntegerCalculator.Add(value._bits, 1, bits); 3522BigIntegerCalculator.Subtract(value._bits, 1, bits); 3543BigIntegerCalculator.Subtract(value._bits, 1, bits); 3552BigIntegerCalculator.Add(value._bits, 1, bits); 3610BigIntegerCalculator.Multiply(right, NumericsHelpers.Abs(leftSign), bits); 3621BigIntegerCalculator.Multiply(left, NumericsHelpers.Abs(rightSign), bits); 3630BigIntegerCalculator.Square(left, bits); 3641BigIntegerCalculator.Multiply(left, right, bits); 3674BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor._sign), quotient); 3691? BigIntegerCalculator.GetCommonLimbOffset(dividend._bits, divisor._bits) 3707BigIntegerCalculator.DivideSpecial(dividendBits, divisorBits, quotient); 3711BigIntegerCalculator.Divide(dividendBits, divisorBits, quotient); 3741nuint remainder = BigIntegerCalculator.Remainder(dividend._bits, NumericsHelpers.Abs(divisor._sign)); 3753? BigIntegerCalculator.GetCommonLimbOffset(dividend._bits, divisor._bits) 3769BigIntegerCalculator.RemainderSpecial(dividendBits, divisorBits, remainderBits); 3773BigIntegerCalculator.Remainder(dividendBits, divisorBits, remainderBits); 3880long bitLength = (long)bitsArrayLength * BigIntegerCalculator.BitsPerLimb - 4183BigIntegerCalculator.RightShiftSelf(zd, nuintSmallShift, out nuint carry); 4188BigIntegerCalculator.SwapUpperAndLower(zd, nuintDigitShift); 4192BigIntegerCalculator.LeftShiftSelf(zd, nuintSmallShift, out nuint carry); 4197BigIntegerCalculator.SwapUpperAndLower(zd, zd.Length - nuintDigitShift); 4211BigIntegerCalculator.RightShiftSelf(zd, smallShift32, out nuint carry); 4224BigIntegerCalculator.SwapUpperAndLower(words, effectiveDigitShift); 4234BigIntegerCalculator.LeftShiftSelf(zd, smallShift32, out _); 4249BigIntegerCalculator.SwapUpperAndLower(words, zWordCount - effectiveDigitShift); 4310&& (leadingZeroCount != bits.Length - 1 || bits[^1] != ((nuint)1 << (BigIntegerCalculator.BitsPerLimb - 1)))) 4328BigIntegerCalculator.RotateLeft(zd, rotateLeftAmount); 4371return checked((zeroLimbCount * BigIntegerCalculator.BitsPerLimb) 4401int result = (bits.Length - 1) * BigIntegerCalculator.BitsPerLimb; 4405result += BigIntegerCalculator.BitsPerLimb - BitOperations.LeadingZeroCount(bits[^1]); 4420result += BigIntegerCalculator.BitsPerLimb + 1 - BitOperations.LeadingZeroCount(~part); 4637? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value._sign | 1)) 4638: (BigInteger)(((long)value._bits.Length * BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount(value._bits[^1])); 6019(int digitShift, int smallShift) = Math.DivRem(shiftAmount, BigIntegerCalculator.BitsPerLimb); 6058nuint signBit = (nuint)1 << (BigIntegerCalculator.BitsPerLimb - 1); 6108BigIntegerCalculator.RightShiftSelf(zd, smallShift, out _);
System\Numerics\BigIntegerCalculator.SquMul.cs (5)
763BigIntegerCalculator.Square(p0, r0); 764BigIntegerCalculator.Square(p1, r1); 765BigIntegerCalculator.Square(pm1, rm1); 766BigIntegerCalculator.Square(pm2, rm2); 767BigIntegerCalculator.Square(pInf, rInf);