Ticket #4326: trac_4326-root_systems-fix-nt.patch

File trac_4326-root_systems-fix-nt.patch, 9.3 KB (added by nthiery, 9 years ago)

Fix ClassicalWeylSubgroup? and remove unneeded long time, as spotted by Mike

  • sage/combinat/root_system/weight_lattice_realization.py

    # HG changeset patch
    # User Nicolas M. Thiery <nthiery@users.sf.net>
    # Date 1258550767 -3600
    # Node ID f9ce7c86fc834bc63786785d0c410f1dfe273a2b
    # Parent  713d7a6f05ac79bc94458f5b2f5be899c175b4cb
    #4326: Root systems: fix ClassicalWeylSubgroup and remove unneeded long time
    
    diff --git a/sage/combinat/root_system/weight_lattice_realization.py b/sage/combinat/root_system/weight_lattice_realization.py
    a b class WeightLatticeRealization(RootLatti 
    165165
    166166          The plot returned has a size of one fundamental polygon by default. We can
    167167          ask plot to give a bigger plot by using the argument size
    168             sage: G = RootSystem(['G',2,1]).weight_space().plot(size = [[0..1],[-1..1]]) #long time
    169             sage: G = RootSystem(['A',2,1]).weight_space().plot(size = [[-1..1],[-1..1]]) #long time
     168            sage: G = RootSystem(['G',2,1]).weight_space().plot(size = [[0..1],[-1..1]])
     169            sage: G = RootSystem(['A',2,1]).weight_space().plot(size = [[-1..1],[-1..1]])
    170170
    171171          A very important argument is the projection which will draw the plot. There are
    172172          some usual projections is this method. If you want to draw in the plane a very
    173173          special Cartan type, Sage will ask you to specify the projection. The projection
    174174          is a matrix over a ring. In practice, calcul over float is a good way to draw.
    175175            sage: L = RootSystem(['A',2,1]).weight_space()
    176             sage: G = L.plot(projection=matrix(RR, [[0,0.5,-0.5],[0,0.866,0.866]])) #long time
    177             sage: G = RootSystem(['C',2,1]).weight_space().plot() #long time
     176            sage: G = L.plot(projection=matrix(RR, [[0,0.5,-0.5],[0,0.866,0.866]]))
     177            sage: G = RootSystem(['C',2,1]).weight_space().plot()
    178178
    179179          By default, the plot method draw the simple roots, this can be disabled by setting
    180180          the argument simple_roots=False
    class WeightLatticeRealization(RootLatti 
    184184          setting the argument fundamental_weights=False
    185185            sage: G = RootSystem(['A',2]).weight_space().plot(fundamental_weights=False, simple_roots=False)
    186186
    187           There is in a plot an argument to draw alcoves walks. The good way to do this is 
     187          There is in a plot an argument to draw alcoves walks. The good way to do this is
    188188          to use the crystals theory. the plot method contains only the drawing part...
    189189            sage: L = RootSystem(['A',2,1]).weight_space()
    190             sage: G = L.plot(size=[[-1..1],[-1..1]],alcovewalks=[[0,2,0,1,2,1,2,0,2,1]]) # long time
     190            sage: G = L.plot(size=[[-1..1],[-1..1]],alcovewalks=[[0,2,0,1,2,1,2,0,2,1]])
    191191        """
    192192
    193193        from sage.plot.plot import Graphics
  • sage/combinat/root_system/weyl_group.py

    diff --git a/sage/combinat/root_system/weyl_group.py b/sage/combinat/root_system/weyl_group.py
    a b from sage.matrix.constructor import matr 
    2323from sage.combinat.root_system.root_lattice_realization import RootLatticeRealization
    2424from sage.structure.unique_representation import UniqueRepresentation
    2525from sage.categories.all import WeylGroups, FiniteWeylGroups, AffineWeylGroups
     26from sage.sets.family import Family
    2627
    2728def WeylGroup(x):
    2829    """
    def WeylGroup(x): 
    121122class WeylGroup_gens(ClearCacheOnPickle, UniqueRepresentation, MatrixGroup_gens):
    122123    def __init__(self, lattice):
    123124        """
    124         EXAMPLES:
    125             sage: G = WeylGroup(['F',4])
    126             sage: G == loads(dumps(G))
    127             True
     125        EXAMPLES::
     126
     127            sage: G = WeylGroup(['B',3])
     128            sage: TestSuite(G).run()
    128129        """
    129130        self._lattice = lattice
    130131        if self.cartan_type().is_affine():
    class WeylGroup_gens(ClearCacheOnPickle, 
    134135        else:
    135136            category = WeylGroups()
    136137        self._init_category_(category)
    137         MatrixGroup_gens.__init__(self, [self.morphism_matrix(s) for s in lattice.simple_reflections()])
    138138        self.n = lattice.dimension() # Really needed?
     139        # MatrixGroup_gens takes plain matrices as input. So we can't do:
     140        #MatrixGroup_gens.__init__(self, list(self.simple_reflections()))
     141        MatrixGroup_gens.__init__(self, [self.morphism_matrix(self.lattice().simple_reflection(i)) for i in self.index_set()])
    139142
    140143    @cached_method
    141144    def cartan_type(self):
    class WeylGroup_gens(ClearCacheOnPickle, 
    153156
    154157    @cached_method
    155158    def index_set(self):
    156         return self.lattice().index_set()
     159        """
     160        Returns the index set of self.
     161
     162        EXAMPLES::
     163
     164            sage: G = WeylGroup(['F',4])
     165            sage: G.index_set()
     166            [1, 2, 3, 4]
     167            sage: G = WeylGroup(['A',3,1])
     168            sage: G.index_set()
     169            [0, 1, 2, 3]
     170        """
     171        return self.cartan_type().index_set()
    157172
    158173    # Should be implemented in (morphisms of) modules with basis
    159174    def morphism_matrix(self, f):
    class ClassicalWeylSubgroup(WeylGroup_ge 
    516531    """
    517532    A class for Classical Weyl Subgroup of a Weyl Group
    518533
     534    EXAMPLES::
     535
     536        sage: G = WeylGroup(["A",3,1]).classical()
     537        sage: G
     538        Parabolic Subgroup of the Weyl Group of type ['A', 3, 1] (as a matrix group acting on the root space)
     539        sage: G.category()
     540        Category of finite weyl groups
     541        sage: G.cardinality()
     542        24
     543        sage: TestSuite(G).run()
     544
     545    TESTS::
     546
     547        sage: from sage.combinat.root_system.weyl_group import ClassicalWeylSubgroup
     548        sage: H = ClassicalWeylSubgroup(RootSystem(["A", 3, 1]).root_space())
     549        sage: H is G
     550        True
     551
    519552    Caveat: the interface is likely to change. The current main
    520553    application is for plots.
    521554
    class ClassicalWeylSubgroup(WeylGroup_ge 
    523556     - Parabolic subrootsystems
    524557     - Parabolic subgroups with a set of nodes as argument
    525558    """
    526     def __init__(self, lattice):
     559
     560    @cached_method
     561    def cartan_type(self):
    527562        """
    528563        EXAMPLES::
    529564
    530             sage: from sage.combinat.root_system.weyl_group import ClassicalWeylSubgroup
    531             sage: G = ClassicalWeylSubgroup(RootSystem(["A", 3, 1]).root_space())
    532             sage: G == loads(dumps(G))
    533             True
     565            sage: WeylGroup(['A',3,1]).classical().cartan_type()
     566            ['A', 3]
     567            sage: WeylGroup(['A',3,1]).classical().index_set()
     568            [1, 2, 3]
     569
     570        Note: won't be needed, once the lattice will be a parabolic sub root system
    534571        """
    535         self._lattice = lattice
    536         self.n = lattice.dimension()
    537         MatrixGroup_gens.__init__(self, [self.morphism_matrix(lattice.simple_reflections()[s]) for s in range(1,self.n)])
     572        return self.lattice().cartan_type().classical()
     573
     574    def simple_reflections(self):
     575        """
     576        EXAMPLES::
     577
     578            sage: WeylGroup(['A',2,1]).classical().simple_reflections()
     579            Finite family {1: [ 1  0  0]
     580                              [ 1 -1  1]
     581                              [ 0  0  1],
     582                           2: [ 1  0  0]
     583                              [ 0  1  0]
     584                              [ 1  1 -1]}
     585
     586        Note: won't be needed, once the lattice will be a parabolic sub root system
     587        """
     588        return Family(dict((i, self.from_morphism(self.lattice().simple_reflection(i))) for i in self.index_set()))
    538589
    539590    def __repr__(self):
    540591        """
    class ClassicalWeylSubgroup(WeylGroup_ge 
    549600            sage: RootSystem(['C',4,1]).coweight_lattice().weyl_group().classical()
    550601            Parabolic Subgroup of the Weyl Group of type ['C', 4, 1]^* (as a matrix group acting on the coweight lattice)
    551602        """
    552         return "Parabolic Subgroup of the Weyl Group of type %s (as a matrix group acting on the %s)"%(self.cartan_type(),
     603        return "Parabolic Subgroup of the Weyl Group of type %s (as a matrix group acting on the %s)"%(self.lattice().cartan_type(),
    553604                                                                           self._lattice._name_string(capitalize=False,
    554605                                                                                                      base_ring=False,
    555606                                                                                                      type=False))
    class ClassicalWeylSubgroup(WeylGroup_ge 
    574625        Tests some internal invariants
    575626
    576627        EXAMPLES::
    577        
     628
    578629            sage: WeylGroup(['A', 2, 1]).classical()._test_is_finite()
    579630            sage: WeylGroup(['B', 3, 1]).classical()._test_is_finite()
    580631        """
    581632        tester = self._tester(**options)
    582         assert(self.cartan_type().is_affine())
    583633        assert(not self.weyl_group().is_finite())
    584634        assert(self.is_finite())
    585    
     635
    586636class WeylGroupElement(MatrixGroupElement):
    587637    """
    588638    Class for a Weyl Group elements
    class WeylGroupElement(MatrixGroupElemen 
    593643       
    594644            sage: G = WeylGroup(['A',2])
    595645            sage: s1 = G.simple_reflection(1)
    596             sage: loads(dumps(s1))
    597             [0 1 0]
    598             [1 0 0]
    599             [0 0 1]
     646            sage: TestSuite(s1).run()
    600647        """
    601648        MatrixGroupElement.__init__(self, g, parent)
    602649        self.__matrix = self._MatrixGroupElement__mat