Ticket #13955: trac_13955-latex_output_for_weyl_group_elements-cs.patch

File trac_13955-latex_output_for_weyl_group_elements-cs.patch, 1.5 KB (added by Christian Stump, 10 years ago)
  • sage/combinat/root_system/weyl_group.py

    # HG changeset patch
    # User Christian Stump <christian.stump at gmail.com>
    # Date 1358242387 -3600
    # Node ID b1908ea96e267a2ffc2e0ed84f0931e33ce534a0
    # Parent  dae73a4694cbe91a3b3219ea0a4da05d63073707
    trac 13955 latex output for Weyl group elements with prefix
    
    diff --git a/sage/combinat/root_system/weyl_group.py b/sage/combinat/root_system/weyl_group.py
    a b class WeylGroupElement(MatrixGroupElemen 
    806806                    ret += "%s%d*"%(self._parent._prefix, i)
    807807            return ret + "%s%d"%(self._parent._prefix, redword[-1])
    808808
     809    def _latex_(self):
     810        """
     811        EXAMPLES::
     812
     813            sage: W = WeylGroup(['A',2,1], prefix="s")
     814            sage: [s0,s1,s2]=W.simple_reflections()
     815            sage: latex(s0*s1) # indirect doctest
     816            s_{0}s_{1}
     817            sage: W = WeylGroup(['A',2,1])
     818            sage: [s0,s1,s2]=W.simple_reflections()
     819            sage: latex(s0*s1)
     820            \left(\begin{array}{rrr}
     821            0 & -1 & 2 \\
     822            1 & -1 & 1 \\
     823            0 & 0 & 1
     824            \end{array}\right)
     825        """
     826        if self._parent._prefix is None:
     827            return MatrixGroupElement._latex_(self)
     828        else:
     829            redword = self.reduced_word()
     830            if len(redword) == 0:
     831                return "1"
     832            else:
     833                return "".join(["%s_{%d}"%(self._parent._prefix, i) for i in redword])
     834
    809835    def matrix(self):
    810836        """
    811837        Returns self as a matrix.