public static bool IsGeneratingSetOf <T>(this IEnumerable <T> collection, IFiniteGroup <T> group)
     where T : IFiniteGroupElement <T>, new()
 {
     return(!ReferenceEquals(collection, null) &&
            !ReferenceEquals(group, null) &&
            group.IsSubsetOf(CreateGroup <T>(collection)));
 }
        public static IFiniteGroup <T> CreateGroup <T>(this IEnumerable <T> collection)
            where T : IFiniteGroupElement <T>, new()
        {
            List <T> list = new List <T>();

            list.Add(new T());
            if (!ReferenceEquals(collection, null))
            {
                foreach (T a in collection)
                {
                    if (!list.Contains(a))
                    {
                        list.Add(a);
                    }
                }
                int i = 1, count;
                do
                {
                    for (count = list.Count; i < count; ++i)
                    {
                        T a = list[i];
                        for (int j = 1; j < count; ++j)
                        {
                            T b = list[j], c;
                            if (!list.Contains(c = a.Add(b)))
                            {
                                list.Add(c);
                            }
                            if (!list.Contains(c = b.Add(a)))
                            {
                                list.Add(c);
                            }
                        }
                    }
                } while(count < list.Count);
            }
            IFiniteGroup <T> group = ToFiniteGroup <T>(list);

            list[0] = group.IdentityElement;
            return(group);
        }
Пример #3
0
 internal static IFiniteSet <T> ToFiniteSet <T>(this IFiniteGroup <T> collection)
     where T : IFiniteGroupElement <T>, new()
 {
     return(ReferenceEquals(collection, null) ?
            null : new InternalGroup <T>(collection));
 }
Пример #4
0
 internal InternalGroup(IFiniteGroup <T> collection) : base(collection)
 {
 }
Пример #5
0
 static Polygon120()
 {
     AllValues = new DihedralGroupD120();
 }