EXAMPLES: We create and compute a
basis.
sage: M = FreeModule(IntegerRing(),2)
sage: E = End(M)
sage: B = E.basis()
sage: len(B)
4
sage: B[0]
Free module morphism defined by the matrix
[1 0]
[0 0]
Domain: Ambient free module of rank 2 over the principal ideal domain ...
Codomain: Ambient free module of rank 2 over the principal ideal domain ...
We create and
compute a basis.
sage: V3 = FreeModule(IntegerRing(),3)
sage: V2 = FreeModule(IntegerRing(),2)
sage: H = Hom(V3,V2)
sage: H
Set of Morphisms from Ambient free module of rank 3
over the principal ideal domain Integer Ring to
Ambient free module of rank 2
over the principal ideal domain Integer Ring
in Category of modules with basis over Integer Ring
sage: B = H.basis()
sage: len(B)
6
sage: B[0]
Free module morphism defined by the matrix
[1 0]
[0 0]
[0 0]...
TESTS:
sage: H = Hom(QQ^2, QQ^1)
sage: loads(dumps(H)) == H
True
See trac 5886:
sage: V = (ZZ^2).span_of_basis([[1,2],[3,4]])
sage: V.hom([V.0, V.1])
Free module morphism defined by the matrix
[1 0]
[0 1]...
Bases: sage.categories.homset.HomsetWithBase
TESTS:
sage: X = ZZ['x']; X.rename("X")
sage: Y = ZZ['y']; Y.rename("Y")
sage: class MyHomset(HomsetWithBase):
... def my_function(self, x):
... return Y(x[0])
... def _an_element_(self):
... return sage.categories.morphism.SetMorphism(self, self.my_function)
...
sage: import __main__; __main__.MyHomset = MyHomset # fakes MyHomset being defined in a Python module
sage: H = MyHomset(X, Y, category=Monoids())
sage: H
Set of Morphisms from X to Y in Category of monoids
sage: H.base()
Integer Ring
sage: TestSuite(H).run()
Return a basis for this space of free module homomorphisms.
OUTPUT:
EXAMPLES:
sage: H = Hom(ZZ^2, ZZ^1)
sage: H.basis()
(Free module morphism defined by the matrix
[1]
[0]
Domain: Ambient free module of rank 2 over the principal ideal domain ...
Codomain: Ambient free module of rank 1 over the principal ideal domain ..., Free module morphism defined by the matrix
[0]
[1]
Domain: Ambient free module of rank 2 over the principal ideal domain ...
Codomain: Ambient free module of rank 1 over the principal ideal domain ...)
Return identity morphism in an endomorphism ring.
EXAMPLE:
sage: V=FreeModule(ZZ,5)
sage: H=V.Hom(V)
sage: H.identity()
Free module morphism defined by the matrix
[1 0 0 0 0]
[0 1 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 0 0 0 1]
Domain: Ambient free module of rank 5 over the principal ideal domain ...
Codomain: Ambient free module of rank 5 over the principal ideal domain ...
EXAMPLES:
sage: E = ZZ^2
sage: F = ZZ^3
sage: H = Hom(E, F)
sage: f = H.zero()
sage: f
Free module morphism defined by the matrix
[0 0 0]
[0 0 0]
Domain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
Codomain: Ambient free module of rank 3 over the principal ideal domain Integer Ring
sage: f(E.an_element())
(0, 0, 0)
sage: f(E.an_element()) == F.zero()
True
TESTS:
We check that H.zero() is picklable:
sage: loads(dumps(f.parent().zero()))
Free module morphism defined by the matrix
[0 0 0]
[0 0 0]
Domain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
Codomain: Ambient free module of rank 3 over the principal ideal domain Integer Ring
Return True if x is a free module homspace.
EXAMPLES:
Notice that every vector space is a free module, but when we construct a set of morphisms between two vector spaces, it is a VectorSpaceHomspace, which qualifies as a FreeModuleHomspace, since the former is special case of the latter.
sage: H = Hom(ZZ^3, ZZ^2) sage: type(H) <class ‘sage.modules.free_module_homspace.FreeModuleHomspace_with_category’> sage: sage.modules.free_module_homspace.is_FreeModuleHomspace(H) True
sage: K = Hom(QQ^3, ZZ^2) sage: type(K) <class ‘sage.modules.free_module_homspace.FreeModuleHomspace_with_category’> sage: sage.modules.free_module_homspace.is_FreeModuleHomspace(K) True
sage: L = Hom(ZZ^3, QQ^2) sage: type(L) <class ‘sage.modules.free_module_homspace.FreeModuleHomspace_with_category’> sage: sage.modules.free_module_homspace.is_FreeModuleHomspace(L) True
sage: P = Hom(QQ^3, QQ^2) sage: type(P) <class ‘sage.modules.vector_space_homspace.VectorSpaceHomspace_with_category’> sage: sage.modules.free_module_homspace.is_FreeModuleHomspace(P) True
sage: sage.modules.free_module_homspace.is_FreeModuleHomspace(‘junk’) False