Ejemplo n.º 1
0
        public void generate_permute_monoid_returns_Unit()
        {
            var p = PermutationCompositionMonoid.PermutationIndexMonoidGenerator(6);

            Assert.That(p.Unit.SequenceEqual(new List <int>()
            {
                0, 1, 2, 3, 4, 5
            }));
        }
Ejemplo n.º 2
0
        public void permute_monoid_permutes_arrays()
        {
            int[] a = new int[] { 1, 3, 2, 5, 4, 0 };
            int[] b = new int[] { 5, 4, 2, 1, 3, 0 };

            var m = PermutationCompositionMonoid.PermutationIndexMonoidGenerator(6).Op(a, b);

            Assert.That(m.SequenceEqual(new List <int>()
            {
                4, 1, 2, 0, 3, 5
            }));
        }
Ejemplo n.º 3
0
        public void permute_with_inverse_returns_identity()
        {
            int[] a  = new int[] { 1, 3, 2, 5, 4, 0 };
            var   p  = PermutationCompositionMonoid.PermutationIndexMonoidGenerator(6);
            var   a2 = a;

            while (!p.Op(a2, a).SequenceEqual(p.Unit))
            {
                a2 = p.Op(a2, a).ToArray();
            }

            Assert.That(p.Op(a2, a).SequenceEqual(p.Unit));
        }