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