�
ɍ�Xc@shddlTed�Zed�Zed�ZddlTdefd��YZdefd��YZ	d	S(
i����(t*iiitlocal_BraidcBs8eZdZdd�Zdd�Zdedd�ZRS(s�
    This Class contains extensions to the Braid Element class.

    If you don't see this well formatted type 

    sage: print local_Braid.__doc__
     
    This class has two new methods and one overwriting the corresponding methods of the class Braid.

    New methods:
        - __burau_matrix_wikipedia__
        - __burau_matrix_unitary__

    Modified:
        . burau_matrix (using __burau_matrix_wikipedia__, __burau_matrix_unitary__ )


    For more information type

        sage: print local_Braid.__burau_matrix_wikipedia__.__doc__
        sage: print local_Braid.__burau_matrix_unitary__.__doc__
        sage: print local_Braid.burau_matrix.__doc__

    AUTHOR

     - Sebastian Oehms, Oct. 2016

    ttcCsstt�|�}|j�}|j�}t||t�}x/|j�D]!}t||t�}|tkr�|||t|tf<|tkr�|||t|tf<n||tkr�t||t|f<q�n|tkra|t||t|tf<|tkr/t||t|tf<n||tkra|t||t|f<qan||}qJW|S(s	
        The explicit reduced Burau representation given on Wikipedia since 11.03.2014 is different from the version 
        implemented in the braid-basis class. The version according to the recent Wikipedia-Page is implemented here.

        If you don't see this well formatted type 

        sage: print local_Braid.__burau_matrix_wikipedia__.__doc__


        Moreover it is the version used by Squier and Coxeter and will be used here to implement the unitary Burau 
        reoresentation 

        INPUT:

          - "var":  string (default: 't'); the name of the variable in the entries of the matrix. See also: 
                    print sage.groups.braid.Braid.burau_matrix.__doc__

        OUTPUT:

            The Burau matrix of the braid. It is a matrix whose entries are Laurent polynomials in the variable "var".

        EXAMPLES:

            sage: sage.groups.braid.BraidGroup_class = local_BraidGroup_class
            sage: B4 = BraidGroup(4)
            sage: b1, b2, b3 = B4.gens()
            sage: b = b1*b2/b3/b2
            sage: type(b)
            <class 'lib.local_braid.local_BraidGroup_class_with_category.element_class'>
            sage: b.__burau_matrix_wikipedia__()
            [    1 - t -t^-1 + 1        -1]
            [        1 -t^-1 + 1        -1]
            [        1     -t^-1         0]
            sage: b.__burau_matrix_wikipedia__(var='x')
            [    1 - x -x^-1 + 1        -1]
            [        1 -x^-1 + 1        -1]
            [        1     -x^-1         0]

          compare with the original method

            sage: b.burau_matrix()
            [       1 - t            0      t - t^2          t^2]
            [           1            0            0            0]
            [           0            0            1            0]
            [           0         t^-2 -t^-2 + t^-1    -t^-1 + 1]
            sage: b.burau_matrix(reduced=True)
            [                     0               -t + t^2                   -t^2]
            [                     0            1 - t + t^2                   -t^2]
            [                  t^-2 -t^-2 + t^-1 - t + t^2        -t^-1 + 1 - t^2]
            sage: 
       

        REFERENCES:

         - wikipedia:'Burau_representation'

        AUTHOR

         - Sebastian Oehms, Oct. 2016

        (	tLaurentPolynomialRingtIntegerRingtgentstrandstidentity_matrixt
_sage_const_1tTietzet
_sage_const_0t
_sage_const_2(tselftvartRRtntMtitA((slib/local_braid.pyt__burau_matrix_wikipedia__Ys(> 
!tscs%|j���j�t}tt�dd�}|jd�\}tt�|�}|j�}|j|tgd|��t	||��fd��}t	|||d��}t	|||d��}	xEt
|�D]7}
||
t||
|
f<||
t|	|
|
f<q�W|	||}|S(	s�
        Return the unitary form of the Burau matrix of the braid according to
 
        CRAIG C. SQUIE: THE BURAU REPRESENTATION IS UNITARY, PROCEEDINGS OF THE AMERICAN MATHEMATICAL SOCIETY,
                        Volume 90. Number 2, February 1984

        If you don't see this well formatted type 

        sage: print local_Braid.__burau_matrix_unitary__.__doc__

        INPUT:

          - "var":  string (default: 's'); the name of the variable in the entries of the matrix. The connection with the 
                    variable t of the original burau_matrix is t=s**2. See also: 
                    print sage.groups.braid.Braid.burau_matrix.__doc__

        OUTPUT:

          The Burau matrix of the braid in the unitary form. It is obtained from the original burau_matrix by a base change
          in order to preserve a hermitian form. It is a matrix whose entries are Laurent polynomials in the variable "var".
          The original Burau matrix can be obtained by the method local_Braid.__burau_matrix_wikipedia__ 

        EXAMPLES:

            sage: sage.groups.braid.BraidGroup_class = local_BraidGroup_class
            sage: B4 = BraidGroup(4)
            sage: b1, b2, b3 = B4.gens()
            sage: b = b1*b2/b3/b2
            sage: type(b)
            <class 'lib.local_braid.local_BraidGroup_class_with_category.element_class'>
            sage: b.__burau_matrix_unitary__()
            [  1 - s^2 -s^-1 + s      -s^2]
            [     s^-1 -s^-2 + 1        -s]
            [     s^-2     -s^-3         0]
            sage: b.__burau_matrix_unitary__(var='x')
            [  1 - x^2 -x^-1 + x      -x^2]
            [     x^-1 -x^-2 + 1        -x]
            [     x^-2     -x^-3         0]
            sage: 

          compare with the version given on wikipedia:

            sage: b.__burau_matrix_wikipedia__()
            [    1 - t -t^-1 + 1        -1]
            [        1 -t^-1 + 1        -1]
            [        1     -t^-1         0]

          compare with the original method:

            sage: b.burau_matrix()
            [       1 - t            0      t - t^2          t^2]
            [           1            0            0            0]
            [           0            0            1            0]
            [           0         t^-2 -t^-2 + t^-1    -t^-1 + 1]
            sage: b.burau_matrix(reduced=True)
            [                     0               -t + t^2                   -t^2]
            [                     0            1 - t + t^2                   -t^2]
            [                  t^-2 -t^-2 + t^-1 - t + t^2        -t^-1 + 1 - t^2]
            sage: 

        REFERENCES:

        - Coxeter, H.S.M: "Factor groups of the braid groups, Proceedings of the Fourth Candian Mathematical Congress
          (Vancover      1957), pp. 95-122". 

        - C. C. Squier:`THE BURAU REPRESENTATION IS UNITARY`, PROCEEDINGS OF THE
                                                              AMERICAN MATHEMATICAL SOCIETY
                                                              Volume 90. Number 2, February 1984
        - Tyakay Venkataramana: Image of the Burau Representation at $d$-th Roots of unity. ANNALS OF MATHEMATICS MAY 2014

        AUTHOR

         - Sebastian Oehms, Oct. 2016

        tnamesRitcodomaincs��||f�S(N((Rtj(tBurauOritsubsVar(slib/local_braid.pyt<lambda>scSstS(N(R
(RR((slib/local_braid.pyRscSstS(N(R
(RR((slib/local_braid.pyRs(R(Rt
dimensionsR
RRt_first_ngensRthomRtmatrixtrangeR(RR
tdt	oriDomainRt	newDomainRtBurauMatt
transformPttransformPIRtres((RRslib/local_braid.pyt__burau_matrix_unitary__�sMtdefaultcCs^|dkr.tjjjj|d|d|�S|dkrJ|jd|�S|jd|�SdS(sb
        This method is a modification of the original burau_matrix-method. It contains an additional keyword-parameter 
        "version". If this keyword is not set or is set to the value 'default' it behaves like the original one.

        If you don't see this well formatted type:

        sage: print local_Braid.burau_matrix.__doc__

        To read the original docstring type:

        sage: print Braid.burau_matrix.__doc__

        INPUT:

          - "var":  string (default: 't'); the name of the variable in the entries of the matrix. See also: 
                    print sage.groups.braid.Braid.burau_matrix.__doc__
          - "reduced": boolean (default: 'False'); whether to return the reduced or unreduced Burau representation.
                    Note: if version is set to a value different from 'default' this keyword is ignored and treated
                    as set to 'True' (this means: no unreduced form for other versions)
          - "version": string (default = 'default' ). The following values are possible

            - "default" the method behaves like the original one. For more information on this see
               sage: print Braid.burau_matrix.__doc__

            - "unitary" gives the unitary form according to Squier. For more information on this see
               sage: print local_Braid.__burau_matrix_unitary__.__doc__
                       
            - any value else gives the reduced form given on wikipedia. For more information on this see
               sage: print local_Braid.__burau_matrix_wikipedia__.__doc__

        OUTPUT:

            The Burau matrix of the braid. It is a matrix whose entries are Laurent polynomials in the variable "var".
                      
        EXAMPLES:

            sage: sage.groups.braid.BraidGroup_class = local_BraidGroup_class
            sage: B4 = BraidGroup(4)
            sage: b1, b2, b3 = B4.gens()
            sage: b = b1*b2/b3/b2
            sage: type(b)
            <class 'lib.local_braid.local_BraidGroup_class_with_category.element_class'>
            sage: b.burau_matrix()
            [       1 - t            0      t - t^2          t^2]
            [           1            0            0            0]
            [           0            0            1            0]
            [           0         t^-2 -t^-2 + t^-1    -t^-1 + 1]
            sage: b.burau_matrix(version='unitary')
            [  1 - t^2 -t^-1 + t      -t^2]
            [     t^-1 -t^-2 + 1        -t]
            [     t^-2     -t^-3         0]
            sage: b.burau_matrix(version='wiki')
            [    1 - t -t^-1 + 1        -1]
            [        1 -t^-1 + 1        -1]
            [        1     -t^-1         0]
            sage: b.burau_matrix(version='wiki', reduced=True)
            [    1 - t -t^-1 + 1        -1]
            [        1 -t^-1 + 1        -1]
            [        1     -t^-1         0]
            sage: b.burau_matrix(version='wiki', reduced=False)
            [    1 - t -t^-1 + 1        -1]
            [        1 -t^-1 + 1        -1]
            [        1     -t^-1         0]
            sage: b.burau_matrix(reduced=True)
            [                     0               -t + t^2                   -t^2]
            [                     0            1 - t + t^2                   -t^2]
            [                  t^-2 -t^-2 + t^-1 - t + t^2        -t^-1 + 1 - t^2]
            sage: b.burau_matrix(var='s', version='unitary')
            [  1 - s^2 -s^-1 + s      -s^2]
            [     s^-1 -s^-2 + 1        -s]
            [     s^-2     -s^-3         0]
            sage: 


        AUTHOR

         - Sebastian Oehms, Oct. 2016

        R(R
treducedtunitaryN(tsagetgroupstbraidtBraidtburau_matrixR'R(RR
R)tversion((slib/local_braid.pyR/s
Q"(t__name__t
__module__t__doc__RR'tFalseR/(((slib/local_braid.pyR;sW^tlocal_BraidGroup_classcBs eZdZeZdd�ZRS(s�
    This Class contains extensions to the sage BraidGroup class. 

    If you don't see this well formatted type:

    sage: print local_BraidGroup_class.__doc__

    New methods:

        - __unitary_form__

    Modified:

        . Element Class is local_Braid instead of Braid. This contains extension of the burau_matrix -method
          For more information type:

          sage: print local_Braid.__doc__

    AUTHOR

     - Sebastian Oehms, Oct. 2016

    RcCs�tt�|�}|j�}|j�}||tt||t�}xBt|t�D]0}t|||tf<t||t|f<q[W|S(s�
        Returns the hermitian form with respect to the __unitary_burau_matrix__ of the Element Class

        If you don't see this well formatted type:

        sage: print local_BraidGroup_class.__unitary_form__.__doc__

        The hermitian form returned by this method is kept invariant by the unitary Burau matrices returned by the 
        local_Braid -method burau_matrix() setting the version keyword to 'unitary'

        For more information on the unitary Burau matrices type         

           sage: print local_Braid.__burau_matrix_unitary__.__doc__
           sage: print local_Braid.burau_matrix.__doc__

        INPUT:

          - "var":  string (default: 's'); the name of the variable in the entries of the matrix of the unitary form. 

        OUTPUT:

          The hermitian form as a quadratic matrix whose entries are Laurent polynomials in the variable "var".

        EXAMPLES:

            sage: sage.groups.braid.BraidGroup_class = local_BraidGroup_class
            sage: B4 = BraidGroup(4)
            sage: B4.__unitary_form__()
            [s^-1 + s       -1        0]
            [      -1 s^-1 + s       -1]
            [       0       -1 s^-1 + s]
            sage: 
            sage: 
            sage: B4.__unitary_form__(var='x')
            [x^-1 + x       -1        0]
            [      -1 x^-1 + x       -1]
            [       0       -1 x^-1 + x]
            sage: 

        REFERENCES:

        - Coxeter, H.S.M: "Factor groups of the braid groups, Proceedings of the Fourth Candian Mathematical Congress
          (Vancover      1957), pp. 95-122". 

        - C. C. Squier:`THE BURAU REPRESENTATION IS UNITARY`, PROCEEDINGS OF THE
                                                              AMERICAN MATHEMATICAL SOCIETY
                                                              Volume 90. Number 2, February 1984

        AUTHOR

         - Sebastian Oehms, Oct. 2016

        (RRRRRRRR(RR
RRRRR((slib/local_braid.pyt__unitary_form__�s6 (R1R2R3RtElementR6(((slib/local_braid.pyR5isN(
tsage.all_cmdlinetIntegerRRR
tsage.groups.braidR.RtBraidGroup_classR5(((slib/local_braid.pyt<module>s
6
�/