Source code for sympy.combinatorics.group_constructs

[docs]defDirectProduct(*groups):""" Returns the direct product of several groups as a permutation group. This is implemented much like the __mul__ procedure for taking the direct product of two permutation groups, but the idea of shifting the generators is realized in the case of an arbitrary number of groups. A call to DirectProduct(G1, G2, ..., Gn) is generally expected to be faster than a call to G1*G2*...*Gn (and thus the need for this algorithm). Examples ======== >>> from sympy.combinatorics.group_constructs import DirectProduct >>> from sympy.combinatorics.named_groups import CyclicGroup >>> C = CyclicGroup(4) >>> G = DirectProduct(C,C,C) >>> G.order() 64 See Also ======== __mul__ """degrees=[]gens_count=[]total_degree=0total_gens=0forgroupingroups:current_deg=group.degreecurrent_num_gens=len(group.generators)degrees.append(current_deg)total_degree+=current_deggens_count.append(current_num_gens)total_gens+=current_num_gensarray_gens=[]foriinrange(total_gens):array_gens.append(range(total_degree))current_gen=0current_deg=0foriinxrange(len(gens_count)):forjinxrange(current_gen,current_gen+gens_count[i]):gen=((groups[i].generators)[j-current_gen]).array_formarray_gens[j][current_deg:current_deg+degrees[i]]=\
[x+current_degforxingen]current_gen+=gens_count[i]current_deg+=degrees[i]perm_gens=uniq([_af_new(list(a))forainarray_gens])returnPermutationGroup(perm_gens,dups=False)