o
    *ήcW                     @   s,   d dl mZ ddlmZ G dd deZdS )   )Standard_Cartan    )eyec                   @   s\   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d ZdS )TypeCc                 C   s   |dk rt dt| d|S )N   zn cannot be less than 3C)
ValueErrorr   __new__)clsn r   ?/tmp/pip-target-vg8gfxp4/lib/python/sympy/liealgebras/type_c.pyr	      s   zTypeC.__new__c                 C   s
   | j }|S )zDimension of the vector space V underlying the Lie algebra

        Examples
        ========

        >>> from sympy.liealgebras.cartan_type import CartanType
        >>> c = CartanType("C3")
        >>> c.dimension()
        3
        r   selfr   r   r   r   	dimension   s   zTypeC.dimensionc                 C   s$   | j }dg| }d||< d||< |S )zGGenerate roots with 1 in ith position and a -1 in jth position
        r   r   r   )r   ijr   rootr   r   r   
basic_root   s
   
zTypeC.basic_rootc                 C   s:   | j }||k r| |d |S dg| j  }d||d < |S )a  The ith simple root for the C series

        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 C_n, the first n-1 simple roots are the same as
        the roots in A_(n-1) (a 1 in the ith position, a -1
        in the (i+1)th position, and zeroes elsewhere).  The
        nth simple root is the root in which there is a 2 in
        the nth position and zeroes elsewhere.

        Examples
        ========

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

        r   r      )r   r   )r   r   r   r   r   r   r   simple_root#   s   zTypeC.simple_rootc                 C   s   | j }i }d}td|d D ]*}t|d |D ] }|d7 }| ||||< |d7 }| ||}d||< |||< qqtd|D ]}|d7 }dg| }d||< |||< q>|S )a  Generates all the positive roots of A_n

        This is half of all of the roots of C_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   ranger   )r   r   posrootskr   r   r   r   r   r   positive_rootsH   s$   


zTypeC.positive_rootsc                 C   s   | j }d|d  S )z<
        Returns the total number of roots for C_n"
        r   r   r   r   r   r   rootsm   s   zTypeC.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 )a(  The Cartan matrix for C_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('C4')
        >>> c.cartan_matrix()
        Matrix([
        [ 2, -1,  0,  0],
        [-1,  2, -1,  0],
        [ 0, -1,  2, -1],
        [ 0,  0, -2,  2]])

        r   r   r   )r   r   )r   r   )r   r   mr   r   r   r   cartan_matrixu   s   zTypeC.cartan_matrixc                 C   s   | j }|d| d  S )zE
        Returns the number of independent generators of C_n
        r   r   r   r   r   r   r   basis   s   zTypeC.basisc                 C   s   | j }dtd|  d S )z>
        Returns the Lie algebra associated with C_n"
        zsp(r   ))r   strr   r   r   r   lie_algebra   s   zTypeC.lie_algebrac                 C   sJ   | j }ddd t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'TypeC.dynkin_diagram.<locals>.<genexpr>r   z=<=0
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TypeC.dynkin_diagramN)__name__
__module____qualname__r	   r   r   r   r   r   r    r!   r$   r+   r   r   r   r   r      s    	%%"r   N)cartan_typer   sympy.core.backendr   r   r   r   r   r   <module>   s    