Exemplo n.º 1
0
        private static void quotiendFieldTest()
        {
            QuotientField <long> qf = new QuotientField <long>(new ZnRing(5));

            // Console.WriteLine(qf.Prod(new Tuple<long, long>(1, 1), new Tuple<long, long>(1, 2)));

            foreach (Tuple <long, long> item1 in qf.GetItems())
            {
                // Console.Write("({0},{1}) ", item1.Item1, item1.Item2);
                foreach (Tuple <long, long> item2 in qf.GetItems())
                {
                    Tuple <long, long> prod = qf.Prod(item1, item2);
                    Console.Write(prod);
                }
                Console.WriteLine();
            }

            ZnRing r = new ZnRing(5);

            foreach (long item1 in r)
            {
                // Console.Write("({0},{1}) ", item1.Item1, item1.Item2);
                foreach (long item2 in r)
                {
                    long prod = r.Prod(item1, item2);
                    Console.Write("{0} ", prod);
                }
                Console.WriteLine();
            }
        }
Exemplo n.º 2
0
        public void TestInverse()
        {
            SlowOperatorBasedField<double> rationalField = new SlowOperatorBasedField<double>();

            PolynomialOverFieldRing<double> rationalPolynomialRing = new PolynomialOverFieldRing<double>(rationalField);

            IField<Polynomial<double>> rationalWithSqrt2Ring =
                new QuotientField<Polynomial<double>>
                    (new PrincipalIdeal<Polynomial<double>>
                         (rationalPolynomialRing,
                          new Polynomial<double>(new double[] {-2, 0, 1}, rationalField)));

            var sqrt2 = rationalField.CreateMonomial(1, 1);

            var number = rationalWithSqrt2Ring.Add(sqrt2, rationalWithSqrt2Ring.Identity);

            var result = rationalWithSqrt2Ring.Inverse(number);

            Polynomial<double> inverse = rationalWithSqrt2Ring.Add(sqrt2,
                                                                   rationalWithSqrt2Ring.Negative(
                                                                       rationalWithSqrt2Ring.Identity));

            Assert.IsTrue(rationalWithSqrt2Ring.Comparer.Equals
                              (result,
                               inverse));
        }