o
    *ήc                     @   s,   d dl mZ d dlmZ G dd deZdS )    )Standard_Cartan)eyec                   @   sh   e Zd 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d Zdd ZdS )TypeAze
    This class contains the information about
    the A series of simple Lie algebras.
    ====
    c                 C   s   |dk rt dt| d|S )N   zn cannot be less than 1A)
ValueErrorr   __new__)clsn r   ?/tmp/pip-target-vg8gfxp4/lib/python/sympy/liealgebras/type_a.pyr      s   zTypeA.__new__c                 C   s
   | j d S )zDimension of the vector space V underlying the Lie algebra

        Examples
        ========

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

        r   r   r   )r   ijr
   rootr   r   r   
basic_root    s
   zTypeA.basic_rootc                 C   s   |  |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.

        In A_n the ith simple root is the root which has a 1
        in the ith position, a -1 in the (i+1)th position,
        and zeroes elsewhere.

        This method returns the ith simple root for the A series.

        Examples
        ========

        >>> from sympy.liealgebras.cartan_type import CartanType
        >>> c = CartanType("A4")
        >>> c.simple_root(1)
        [1, -1, 0, 0, 0]

        r   )r   )r   r   r   r   r   simple_root.   s   zTypeA.simple_rootc                 C   sR   | j }i }d}td|D ]}t|d |d D ]}|d7 }| ||||< qq|S )a  
        This method generates all the positive roots of
        A_n.  This is half of all of the roots of A_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
   ranger   )r   r
   posrootskr   r   r   r   r   positive_rootsK   s   zTypeA.positive_rootsc                 C   s   |  d| jS )z9
        Returns the highest weight root for A_n
        r   )r   r
   r   r   r   r   highest_roote   s   zTypeA.highest_rootc                 C   s   | j }||d  S )z;
        Returns the total number of roots for A_n
        r   r   r   r
   r   r   r   rootsl      zTypeA.rootsc                 C   sv   | j }dt| }d}||d k r+d|||d f< d|||d f< |d7 }||d k sd|d< d||d |d f< |S )a9  
        Returns the Cartan matrix for A_n.
        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
   mr   r   r   r   cartan_matrixs   s   zTypeA.cartan_matrixc                 C   s   | j }|d d S )zE
        Returns the number of independent generators of A_n
        r   r   r   r   r   r   r   basis   r   zTypeA.basisc                 C   s   | j }dt|d  d S )z=
        Returns the Lie algebra associated with A_n
        zsu(r   ))r
   strr   r   r   r   lie_algebra   s   zTypeA.lie_algebrac                 C   sN   | j }ddd td|d D d }|ddd td|d D 7 }|S )Nz---c                 s   s    | ]}d V  qdS )0Nr   .0r   r   r   r   	<genexpr>   s    z'TypeA.dynkin_diagram.<locals>.<genexpr>r   
z   c                 s   s    | ]}t |V  qd S )N)r$   r'   r   r   r   r)      s    )r
   joinr   )r   r
   diagr   r   r   dynkin_diagram   s   ""zTypeA.dynkin_diagramN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r!   r"   r%   r-   r   r   r   r   r      s    !r   N)sympy.liealgebras.cartan_typer   sympy.core.backendr   r   r   r   r   r   <module>   s    