Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/homology/chain_complex_homspace.py
4108 views
1
r"""
2
Homspaces between chain complexes
3
4
Note that some significant functionality is lacking. Namely, the homspaces
5
are not actually modules over the base ring. It will be necessary to
6
enrich some of the structure of chain complexes for this to be naturally
7
available. On other hand, there are various overloaded operators. __mul__
8
acts as composition. One can __add__, and one can __mul__ with a ring element
9
on the right.
10
11
EXAMPLES::
12
13
sage: S = simplicial_complexes.Sphere(2)
14
sage: T = simplicial_complexes.Torus()
15
sage: C = S.chain_complex(augmented=True,cochain=True)
16
sage: D = T.chain_complex(augmented=True,cochain=True)
17
sage: G = Hom(C,D)
18
sage: G
19
Set of Morphisms from Chain complex with at most 4 nonzero terms over Integer Ring to Chain complex with at most 4 nonzero terms over Integer Ring in Category of chain complexes over Integer Ring
20
21
sage: S = simplicial_complexes.ChessboardComplex(3,3)
22
sage: H = Hom(S,S)
23
sage: i = H.identity()
24
sage: x = i.associated_chain_complex_morphism(augmented=True)
25
sage: x
26
Chain complex morphism from Chain complex with at most 4 nonzero terms over Integer Ring to Chain complex with at most 4 nonzero terms over Integer Ring
27
sage: x._matrix_dictionary
28
{0: [1 0 0 0 0 0 0 0 0]
29
[0 1 0 0 0 0 0 0 0]
30
[0 0 1 0 0 0 0 0 0]
31
[0 0 0 1 0 0 0 0 0]
32
[0 0 0 0 1 0 0 0 0]
33
[0 0 0 0 0 1 0 0 0]
34
[0 0 0 0 0 0 1 0 0]
35
[0 0 0 0 0 0 0 1 0]
36
[0 0 0 0 0 0 0 0 1], 1: [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
37
[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
38
[0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
39
[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
40
[0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]
41
[0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]
42
[0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]
43
[0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]
44
[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]
45
[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]
46
[0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]
47
[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]
48
[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]
49
[0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]
50
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]
51
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]
52
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0]
53
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1], 2: [1 0 0 0 0 0]
54
[0 1 0 0 0 0]
55
[0 0 1 0 0 0]
56
[0 0 0 1 0 0]
57
[0 0 0 0 1 0]
58
[0 0 0 0 0 1], -1: [1]}
59
60
sage: S = simplicial_complexes.Sphere(2)
61
sage: A = Hom(S,S)
62
sage: i = A.identity()
63
sage: x = i.associated_chain_complex_morphism()
64
sage: x
65
Chain complex morphism from Chain complex with at most 3 nonzero terms over Integer Ring to Chain complex with at most 3 nonzero terms over Integer Ring
66
sage: y = x*4
67
sage: z = y*y
68
sage: (y+z)
69
Chain complex morphism from Chain complex with at most 3 nonzero terms over Integer Ring to Chain complex with at most 3 nonzero terms over Integer Ring
70
sage: f = x._matrix_dictionary
71
sage: C = S.chain_complex()
72
sage: G = Hom(C,C)
73
sage: w = G(f)
74
sage: w==x
75
True
76
77
"""
78
79
#*****************************************************************************
80
# Copyright (C) 2009 D. Benjamin Antieau <[email protected]>
81
#
82
# Distributed under the terms of the GNU General Public License (GPL)
83
#
84
# This code is distributed in the hope that it will be useful,
85
# but WITHOUT ANY WARRANTY; without even the implied warranty
86
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
87
#
88
# See the GNU General Public License for more details; the full text
89
# is available at:
90
#
91
# http://www.gnu.org/licenses/
92
#
93
#*****************************************************************************
94
95
import sage.categories.homset
96
import sage.homology.chain_complex_morphism as chain_complex_morphism
97
98
def is_ChainComplexHomspace(x):
99
"""
100
Returns True if and only if x is a morphism of chain complexes.
101
102
EXAMPLES::
103
104
sage: from sage.homology.chain_complex_homspace import is_ChainComplexHomspace
105
sage: T = SimplicialComplex(17,[[1,2,3,4],[7,8,9]])
106
sage: C = T.chain_complex(augmented=True,cochain=True)
107
sage: G = Hom(C,C)
108
sage: is_ChainComplexHomspace(G)
109
True
110
111
"""
112
return isinstance(x,ChainComplexHomspace)
113
114
class ChainComplexHomspace(sage.categories.homset.Homset):
115
"""
116
Class of homspaces of chain complex morphisms.
117
118
EXAMPLES::
119
120
sage: T = SimplicialComplex(17,[[1,2,3,4],[7,8,9]])
121
sage: C = T.chain_complex(augmented=True,cochain=True)
122
sage: G = Hom(C,C)
123
sage: G
124
Set of Morphisms from Chain complex with at most 5 nonzero terms over Integer Ring to Chain complex with at most 5 nonzero terms over Integer Ring in Category of chain complexes over Integer Ring
125
126
"""
127
def __call__(self, f):
128
"""
129
f is a dictionary of matrices in the basis of the chain complex.
130
131
EXAMPLES::
132
133
sage: S = simplicial_complexes.Sphere(5)
134
sage: H = Hom(S,S)
135
sage: i = H.identity()
136
sage: C = S.chain_complex()
137
sage: G = Hom(C,C)
138
sage: x = i.associated_chain_complex_morphism()
139
sage: f = x._matrix_dictionary
140
sage: y = G(f)
141
sage: x==y
142
True
143
144
"""
145
return chain_complex_morphism.ChainComplexMorphism(f, self.domain(), self.codomain())
146
147