Beispiel #1
0
        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());
            }
        }
Beispiel #2
0
        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);
                    }
            }
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        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();
        }
Beispiel #5
0
        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());
            }
        }
Beispiel #6
0
        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);
                }
            }
        }