private void VerifyPartialResult(MpirRandom rnd, IntegerExpression expr, long expected) { rnd.Seed(123); using (var r = new HugeInt()) { r.Value = expr; Assert.AreEqual(expected.ToString(), r.ToString()); } }
private void VerifyPartialResult(MpirRandom rnd, FloatExpression expr, long expected) { rnd.Seed(123); using (var r = new HugeFloat()) { using (var exp = new HugeFloat(expected)) using (var epsilon = new HugeFloat("0.001")) { r.Value = expr; Assert.IsTrue(r - epsilon <exp && r + epsilon> exp, "Expected {0}, Actual {1}", exp, r); } } }
private void TestRandom(MpirRandom r, uint seed, Action <MpirRandom> assert) #endif { MpirRandom copy = null; for (var i = 0; i < 6; i++) { switch (i) { case 0: case 1: case 5: r.Seed(seed); break; case 2: using (var s = new HugeInt(seed)) r.Seed(s); break; case 3: using (var s = new HugeInt(seed)) r.Seed(s); copy = r.Copy(); break; case 4: r.Seed(seed); //todo r = copy; temporarily disabled copy tests due to MPIR bug break; } assert(r); } copy.Dispose(); }
private void TestRandom(MpirRandom r, uint seed, Action<MpirRandom> assert) #endif { MpirRandom copy = null; for (var i = 0; i < 6; i++) { switch (i) { case 0: case 1: case 5: r.Seed(seed); break; case 2: using (var s = new HugeInt(seed)) r.Seed(s); break; case 3: using (var s = new HugeInt(seed)) r.Seed(s); copy = r.Copy(); break; case 4: r.Seed(seed); //todo r = copy; temporarily disabled copy tests due to MPIR bug break; } assert(r); } copy.Dispose(); }
private void VerifyPartialResult(MpirRandom rnd, FloatExpression expr, long expected) { rnd.Seed(123); using (var r = new HugeFloat()) { using (var exp = new HugeFloat(expected)) using (var epsilon = new HugeFloat("0.001")) { r.Value = expr; Assert.IsTrue(r - epsilon < exp && r + epsilon > exp, "Expected {0}, Actual {1}", exp, r); } } }