Ticket #2853: 2853.1.patch

File 2853.1.patch, 5.9 KB (added by bump, 2 years ago)
  • sage/combinat/crystals/letters.py

    diff -r 2b672817103a sage/combinat/crystals/letters.py
    a b  
    142142        """ 
    143143        return self._digraph 
    144144     
    145  
    146145    def __contains__(self, x): 
    147146        """ 
    148147        EXAMPLES: 
     
    287286 
    288287        sage: C.check() 
    289288        True 
    290     """ 
     289 
     290    """ 
     291     
     292    def weight(self): 
     293        """ 
     294        Returns the weight of self. 
     295 
     296        EXAMPLES: 
     297            sage: [v.weight() for v in CrystalOfLetters(['A',3])] 
     298            [(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1)] 
     299        """ 
     300        return self._parent.weight_lattice_realization()._term(self.value-1) 
     301 
    291302    def e(self, i): 
    292303        r""" 
    293304        Returns the action of $e_i$ on self. 
     
    331342        sage: C.check() 
    332343        True 
    333344    """ 
     345     
     346    def weight(self): 
     347        """ 
     348        Returns the weight of self. 
     349 
     350        EXAMPLES: 
     351            sage: [v.weight() for v in CrystalOfLetters(['B',3])] 
     352            [(1, 0, 0), 
     353             (0, 1, 0), 
     354             (0, 0, 1), 
     355             (0, 0, 0), 
     356             (0, 0, -1), 
     357             (0, -1, 0), 
     358             (-1, 0, 0)] 
     359        """ 
     360        if self.value > 0: 
     361            return self._parent.weight_lattice_realization()._term(self.value-1) 
     362        elif self.value < 0: 
     363            return -self._parent.weight_lattice_realization()._term(-self.value-1) 
     364        else: 
     365            return self._parent.weight_lattice_realization()._free_module(0) 
     366 
    334367    def e(self, i): 
    335368        r""" 
    336369        Returns the action of $e_i$ on self. 
     
    410443         [False, False, False, False, False, False]] 
    411444        sage: C.check() 
    412445        True 
    413     
    414     """ 
     446    """ 
     447     
     448    def weight(self): 
     449        """ 
     450        Returns the weight of self. 
     451 
     452        EXAMPLES: 
     453            sage: [v.weight() for v in CrystalOfLetters(['C',3])] 
     454            [(1, 0, 0), (0, 1, 0), (0, 0, 1), (0, 0, -1), (0, -1, 0), (-1, 0, 0)] 
     455         
     456        """ 
     457        if self.value > 0: 
     458            return self._parent.weight_lattice_realization()._term(self.value-1) 
     459        elif self.value < 0: 
     460            return -self._parent.weight_lattice_realization()._term(-self.value-1) 
     461        else: 
     462            return self._parent.weight_lattice_realization()._free_module(0) 
     463 
    415464    def e(self, i): 
    416465        r""" 
    417466        Returns the action of $e_i$ on self. 
     
    472521        [1, 2, 3, 4, -4, -3, -2, -1] 
    473522        sage: C.check() 
    474523        True 
    475     """ 
     524         
     525    """ 
     526 
     527    def weight(self): 
     528        """ 
     529        Returns the weight of self. 
     530 
     531        EXAMPLES: 
     532            sage: [v.weight() for v in CrystalOfLetters(['D',4])] 
     533            [(1, 0, 0, 0), 
     534             (0, 1, 0, 0), 
     535             (0, 0, 1, 0), 
     536             (0, 0, 0, 1), 
     537             (0, 0, 0, -1), 
     538             (0, 0, -1, 0), 
     539             (0, -1, 0, 0), 
     540             (-1, 0, 0, 0)] 
     541        """ 
     542        if self.value > 0: 
     543            return self._parent.weight_lattice_realization()._term(self.value-1) 
     544        elif self.value < 0: 
     545            return -self._parent.weight_lattice_realization()._term(-self.value-1) 
     546        else: 
     547            return self._parent.weight_lattice_realization()._free_module(0) 
     548 
    476549    def e(self, i): 
    477550        r""" 
    478551        Returns the action of $e_i$ on self. 
     
    552625        sage: C.check() 
    553626        True 
    554627    """ 
     628     
     629    def weight(self): 
     630        """ 
     631        Returns the weight of self. 
     632 
     633        EXAMPLES: 
     634            sage: [v.weight() for v in CrystalOfLetters(['G',2])] 
     635            [(1, 0, -1), (1, -1, 0), (0, 1, -1), (0, 0, 0), (0, -1, 1), (-1, 1, 0), (-1, 0, 1)] 
     636        """ 
     637        if self.value == 1: 
     638            return self._parent.weight_lattice_realization()._free_module((1, 0, -1)) 
     639        elif self.value == 2: 
     640            return self._parent.weight_lattice_realization()._free_module((1, -1, 0)) 
     641        elif self.value == 3: 
     642            return self._parent.weight_lattice_realization()._free_module((0, 1, -1)) 
     643        elif self.value == 0: 
     644            return self._parent.weight_lattice_realization()._free_module((0, 0, 0)) 
     645        elif self.value == -3: 
     646            return self._parent.weight_lattice_realization()._free_module((0, -1, 1)) 
     647        elif self.value == -2: 
     648            return self._parent.weight_lattice_realization()._free_module((-1, 1, 0)) 
     649        elif self.value == -1: 
     650            return self._parent.weight_lattice_realization()._free_module((-1, 0, 1)) 
     651        else: 
     652            raise RuntimeError, "G2 crystal of letters element %d not valid"%self.value 
     653 
    555654    def e(self, i): 
    556655        r""" 
    557656        Returns the action of $e_i$ on self. 
  • sage/combinat/crystals/tensor_product.py

    diff -r 2b672817103a sage/combinat/crystals/tensor_product.py
    a b  
    235235            else: 
    236236                self.module_generators = [ self(*x) for x in options['generators']] 
    237237 
    238  
    239238    def __call__(self, *args): 
    240239        """ 
    241240        EXAMPLES: 
     
    272271        k = position[0] 
    273272        return self.set_index(k, self[k].e(i)) 
    274273     
     274    def weight(self): 
     275        """ 
     276        Returns the weight of self. 
     277 
     278        EXAMPLES: 
     279            sage: C = CrystalOfLetters(['A',3]) 
     280            sage: T = TensorProductOfCrystals(C,C) 
     281            sage: T(C(1),C(2)).weight() 
     282            (1, 1, 0, 0) 
     283        """ 
     284        return sum(self[j].weight() for j in range(len(self))) 
     285 
    275286    def f(self, i): 
    276287        """ 
    277288        Returns the action of $f_i$ on self.