예제 #1
0
 public void PolyGF2Primitive()
 {
     foreach (var p in PolyGF2.GetAllPrimitive().Take(100))
     {
         Trace.WriteLine(p);
     }
 }
예제 #2
0
 public void PolyGF2Irreducible()
 {
     foreach (var p in PolyGF2.GetAllIrreducible().Take(1000))
     {
         Trace.WriteLine(p);
     }
 }
예제 #3
0
        public void PolyGF2SmallIrreduciblesCheck()
        {
            var p1 = PolyGF2.GetAllIrreducible().Take(1000).GetEnumerator();
            var p2 = PolyGF2.SmallIrreducibles().Take(1000).GetEnumerator();

            while (p1.MoveNext() && p2.MoveNext())
            {
                Assert.AreEqual(p1.Current, p2.Current);
            }
        }
예제 #4
0
        public void SobolCoefficients()
        {
            Trace.WriteLine("s\ta\tP");

            foreach (var p in PolyGF2.GetAllPrimitive().Take(100))
            {
                var a = p.GetCode();
                a  ^= 1ul << p.Degree;
                a >>= 1;
                Trace.WriteLine($"{p.Degree}\t{a}\t{p}");
            }
        }
예제 #5
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})");
            }
        }
예제 #6
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);
            }
        }
예제 #7
0
        public void PolyGF2SmallIrreducibles()
        {
            var last = 0UL;
            int len  = 0;

            foreach (var p in PolyGF2.GetAllIrreducible().Take(8192))
            {
                var c = p.GetCode();
                var s = ((int)(c - last) / 2 - 1).ToString() + ",";
                if (len + s.Length > 100)
                {
                    Trace.WriteLine(""); len = 0;
                }
                Trace.Write(s);
                len += s.Length;
                last = c;
            }
        }
예제 #8
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);
            }
        }