Ticket #6670: trac-6670-functors.patch

File trac-6670-functors.patch, 2.2 KB (added by Martin Raum, 11 years ago)
  • sage/algebras/group_algebra_new.py

    # HG changeset patch
    # User Martin Raum <Martin.Raum@matha.rwth-aachen.de>
    # Date 1312149231 -7200
    # Node ID 2e4bb7d7e50aa19750efd4f74ea74c16b50aab13
    # Parent  bbb259d142fac734ce2f331348b8dbedbe9ae8ee
    #6670: Update the group algebra functor to apply to morphisms correctly.
    
    diff -r bbb259d142fa -r 2e4bb7d7e50a sage/algebras/group_algebra_new.py
    a b  
    112112from sage.misc.cachefunc import cached_method
    113113from sage.categories.pushout import ConstructionFunctor
    114114from sage.combinat.free_module import CombinatorialFreeModule
    115 from sage.categories.all import Rings, HopfAlgebrasWithBasis
     115from sage.categories.all import Rings, HopfAlgebrasWithBasis, Hom
     116from sage.categories.morphism import SetMorphism
     117
    116118
    117119class GroupAlgebraFunctor (ConstructionFunctor) :
    118120    r"""
     
    159161         """
    160162        return self.__group
    161163
    162     def __call__(self, base_ring) :
     164    def _apply_functor(self, base_ring) :
    163165        r"""
    164         Create the group algebra with given base ring over self.group().
     166        Create the group algebra with given base ring over ``self.group()``.
    165167
    166168        INPUT :
    167169
     
    180182        """
    181183        return GroupAlgebra(self.__group, base_ring)
    182184
     185    def _apply_functor_to_morphism(self, f) :
     186        r"""
     187        Lift a homomorphism of rings to the corresponding homomorphism of the group algebras of ``self.group()``.
     188       
     189        INPUT:
     190       
     191        - ``f`` - a morphism of rings.
     192
     193        OUTPUT:
     194
     195        A morphism of group algebras.
     196
     197        EXAMPLES::
     198       
     199            sage: G = SymmetricGroup(3)
     200            sage: A = GroupAlgebra(G, ZZ)
     201            sage: h = sage.categories.morphism.SetMorphism(Hom(ZZ, GF(5), Rings()), lambda x: GF(5)(x))
     202            sage: hh = A.construction()[0](h)
     203            sage: hh(A.0 + 5 * A.1)
     204            (1,2,3)
     205        """
     206        codomain = self(f.codomain())
     207        return SetMorphism(Hom(self(f.domain()), codomain, Rings()), lambda x: sum(codomain(g) * f(c) for (g, c) in dict(x).iteritems()))
     208
    183209class GroupAlgebra(CombinatorialFreeModule, Algebra):
    184210    r"""
    185211    Create the given group algebra.