# 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 from sage.misc.cachefunc import cached_method from sage.categories.pushout import ConstructionFunctor from sage.combinat.free_module import CombinatorialFreeModule from sage.categories.all import Rings, HopfAlgebrasWithBasis from sage.categories.all import Rings, HopfAlgebrasWithBasis, Hom from sage.categories.morphism import SetMorphism class GroupAlgebraFunctor (ConstructionFunctor) : r""" """ return self.__group def __call__(self, base_ring) : def _apply_functor(self, base_ring) : r""" Create the group algebra with given base ring over self.group(). Create the group algebra with given base ring over ``self.group()``. INPUT : """ return GroupAlgebra(self.__group, base_ring) def _apply_functor_to_morphism(self, f) : r""" Lift a homomorphism of rings to the corresponding homomorphism of the group algebras of ``self.group()``. INPUT: - ``f`` - a morphism of rings. OUTPUT: A morphism of group algebras. EXAMPLES:: sage: G = SymmetricGroup(3) sage: A = GroupAlgebra(G, ZZ) sage: h = sage.categories.morphism.SetMorphism(Hom(ZZ, GF(5), Rings()), lambda x: GF(5)(x)) sage: hh = A.construction()[0](h) sage: hh(A.0 + 5 * A.1) (1,2,3) """ codomain = self(f.codomain()) return SetMorphism(Hom(self(f.domain()), codomain, Rings()), lambda x: sum(codomain(g) * f(c) for (g, c) in dict(x).iteritems())) class GroupAlgebra(CombinatorialFreeModule, Algebra): r""" Create the given group algebra.