U
    L?h                     @   s6   d dl mZ d dlmZ d dlmZ ejZdd ZdS )    )PermutationGroup)Permutation)uniqc                     s  g }g }d}d}| D ]8}|j  t|j}|  | 7 }|| ||7 }qg }t|D ]}|tt| qZd}	d tt|D ]n}t|	|	||  D ]>}
| | j|
|	  j} fdd|D ||
   ||  < q|	|| 7 }	 || 7  qttdd |D }t|ddS )a8  
    Returns the direct product of several groups as a permutation group.

    Explanation
    ===========

    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
    ========

    sympy.combinatorics.perm_groups.PermutationGroup.__mul__

    r   c                    s   g | ]}|  qS  r   ).0xZcurrent_degr   V/var/www/html/venv/lib/python3.8/site-packages/sympy/combinatorics/group_constructs.py
<listcomp>9   s     z!DirectProduct.<locals>.<listcomp>c                 S   s   g | ]}t t|qS r   )_af_newlist)r   ar   r   r	   r
   <   s     F)Zdups)	Zdegreelen
generatorsappendranger   Z
array_formr   r   )groupsdegreesZ
gens_countZtotal_degreeZ
total_gensgroupZcurrent_num_gensZ
array_gensiZcurrent_genjgenZ	perm_gensr   r   r	   DirectProduct   s2    



r   N)Zsympy.combinatorics.perm_groupsr   Z sympy.combinatorics.permutationsr   Zsympy.utilities.iterablesr   r   r   r   r   r   r	   <module>   s   