public Group <Permutation <U> > ActionGroup <U>(Func <T, U, U> action, FiniteSet <U> set) where U : IEquatable <U> { return(new Group <Permutation <U> >( new FiniteSet <Permutation <U> >(_set.Select(g => Permutation <U> .FromFunction(set, x => action(g, x)))), Permutation <U> .Product, Permutation <U> .Inverse, Permutation <U> .Identity(set) )); }
public Group <Permutation <T> > InnerAutomorphismGroup() { return(new Group <Permutation <T> >( new FiniteSet <Permutation <T> >(_set.Select(g => Permutation <T> .FromFunction(_set, x => _product(_inverse(g), _product(x, g))))), Permutation <T> .Product, Permutation <T> .Inverse, Permutation <T> .Identity(_set) )); }
/// <summary> /// Returns a permutation group on {1,2,...,|G|} isomorphic to this group G. /// </summary> /// <param name="bijection">A bijection from G to {1,2,...,|G|}.</param> /// <param name="bijectionInverse">The inverse of <paramref name="bijection"/>.</param> /// <param name="isomorphism">An isomorphism from G to the permutation group.</param> public Group <Permutation <int> > ToPermutationGroup(Func <T, int> bijection, Func <int, T> bijectionInverse, out Func <T, Permutation <int> > isomorphism) { if (bijectionInverse == null) { bijectionInverse = Discrete.Inverse(_set, bijection); } var set = new FiniteSet <int>(Enumerable.Range(1, _set.Size)); isomorphism = x => Permutation <int> .FromFunction(set, k => bijection(_product(x, bijectionInverse(k)))); var permutations = new FiniteSet <Permutation <int> >(_set.Select(isomorphism)); return(new Group <Permutation <int> >(permutations, Permutation <int> .Product, Permutation <int> .Inverse, Permutation <int> .Identity(set))); }
public static IEnumerable <Permutation <T> > SetPermutations(FiniteSet <T> set) { int n = set.Size; Dictionary <int, T> map = new Dictionary <int, T>(); Dictionary <T, int> inverseMap = new Dictionary <T, int>(); int[] permutation = new int[n]; int index = 0; foreach (T element in set) { map.Add(index, element); inverseMap.Add(element, index); permutation[index] = index; index++; } yield return(Identity(set)); // Generate permutations in lexicographic order. while (true) { int k; bool foundK = false; int l; int temp; for (k = n - 2; k >= 0; k--) { if (permutation[k] < permutation[k + 1]) { foundK = true; break; } } if (!foundK) { break; } for (l = n - 1; l >= 0; l--) { if (permutation[k] < permutation[l]) { break; } } temp = permutation[k]; permutation[k] = permutation[l]; permutation[l] = temp; for (int i = 0; i < (n - (k + 1)) / 2; i++) { temp = permutation[k + 1 + i]; permutation[k + 1 + i] = permutation[n - i - 1]; permutation[n - i - 1] = temp; } yield return(Permutation <T> .FromFunction(set, x => map[permutation[inverseMap[x]]])); } }