public void SmallLargeCompareWithClassic() { IntX x = new IntX(GetAllOneDigits(50000), false); IntX y = new IntX(GetAllOneDigits(512), false); IntX classic = IntX.Multiply(x, y, MultiplyMode.Classic); IntX fht = IntX.Multiply(x, y, MultiplyMode.AutoFht); Assert.IsTrue(classic == fht); }
public static Object Solve() { var diameter = FibonacciSequence.ItemsX.Take(1000).Sum(); var x = IntX.Multiply(diameter, 314159265359, MultiplyMode.Classic); var y = IntX.Divide(x, 100000000000, DivideMode.Classic); return(y); }
public static DecimalX Calculate(int numberOfDigitsRequired) { int max = numberOfDigitsRequired + 8; // To be safe, compute 8 extra digits, to be dropped at end. The 8 is arbitrary var a = IntX.Multiply(InverseTan(5, max), new IntX(16), MultiplyMode.AutoFht); //16 x arctan(1/5) var b = IntX.Multiply(InverseTan(239, max), new IntX(4), MultiplyMode.AutoFht); //4 x arctan(1/239) IntX pi = a - b; return(new DecimalX( IntX.Divide(pi, IntX.Pow(10, (uint)8), DivideMode.AutoNewton) , IntX.Pow(10, (uint)numberOfDigitsRequired, MultiplyMode.AutoFht))); }
private static IntX GetTenToPowerOfNumberOfDigitsRequired(int numberOfDigitsRequired) { var tenToNumberOfDigitsRequired = new IntX(1); // The following loop computes 10^numberOfDigitsRequired for (var i = 0; i < numberOfDigitsRequired; i++) { tenToNumberOfDigitsRequired = IntX.Multiply(tenToNumberOfDigitsRequired, new IntX(10), MultiplyMode.AutoFht); } return(tenToNumberOfDigitsRequired); }
public void CompareWithClassicRandom() { TestHelper.Repeat( RandomRepeatCount, delegate { IntX x = new IntX(GetRandomDigits(), false); IntX classic = IntX.Multiply(x, x, MultiplyMode.Classic); IntX fht = IntX.Multiply(x, x, MultiplyMode.AutoFht); Assert.IsTrue(classic == fht); }); }
public void CompareWithClassic() { TestHelper.Repeat( RepeatCount, delegate { IntX x = new IntX(GetAllOneDigits(_length), true); IntX classic = IntX.Multiply(x, x, MultiplyMode.Classic); IntX fht = IntX.Multiply(x, x, MultiplyMode.AutoFht); Assert.IsTrue(classic == fht); _length += LengthIncrement; }); }
public void Multiply128BitNumbers() { IntX int1 = new IntX(new uint[] { 47668, 58687, 223234234, 42424242 }, false); IntX int2 = new IntX(new uint[] { 5674356, 34656476, 45667, 678645646 }, false); Stopwatch stopwatch = Stopwatch.StartNew(); TestHelper.Repeat( 100000, delegate { IntX.Multiply(int1, int2, MultiplyMode.Classic); } ); stopwatch.Stop(); Console.WriteLine(stopwatch.ElapsedMilliseconds); }