示例#1
0
 public void PolyGF2GetAll()
 {
     foreach (var p in PolyGF2.GetAll().Take(100))
     {
         Trace.WriteLine(p);
     }
 }
示例#2
0
        public void PolyGF2Multiply()
        {
            var ps = PolyGF2.GetAll().Take(1000).ToArray();
            var g  = new Generator("PolyGF2Multiply");

            for (int i = 0; i < 100; i++)
            {
                var p = ps[g.Int32(1000)];
                var q = ps[g.Int32(1000)];
                var z = p * q;
                Assert.AreEqual(p.Degree + q.Degree, z.Degree, $"{z} = ({p})({q})");
            }
        }
示例#3
0
        public void PolyGF2DivRem()
        {
            var ps = PolyGF2.GetAll().Take(1000).ToArray();
            var g  = new Generator("PolyGF2DivRem");

            for (int i = 0; i < 100; i++)
            {
                var     p = ps[g.Int32(1000)];
                var     q = ps[g.Int32(1000)];
                PolyGF2 r;
                var     d = PolyGF2.DivRem(p, q, out r);
                Assert.AreEqual(p, d * q + r);
            }
        }
示例#4
0
        public void PolyGF2DivNoRem()
        {
            var ps = PolyGF2.GetAll().Take(1000).ToArray();
            var g  = new Generator("PolyGF2DivNoRem");

            for (int i = 0; i < 100; i++)
            {
                var     p = ps[g.Int32(1000)];
                var     q = ps[g.Int32(1000)];
                var     z = p * q;
                PolyGF2 r;
                var     d = PolyGF2.DivRem(z, p, out r);
                Assert.IsTrue(r.IsZero);
                Assert.AreEqual(q, d);
                d = PolyGF2.DivRem(z, q, out r);
                Assert.IsTrue(r.IsZero);
                Assert.AreEqual(p, d);
            }
        }