K i8VddlmZddlmZddlmZmZmZmZddl m Z Gdde Z y) ) CartanType)fac)MatrixeyeRationaligcd)Atomc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) WeylGroupa\ For each semisimple Lie group, we have a Weyl group. It is a subgroup of the isometry group of the root system. Specifically, it's the subgroup that is generated by reflections through the hyperplanes orthogonal to the roots. Therefore, Weyl groups are reflection groups, and so a Weyl group is a finite Coxeter group. cPtj|}t||_|SN)r __new__r cartan_type)cls cartantypeobjs b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/liealgebras/weyl_group.pyrzWeylGroup.__new__s!ll3$Z0 c|jj}g}td|dzD]!}dt|z}|j |#|S)a This method creates the generating reflections of the Weyl group for a given Lie algebra. For a Lie algebra of rank n, there are n different generating reflections. This function returns them as a list. Examples ======== >>> from sympy.liealgebras.weyl_group import WeylGroup >>> c = WeylGroup("F4") >>> c.generators() ['r1', 'r2', 'r3', 'r4'] rr)rrankrangestrappend)selfn generatorsi reflections rrzWeylGroup.generatorssY    ! ! # q!A# *ASVJ   j ) *rc|jj}|jjdk(rt|dzS|jjdvrt|d|zzS|jjdk(rt|d|dz zzS|jjdk(r|dk(ry|d k(ry |d k(ry |jjd k(ry|jjdk(ryy)a} This method returns the order of the Weyl group. For types A, B, C, D, and E the order depends on the rank of the Lie algebra. For types F and G, the order is fixed. Examples ======== >>> from sympy.liealgebras.weyl_group import WeylGroup >>> c = WeylGroup("D4") >>> c.group_order() 192.0 ArBCDEiiL,i@)FiG N)rrseriesrrrs r group_orderzWeylGroup.group_order.s    ! ! #    " "c )qs8O    " "j 0q61a4=    " "c )q61qs8$ $    " "c )AvAvAv    " "c )    " "c ) *rc |jj}|jjdk(r&dt|dzzdzt|dzzdzS|jjdvrdtd|zzdzS|jjd k(rd t|zd zS|jjd k(r|d k(ry|dk(ry|dk(ry|jjdk(ry|jjdk(ryy)z This method returns some general information about the Weyl group for a given Lie algebra. It returns the name of the group and the elements it acts on, if relevant. r"Srz : the symmetric group acting on z elements.r#z$The hyperoctahedral group acting on r&r'zThe symmetry group of the z-dimensional demihypercube.r(r)z%The symmetry group of the 6-polytope.r*z%The symmetry group of the 7-polytope.r+z%The symmetry group of the 8-polytope.r,z7The symmetry group of the 24-cell, or icositetrachoron.r-zFD6, the dihedral group of order 12, and symmetry group of the hexagon.N)rrr/rr0s r group_namezWeylGroup.group_nameTs    ! ! #    " "c )s1Q3x<"DDs1Q3xOR^^ ^    " "j 09C!HD|S S    " "c )/#a&8;XX X    " "c )Av>Av>Av>    " "c )L    " "c )[ *rc|jj}|jjdk(rQ|j|}d}|t |dzk7r+||j|z}|dz }|t |dzk7r+|S|jjdk(rK|j|}d}|t |k7r(||j|z}|dz }|t |k7r(|S|jjdk(rK|j|}d}|t dk7r(||j|z}|dz }|t dk7r(|S|jjdk(rt |}|ddd}|j |}|j ||k7r(|j |}|}|j ||k7r(t|d zdk(ry t|d k(ryt|dk(ry t|d z}d |zt|d z }||z }|S|jjd k(rK|j|}d}|t d k7r(||j|z}|dz }|t d k7r(|S|jjdvrK|j|}d}|t |k7r(||j|z}|dz }|t |k7r(|Sy)aZ This method returns the order of a given Weyl group element, which should be specified by the user in the form of products of the generating reflections, i.e. of the form r1*r2 etc. For types A-F, this method current works by taking the matrix form of the specified element, and then finding what power of the matrix is the identity. It then returns this power. Examples ======== >>> from sympy.liealgebras.weyl_group import WeylGroup >>> b = WeylGroup("B4") >>> b.element_order('r1*r4*r2') 4 r"rr'r(r+r-Nr&rr)r,r#) rrr/ matrix_formrlistdelete_doubleslenr ) rweyleltraorderelts reflectionsmlcms r element_orderzWeylGroup.element_orderts $    ! ! #    " "c )  )AEs1Q3x-T%%g.. s1Q3x-L    " "c )  )AEs1v+T%%g.. s1v+L    " "c )  )AEs1v+T%%g.. s1v+L    " "c )=Dqt!t*K##K0A%%a(A-''* %%a(A-;!#q([!Q&{#q(K(A-Aq541:-Ca     " "c )  )AEs1v+T%%g.. s1v+L    " "j 0  )AEs1v+T%%g.. s1v+L 1rc|d}t|}|D])}|t|dz kr||dz|k(r||=||=|dz }+|S)z This is a helper method for determining the order of an element in the Weyl group of G2. It takes a Weyl element and if repeated simple reflections in it, it deletes them. rr)r9r;)rr@countercopyelts rr:zWeylGroup.delete_doublessa K  CT1$! $+W W qLG   rc6t|}|ddd}|jj}|jjdk(r]t |dz}|D]H}t |}t |dz}d||dz |dz f<d||dz |f<d|||dz f<d|||f<||z}J|S|jjdk(rt |}|D]}t |}t |}||kr.d||dz |dz f<d||dz |f<d|||dz f<d|||f<||z}Ld||dz |dz f<d||dz |dz f<d||dz |dz f<d||dz |dz f<||z}|S|jjd k(rt d}|D]}t |}|dk(rt gd gd gd g} || z}-t tddtddtddgtddtddtddgtddtddtddgg} || z}|S|jjd k(rKt d}|D]8}t |}|dk(rt gdgdgdgdg}||z}1|dk(rt gdgdgdgdg}||z}S|dk(rt gdgdgdgdg}||z}ut tddtddtddtddgtddtddtddtddgtddtddtddtddgtddtddtddtddgg}||z};|S|jjdk(rpt d}|D]]}t |}|dk(rt tddtddtddtddtddtddtddtddgtddtddtddtddtddtddtddtddgtddtddtddtddtddtddtddtddgtddtddtddtddtddtddtddtddgtddtddtddtddtddtddtddtddgtddtddtddtddtddtddtddtddgtddtddtddtddtddtddtddtddgtddtddtddtddtddtddtddtddgg}||z}|dk(r&t d}d|d<d|d<d|d<d|d<||z}t d}d||dz |dz f<d||dz |dz f<d||dz |dz f<d||dz |dz f<||z}`|S|jjdvrst |}|D]a}t |}t |}|dk(r d|d<||z})d||dz |dz f<d||dz |dz f<d||dz |dz f<d||dz |dz f<||z}c|Sy)a This method takes input from the user in the form of products of the generating reflections, and returns the matrix corresponding to the element of the Weyl group. Since each element of the Weyl group is a reflection of some type, there is a corresponding matrix representation. This method uses the standard representation for all the generating reflections. Examples ======== >>> from sympy.liealgebras.weyl_group import WeylGroup >>> f = WeylGroup("F4") >>> f.matrix_form('r2*r3') Matrix([ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, -1], [0, 0, 1, 0]]) rNr6r"rr'r&r-)rrr)rrr)rrrr,r7)rrrr)rrrr)rrrr)rrrr)rrrrIr(r+)rr)rr)rr)rrr#)r9rrr/rintrr) rr<r?r@r matrixformrGr=matgen1gen2s rr8zWeylGroup.matrix_forms),G}14a4j    ! ! #    " "c )QqSJ" "H!A#h !AaC1H AaCF AqsF AqD c!  "     " "c )QJ" &H!fq5$%C!QqSM"#C!QK"#C1Q3K !C1I#%J$&C!QqSM$%C!QqSM$&C!QqSM$%C!QqSM#%J &     " "c )QJ" 'H6!9i"CDD$&J!HQNHQNHRQRO#T$,QNHROXaQR^#T$,ROXa^XaQR^#T#VWD$&J '     " "c )QJ" &H6 , lL!YZC#%J!V , lL!YZC#%J!V , lM!Z[C#%J!8Aq>8Aq>8Aq>S[\]_`Sa"b!!Q!Q"a(SUWX/Z!!Q"a(1a.(SUWX/Z!!Q"a(2q/8TUWX>Z"\]C#%J# &$     " "c )QJ"! &H6 8Aq>8Aq>8Aq>S[\]_`Sa AAAQSUV#Y!!Q!Q"a(SUWX/$ROXb!_hq!nhWY[\o_!!Q"a(1a.(SUWX/ Q"a(2q/8TUWX>[!!Q"a(2q/8TUWX> Q"a(2q/8TUWX>[!!Q"a(2q/8TVXY? AQ"a(STVW.Z!!Q"a(2q/8TVXY? Q!Q"a(STVW.Z!!Q"a(2q/8TVXY? Q"a(2q/8TUWX>[!!Q"a(2q/8TVXY? Q"a(2q/8TUWX>["\]C #%J!Va&C !CI "CI "CI !CI#%Ja&C$%C!QqSM$%C!QqSM$%C!QqSM$%C!QqSM#%JC! &D     " "j 0QJ" &H!f6 "CI#%J()CAq1u %$%C!QqSM()CAq1u %'(C1a!e $#%J &  1rc (|jj}|jjdvr|jjS|jjdvrOdj dt d|Ddz}|dj dt d|dzDz }|S|jjd k(r)d }|dj d t dd Dz }|S|jjd k(rd}|Sy)aL This method returns the Coxeter diagram corresponding to a Weyl group. The Coxeter diagram can be obtained from a Lie algebra's Dynkin diagram by deleting all arrows; the Coxeter diagram is the undirected graph. The vertices of the Coxeter diagram represent the generating reflections of the Weyl group, $s_i$. An edge is drawn between $s_i$ and $s_j$ if the order $m(i, j)$ of $s_is_j$ is greater than two. If there is one edge, the order $m(i, j)$ is 3. If there are two edges, the order $m(i, j)$ is 4, and if there are three edges, the order $m(i, j)$ is 6. Examples ======== >>> from sympy.liealgebras.weyl_group import WeylGroup >>> c = WeylGroup("B3") >>> print(c.coxeter_diagram()) 0---0===0 1 2 3 )r"r'r(r#z---c3 K|]}dyw)0N.0rs r z,WeylGroup.coxeter_diagram..s7ac7s rz===0 z c32K|]}t|ywrrrTs rrVz,WeylGroup.coxeter_diagram..s=!s1v=r,z0---0===0---0 c32K|]}t|ywrrXrTs rrVz,WeylGroup.coxeter_diagram..s;!s1v;rYr-u0≡≡≡0 1 2N)rrr/dynkin_diagramjoinr)rrdiags rcoxeter_diagramzWeylGroup.coxeter_diagramos(    ! ! #    " "o 5##224 4    " "j 0::75A;77(BD EJJ=uQ!}== =DK    " "c )$D EJJ;uQ{;; ;DK    " "c )'DK *rN) __name__ __module__ __qualname____doc__rrr1r4rCr:r8r_rSrrr r s6 ,$L\@Qf&Qj$rr N) rrmpmathrsympy.core.backendrrrr sympy.core.basicr r rSrrrgs$$::!KKr