Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Modules: Add parent method module_morphism
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Jul 21, 2020
1 parent 467fbc7 commit 0afa01c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/sage/categories/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
from sage.misc.cachefunc import cached_method
from sage.misc.lazy_import import LazyImport
from sage.categories.category_with_axiom import CategoryWithAxiom_over_base_ring
from sage.categories.morphism import SetMorphism
from sage.categories.homsets import HomsetsCategory
from sage.categories.homset import Hom
from .category import Category
from .category_types import Category_module
from sage.categories.tensor import TensorProductsCategory, tensor
Expand Down Expand Up @@ -538,6 +540,37 @@ def tensor_square(self):
"""
return tensor([self, self])

def module_morphism(self, *, function, category=None, codomain, **keywords):
r"""
Construct a module morphism from ``self`` to ``codomain``.
Let ``self`` be a module `X` over a ring `R`.
This constructs a morphism `f: X \to Y`.
INPUT:
- ``self`` -- a parent `X` in ``Modules(R)``.
- ``function`` -- a function `f` from `X` to `Y`
- ``codomain`` -- the codomain `Y` of the morphism (default:
``f.codomain()`` if it's defined; otherwise it must be specified)
- ``category`` -- a category or ``None`` (default: ``None``)
EXAMPLES::
sage: V = FiniteRankFreeModule(QQ, 2)
sage: e = V.basis('e'); e
Basis (e_0,e_1) on the 2-dimensional vector space over the Rational Field
sage: neg = V.module_morphism(function=operator.neg, codomain=V); neg
Generic endomorphism of 2-dimensional vector space over the Rational Field
sage: neg(e[0])
Element -e_0 of the 2-dimensional vector space over the Rational Field
"""
return SetMorphism(Hom(self, codomain, category), function)

class ElementMethods:
pass

Expand Down

0 comments on commit 0afa01c

Please sign in to comment.