o
    *ήc4&                     @   s0   d dl mZ ddlmZmZ G dd deZdS )   )Standard_Cartan    )eyeRationalc                   @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )TypeEc                 C   s&   |dk s|dkrt dt| d|S )N      zInvalid value of nE)
ValueErrorr   __new__)clsn r   ?/tmp/pip-target-vg8gfxp4/lib/python/sympy/liealgebras/type_e.pyr      s   zTypeE.__new__c                 C   s   dS )zDimension of the vector space V underlying the Lie algebra

        Examples
        ========

        >>> from sympy.liealgebras.cartan_type import CartanType
        >>> c = CartanType("E6")
        >>> c.dimension()
        8
        r   r   )selfr   r   r   	dimension   s   zTypeE.dimensionc                 C   s   dgd }d||< d||< |S )z
        This is a method just to generate roots
        with a -1 in the ith position and a 1
        in the jth position.

        r   r   r   r   )r   ijrootr   r   r   
basic_root   s   
zTypeE.basic_rootc                 C   s   | j }|dkrdgd }d|d< d|d< |S |dkr)dgd }d|d< d|d< |S |dv r5|d	kr5td
|dkrA|dkrAtd| |d |d S )a  
        Every lie algebra has a unique root system.
        Given a root system Q, there is a subset of the
        roots such that an element of Q is called a
        simple root if it cannot be written as the sum
        of two elements in Q.  If we let D denote the
        set of simple roots, then it is clear that every
        element of Q can be written as a linear combination
        of elements of D with all coefficients non-negative.

        This method returns the ith simple root for E_n.

        Examples
        ========

        >>> from sympy.liealgebras.cartan_type import CartanType
        >>> c = CartanType("E6")
        >>> c.simple_root(2)
        [1, 1, 0, 0, 0, 0, 0, 0]
        r   g      r   g      ?r         )r   r   r   zE6 only has six simple roots!zE7 has only 7 simple roots!   )r   r
   r   )r   r   r   r   r   r   r   simple_root'   s    

zTypeE.simple_rootc              
   C   s  | j }|dkri }d}t|d D ].}t|d |d D ]"}|d7 }| ||}|||< |d7 }| ||}d||< |||< qqtddtddtddtddtddtddtddtddg}tddD ]o}tddD ]g}tddD ]_}	tddD ]W}
tddD ]O}|| |	 |
 | d dkr|d7 }|dkrtdd|d< |dkrtdd|d< |	dkrtdd|d< |
dkrtdd|d< |dkrtdd|d< |||< qq|quqnqg|S |dkri }d}t|d D ].}t|d |d D ]"}|d7 }| ||}|||< |d7 }| ||}d||< |||< qq|d7 }g d	||< tddtddtddtddtddtddtddtddg}tddD ]}tddD ]}tddD ]}	tddD ]v}
tddD ]m}tddD ]d}|| |	 |
 | | d dkr|d7 }|dkrtdd|d< |dkrtdd|d< |	dkrtdd|d< |
dkrtdd|d< |dkrtdd|d< |dkrtdd|d
< |||< qkqdq]qVqOqH|S |dkri }d}t|D ].}t|d |D ]#}|d7 }| ||}|||< |d7 }| ||}d||< |||< qqtddtddtddtddtddtddtddtddg}tddD ]}tddD ]}tddD ]}	tddD ]}
tddD ]}tddD ]{}tddD ]r}|| |	 |
 | | | d dkr|d7 }|dkrtdd|d< |dkrtdd|d< |	dkrtdd|d< |
dkrtdd|d< |dkrtdd|d< |dkrtdd|d
< |dkrtdd|d< |||< qiqbq[qTqMqFq?|S dS )a  
        This method generates all the positive roots of
        A_n.  This is half of all of the roots of E_n;
        by multiplying all the positive roots by -1 we
        get the negative roots.

        Examples
        ========

        >>> from sympy.liealgebras.cartan_type import CartanType
        >>> c = CartanType("A3")
        >>> c.positive_roots()
        {1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 3: [1, 0, 0, -1], 4: [0, 1, -1, 0],
                5: [0, 1, 0, -1], 6: [0, 0, 1, -1]}
        r   r   r   r   r   r      r   )r   r   r   r   r   r   r   r      r   N)r   ranger   r   )r   r   posrootskr   r   r   abcdefgr   r   r   positive_rootsO   s  
(	

	("






(	&






zTypeE.positive_rootsc                 C   .   | j }|dkr	dS |dkrdS |dkrdS dS )z:
        Returns the total number of roots of E_n
        r   H   r   ~   r      Nr   r   r   r   r   r   roots      zTypeE.rootsc                 C   s   | j }dt| }d}||d k r+d|||d f< d|||d f< |d7 }||d k sd |d< |d< d |d< |d< d|d	< d||d |d f< |S )
a9  
        Returns the Cartan matrix for G_2
        The Cartan matrix matrix for a Lie algebra is
        generated by assigning an ordering to the simple
        roots, (alpha[1], ...., alpha[l]).  Then the ijth
        entry of the Cartan matrix is (<alpha[i],alpha[j]>).

        Examples
        ========

        >>> from sympy.liealgebras.cartan_type import CartanType
        >>> c = CartanType('A4')
        >>> c.cartan_matrix()
        Matrix([
        [ 2, -1,  0,  0],
        [-1,  2, -1,  0],
        [ 0, -1,  2, -1],
        [ 0,  0, -1,  2]])


        r   r   r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   mr   r   r   r   cartan_matrix   s   zTypeE.cartan_matrixc                 C   r(   )zE
        Returns the number of independent generators of E_n
        r   N   r      r      Nr,   r-   r   r   r   basis
  r/   zTypeE.basisc              	   C   sz   | j }dtd d }|d7 }|d7 }|d7 }|ddd td	|D d 7 }|d
ddd td|d	 D  7 }|S )Nz        r   
z
        0
z
        |
z---c                 s   s    | ]}d V  qdS )0Nr   .0r   r   r   r   	<genexpr>  s    z'TypeE.dynkin_diagram.<locals>.<genexpr>r   z1   z   c                 s   s    | ]}t |V  qd S )N)strr8   r   r   r   r:     s    r   )r   r;   joinr   )r   r   diagr   r   r   dynkin_diagram  s   "&zTypeE.dynkin_diagramN)__name__
__module____qualname__r   r   r   r   r'   r.   r1   r5   r>   r   r   r   r   r      s    ( 	%r   N)cartan_typer   sympy.core.backendr   r   r   r   r   r   r   <module>   s    