U
    —9%eå  ã                   @   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 ‰ q†t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   úc/var/www/html/Darija-Ai-API/env/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   