o
    *ήc                     @   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 )TypeBc                 C   s   |dk rt dt| d|S )N   zn cannot be less than 2B)
ValueErrorr   __new__)clsn r   ?/tmp/pip-target-vg8gfxp4/lib/python/sympy/liealgebras/type_b.pyr	      s   zTypeB.__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("B3")
        >>> c.dimension()
        3
        r   )selfr   r   r   	dimension   s   zTypeB.dimensionc                 C   s    dg| j  }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jrootr   r   r   
basic_root   s   zTypeB.basic_rootc                 C   s:   | j }||k r| |d |S dg| j  }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.

        In B_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 n-th
        simple root is the root with a 1 in the nth position
        and zeroes elsewhere.

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

        Examples
        ========

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

        r   r   )r   r   )r   r   r   r   r   r   r   simple_root%   s   zTypeB.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  
        This method generates all the positive roots of
        A_n.  This is half of all of the roots of B_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   r   positive_rootsI   s$   


zTypeB.positive_rootsc                 C   s   | j }d|d  S )z<
        Returns the total number of roots for B_n"
        r   r   r   r   r   r   r   rootsn   s   zTypeB.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 f< d||d |d f< |S )a9  
        Returns the Cartan matrix for B_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('B4')
        >>> c.cartan_matrix()
        Matrix([
        [ 2, -1,  0,  0],
        [-1,  2, -1,  0],
        [ 0, -1,  2, -2],
        [ 0,  0, -1,  2]])

        r   r   r   )r   r   )r   r   )r   r   mr   r   r   r   cartan_matrixv   s   zTypeB.cartan_matrixc                 C   s   | j }|d | d S )zE
        Returns the number of independent generators of B_n
        r   r   r   r   r   r   basis   s   zTypeB.basisc                 C   s   | j }dtd|  d S )z=
        Returns the Lie algebra associated with B_n
        zso(r   ))r   strr   r   r   r   lie_algebra   s   zTypeB.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'TypeB.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TypeB.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    