114 references to BigIntegerCalculator
System.Runtime.Numerics (114)
System\Number.BigInteger.cs (20)
442double digitRatio = 0.10381025297 * 32.0 / BigIntegerCalculator.BitsPerLimb; // log_{2^BitsPerLimb}(10) 474double digitRatio = 0.10381025297 * 32.0 / BigIntegerCalculator.BitsPerLimb; 479leading = leading.Slice(0, BigIntegerCalculator.ActualLength(leading)); 496base1E9 = base1E9.Slice(0, BigIntegerCalculator.ActualLength(base1E9)); 514double digitRatio = 0.10381025297 * 32.0 / BigIntegerCalculator.BitsPerLimb; 520ReadOnlySpan<nuint> buffer2 = buffer.Slice(0, BigIntegerCalculator.ActualLength(buffer)); 522BigIntegerCalculator.Multiply(buffer2, multiplier, bitsUpper); 528BigIntegerCalculator.AddSelf(bits, buffer.Slice(0, BigIntegerCalculator.ActualLength(buffer))); 876double digitRatio = 1.070328873472 * BigIntegerCalculator.BitsPerLimb / 32.0; 1032int ToStringNaiveThreshold = BigIntegerCalculator.DivideBurnikelZieglerThreshold; 1062while (bits.Length < powOfTen.Length + omittedLength || BigIntegerCalculator.Compare(bits.Slice(omittedLength), powOfTen) < 0) 1076BigIntegerCalculator.Divide(bits.Slice(omittedLength), powOfTen, upper, lower.Slice(omittedLength)); 1085lower.Slice(0, BigIntegerCalculator.ActualLength(lower)), 1096upper.Slice(0, BigIntegerCalculator.ActualLength(upper)), 1390BigIntegerCalculator.Square(src, dst); 1440return (MaxPartialDigits * (1 << index)) / BigIntegerCalculator.BitsPerLimb; 1473BigIntegerCalculator.Multiply(left, UInt32PowersOfTen[trailingZeroCount], bits.Slice(0, left.Length + 1)); 1511BigIntegerCalculator.Multiply(src, power, dst); 1529BigIntegerCalculator.Multiply(left, powersOfTen, bits2);
System\Numerics\BigInteger.cs (89)
38internal static int MaxLength => Array.MaxLength / BigIntegerCalculator.BitsPerLimb; 215int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 942BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor._sign), quotient, out nuint rest); 963BigIntegerCalculator.Divide(dividend._bits, divisor._bits, quotient, rest); 1054return BigIntegerCalculator.Gcd(NumericsHelpers.Abs(left._sign), NumericsHelpers.Abs(right._sign)); 1061? BigIntegerCalculator.Gcd(right._bits, NumericsHelpers.Abs(left._sign)) 1069? BigIntegerCalculator.Gcd(left._bits, NumericsHelpers.Abs(right._sign)) 1075return BigIntegerCalculator.Compare(left._bits, right._bits) < 0 1082Debug.Assert(BigIntegerCalculator.Compare(leftBits, rightBits) >= 0); 1089nuint temp = BigIntegerCalculator.Remainder(leftBits, rightBits[0]); 1090result = BigIntegerCalculator.Gcd(rightBits[0], temp); 1096BigIntegerCalculator.Remainder(leftBits, rightBits, bits); 1101result = BigIntegerCalculator.Gcd(left, right); 1108BigIntegerCalculator.Gcd(leftBits, rightBits, bits); 1138nuint bitsResult = trivialValue && trivialExponent ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) : 1139trivialValue ? BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent._bits!, NumericsHelpers.Abs(modulus._sign)) : 1140trivialExponent ? BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent._sign), NumericsHelpers.Abs(modulus._sign)) : 1141BigIntegerCalculator.Pow(value._bits!, exponent._bits!, NumericsHelpers.Abs(modulus._sign)); 1153BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), NumericsHelpers.Abs(exponent._sign), modulus._bits!, bits); 1157BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), exponent._bits!, modulus._bits!, bits); 1162BigIntegerCalculator.Pow(value._bits!, NumericsHelpers.Abs(exponent._sign), modulus._bits!, bits); 1166BigIntegerCalculator.Pow(value._bits!, exponent._bits!, modulus._bits!, bits); 1213int size = BigIntegerCalculator.PowBound(power, 1); 1216BigIntegerCalculator.Pow(NumericsHelpers.Abs(value._sign), power, bits); 1222int size = BigIntegerCalculator.PowBound(power, value._bits!.Length); 1225BigIntegerCalculator.Pow(value._bits, power, bits); 1406int bitsResult = BigIntegerCalculator.Compare(_bits, other._bits); 1774nuint highBitMask = (nuint)1 << (BigIntegerCalculator.BitsPerLimb - 1); 1831int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 1905BigIntegerCalculator.Add(rightBits, NumericsHelpers.Abs(leftSign), bits); 1916BigIntegerCalculator.Add(leftBits, NumericsHelpers.Abs(rightSign), bits); 1927BigIntegerCalculator.Add(rightBits, leftBits, bits); 1938BigIntegerCalculator.Add(leftBits, rightBits, bits); 1974BigIntegerCalculator.Subtract(rightBits, NumericsHelpers.Abs(leftSign), bits); 1985BigIntegerCalculator.Subtract(leftBits, NumericsHelpers.Abs(rightSign), bits); 1989else if (BigIntegerCalculator.Compare(leftBits, rightBits) < 0) 1994BigIntegerCalculator.Subtract(rightBits, leftBits, bits); 2005BigIntegerCalculator.Subtract(leftBits, rightBits, bits); 2048if (bits.Length <= 64 / BigIntegerCalculator.BitsPerLimb) 2078int bitsPerLimb = BigIntegerCalculator.BitsPerLimb; 2186Debug.Assert((uint)bits.Length <= 64 / BigIntegerCalculator.BitsPerLimb); 2190if (BigIntegerCalculator.BitsPerLimb == 32 && bits.Length > 1) 2233if (bits.Length <= 64 / BigIntegerCalculator.BitsPerLimb) 2380if (bits.Length <= 64 / BigIntegerCalculator.BitsPerLimb) 2718return BitwiseOp<BigIntegerCalculator.BitwiseAndOp>(in left, in right, zLen); 2728return BitwiseOp<BigIntegerCalculator.BitwiseOrOp>(in left, in right, Math.Max(xLen, yLen) + 1); 2738return BitwiseOp<BigIntegerCalculator.BitwiseXorOp>(in left, in right, Math.Max(xLen, yLen) + 1); 2742where TOp : struct, BigIntegerCalculator.IBitwiseOp 2746BigIntegerCalculator.BitwiseOp<TOp>( 2775(int digitShift, int smallShift) = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb); 2790: bits[^1] >> (BigIntegerCalculator.BitsPerLimb - smallShift); 2808BigIntegerCalculator.LeftShiftSelf(zd, smallShift, out nuint carry); 2828: m >> (BigIntegerCalculator.BitsPerLimb - smallShift); 2869(int digitShift, int smallShift) = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb); 2900BigIntegerCalculator.RightShiftSelf(zd, smallShift, out nuint carry); 2937BigIntegerCalculator.Add(value._bits, 1, bits); 2946BigIntegerCalculator.Subtract(value._bits, 1, bits); 2972BigIntegerCalculator.Add(value._bits, 1, bits); 2980BigIntegerCalculator.Subtract(value._bits, 1, bits); 3001BigIntegerCalculator.Subtract(value._bits, 1, bits); 3010BigIntegerCalculator.Add(value._bits, 1, bits); 3051BigIntegerCalculator.Multiply(right, NumericsHelpers.Abs(leftSign), bits); 3062BigIntegerCalculator.Multiply(left, NumericsHelpers.Abs(rightSign), bits); 3071BigIntegerCalculator.Square(left, bits); 3082BigIntegerCalculator.Multiply(left, right, bits); 3115BigIntegerCalculator.Divide(dividend._bits, NumericsHelpers.Abs(divisor._sign), quotient); 3135BigIntegerCalculator.Divide(dividend._bits, divisor._bits, quotient); 3164nuint remainder = BigIntegerCalculator.Remainder(dividend._bits, NumericsHelpers.Abs(divisor._sign)); 3178BigIntegerCalculator.Remainder(dividend._bits, divisor._bits, bits); 3281long bitLength = (long)bitsArrayLength * BigIntegerCalculator.BitsPerLimb - 3584BigIntegerCalculator.RightShiftSelf(zd, nuintSmallShift, out nuint carry); 3589BigIntegerCalculator.SwapUpperAndLower(zd, nuintDigitShift); 3593BigIntegerCalculator.LeftShiftSelf(zd, nuintSmallShift, out nuint carry); 3598BigIntegerCalculator.SwapUpperAndLower(zd, zd.Length - nuintDigitShift); 3612BigIntegerCalculator.RightShiftSelf(zd, smallShift32, out nuint carry); 3625BigIntegerCalculator.SwapUpperAndLower(words, effectiveDigitShift); 3635BigIntegerCalculator.LeftShiftSelf(zd, smallShift32, out _); 3650BigIntegerCalculator.SwapUpperAndLower(words, zWordCount - effectiveDigitShift); 3711&& (leadingZeroCount != bits.Length - 1 || bits[^1] != ((nuint)1 << (BigIntegerCalculator.BitsPerLimb - 1)))) 3729BigIntegerCalculator.RotateLeft(zd, rotateLeftAmount); 3765result += (uint)BigIntegerCalculator.BitsPerLimb; 3799int result = (bits.Length - 1) * BigIntegerCalculator.BitsPerLimb; 3803result += BigIntegerCalculator.BitsPerLimb - BitOperations.LeadingZeroCount(bits[^1]); 3818result += BigIntegerCalculator.BitsPerLimb + 1 - BitOperations.LeadingZeroCount(~part); 4035? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value._sign | 1)) 4036: (BigInteger)(((long)value._bits.Length * BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount(value._bits[^1])); 5417(int digitShift, int smallShift) = Math.DivRem(shiftAmount, BigIntegerCalculator.BitsPerLimb); 5456nuint signBit = (nuint)1 << (BigIntegerCalculator.BitsPerLimb - 1); 5506BigIntegerCalculator.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);