Ticket #6099: trac_6099-part2.patch
File trac_6099-part2.patch, 19.3 KB (added by , 13 years ago) |
---|
-
doc/en/reference/homology.rst
# HG changeset patch # User J. H. Palmieri <palmieri@math.washington.edu> # Date 1257896204 28800 # Node ID 3fd8b455bb0dda45d8859f01af291fc1e3074ac0 # Parent e5f49948e6673f928ed062b69389dc31cdb2082d ref patch for #6099 diff -r e5f49948e667 -r 3fd8b455bb0d doc/en/reference/homology.rst
a b 12 12 sage/homology/simplicial_complex_homset 13 13 sage/homology/chain_complex 14 14 sage/homology/chain_complex_morphism 15 sage/homology/chain_complex_homs et15 sage/homology/chain_complex_homspace 16 16 sage/homology/examples -
sage/categories/category_types.py
diff -r e5f49948e667 -r 3fd8b455bb0d sage/categories/category_types.py
a b 1311 1311 GroupAlgebras : [MonoidAlgebras, Algebras, Sets],\ 1312 1312 MatrixAlgebras : [Algebras, Sets],\ 1313 1313 RingModules : [AbelianGroups, Sets],\ 1314 ChainComplexes : [ ],\1314 ChainComplexes : [RingModules, AbelianGroups, Sets],\ 1315 1315 FreeModules : [RingModules, AbelianGroups, Sets],\ 1316 1316 VectorSpaces : [FreeModules, RingModules, AbelianGroups, Sets],\ 1317 1317 HeckeModules : [FreeModules, RingModules, AbelianGroups, Sets],\ -
sage/homology/chain_complex.py
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/chain_complex.py
a b 338 338 EXAMPLES:: 339 339 340 340 sage: ChainComplex() 341 Chain complex with at most 0 nonzero terms over Integer Ring .341 Chain complex with at most 0 nonzero terms over Integer Ring 342 342 sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}) 343 343 sage: C 344 Chain complex with at most 2 nonzero terms over Integer Ring .344 Chain complex with at most 2 nonzero terms over Integer Ring 345 345 sage: D = ChainComplex([matrix(ZZ, 2, 2, [0, 1, 0, 0]), matrix(ZZ, 2, 2, [0, 1, 0, 0])], base_ring=GF(2)); D 346 Chain complex with at most 3 nonzero terms over Finite Field of size 2 .346 Chain complex with at most 3 nonzero terms over Finite Field of size 2 347 347 sage: D == loads(dumps(D)) 348 348 True 349 349 … … 361 361 Defining the base ring implicitly:: 362 362 363 363 sage: ChainComplex([matrix(QQ, 3, 1), matrix(ZZ, 4, 3)]) 364 Chain complex with at most 2 nonzero terms over Rational Field .364 Chain complex with at most 2 nonzero terms over Rational Field 365 365 sage: ChainComplex([matrix(GF(125, 'a'), 3, 1), matrix(ZZ, 4, 3)]) 366 Chain complex with at most 2 nonzero terms over Finite Field in a of size 5^3 .366 Chain complex with at most 2 nonzero terms over Finite Field in a of size 5^3 367 367 368 368 If the matrices are defined over incompatible rings, an error results:: 369 369 … … 389 389 EXAMPLES:: 390 390 391 391 sage: C = ChainComplex(); C 392 Chain complex with at most 0 nonzero terms over Integer Ring .392 Chain complex with at most 0 nonzero terms over Integer Ring 393 393 sage: D = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}) 394 394 sage: D 395 Chain complex with at most 2 nonzero terms over Integer Ring .395 Chain complex with at most 2 nonzero terms over Integer Ring 396 396 """ 397 397 try: 398 398 deg = grading_group(degree) … … 882 882 883 883 sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}) 884 884 sage: C._repr_() 885 'Chain complex with at most 2 nonzero terms over Integer Ring .'885 'Chain complex with at most 2 nonzero terms over Integer Ring' 886 886 """ 887 887 diffs = filter(lambda mat: mat.nrows() + mat.ncols() > 0, 888 888 self._diff.values()) 889 889 string1 = "Chain complex with at most" 890 string2 = " %s nonzero terms over %s ." % (len(diffs),890 string2 = " %s nonzero terms over %s" % (len(diffs), 891 891 self._base_ring) 892 892 return string1 + string2 893 893 -
sage/homology/chain_complex_homspace.py
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/chain_complex_homspace.py
a b 16 16 sage: D = T.chain_complex(augmented=True,cochain=True) 17 17 sage: G = Hom(C,D) 18 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 Ring19 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 20 21 21 sage: S = simplicial_complexes.ChessboardComplex(3,3) 22 22 sage: H = Hom(S,S) 23 23 sage: i = H.identity() 24 24 sage: x = i.associated_chain_complex_morphism(augmented=True) 25 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.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 27 sage: x._matrix_dictionary 28 28 {0: [1 0 0 0 0 0 0 0 0] 29 29 [0 1 0 0 0 0 0 0 0] … … 62 62 sage: i = A.identity() 63 63 sage: x = i.associated_chain_complex_morphism() 64 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.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 66 sage: y = x*4 67 67 sage: z = y*y 68 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.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 70 sage: f = x._matrix_dictionary 71 71 sage: C = S.chain_complex() 72 72 sage: G = Hom(C,C) … … 122 122 sage: C = T.chain_complex(augmented=True,cochain=True) 123 123 sage: G = Hom(C,C) 124 124 sage: G 125 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 Ring125 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 126 126 127 127 """ 128 128 def __call__(self, f): -
sage/homology/chain_complex_morphism.py
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/chain_complex_morphism.py
a b 5 5 6 6 - Benjamin Antieau <d.ben.antieau@gmail.com> (2009.06) 7 7 8 This module implements morphisms of simplicialcomplexes. The input is a dictionary whose8 This module implements morphisms of chain complexes. The input is a dictionary whose 9 9 keys are in the grading group of the chain complex and whose values are matrix morphisms. 10 10 11 11 EXAMPLES:: … … 23 23 sage: G = Hom(C,C) 24 24 sage: x = G(f) 25 25 sage: x 26 Chain complex morphism from Chain complex with at most 2 nonzero terms over Integer Ring . to Chain complex with at most 2 nonzero terms over Integer Ring.26 Chain complex morphism from Chain complex with at most 2 nonzero terms over Integer Ring to Chain complex with at most 2 nonzero terms over Integer Ring 27 27 sage: x._matrix_dictionary 28 28 {0: [0 0 0] 29 29 [0 0 0] … … 69 69 sage: i = H.identity() 70 70 sage: x = i.associated_chain_complex_morphism() 71 71 sage: x # indirect doctest 72 Chain complex morphism from Chain complex with at most 7 nonzero terms over Integer Ring . to Chain complex with at most 7 nonzero terms over Integer Ring.72 Chain complex morphism from Chain complex with at most 7 nonzero terms over Integer Ring to Chain complex with at most 7 nonzero terms over Integer Ring 73 73 sage: is_ChainComplexMorphism(x) 74 74 True 75 75 … … 99 99 sage: G = Hom(C,C) 100 100 sage: x = G(f) 101 101 sage: x 102 Chain complex morphism from Chain complex with at most 2 nonzero terms over Integer Ring . to Chain complex with at most 2 nonzero terms over Integer Ring.102 Chain complex morphism from Chain complex with at most 2 nonzero terms over Integer Ring to Chain complex with at most 2 nonzero terms over Integer Ring 103 103 sage: x._matrix_dictionary 104 104 {0: [0 0 0] 105 105 [0 0 0] … … 225 225 Returns self*x if self and x are composable morphisms or if x is an element of the base_ring. 226 226 227 227 EXAMPLES:: 228 228 229 sage: S = simplicial_complexes.Sphere(2) 229 230 sage: H = Hom(S,S) 230 231 sage: i = H.identity() … … 270 271 raise TypeError, "Multiplication is not defined." 271 272 f = dict() 272 273 for i in self._matrix_dictionary.keys(): 273 f[i] = y * self._matrix_dictionary[i]274 f[i] = self._matrix_dictionary[i] * y 274 275 return ChainComplexMorphism(f,self._domain,self._codomain) 275 276 f = dict() 276 277 for i in self._matrix_dictionary.keys(): 277 278 f[i] = x._matrix_dictionary[i]*self._matrix_dictionary[i] 278 279 return ChainComplexMorphism(f,self._domain,x._codomain) 279 280 281 def __rmul__(self,x): 282 """ 283 Returns x*self if x is an element of the base_ring. 284 285 EXAMPLES:: 286 287 sage: S = simplicial_complexes.Sphere(2) 288 sage: H = Hom(S,S) 289 sage: i = H.identity() 290 sage: x = i.associated_chain_complex_morphism() 291 sage: 2*x == x*2 292 True 293 sage: 3*x == x*2 294 False 295 """ 296 try: 297 y = self._domain.base_ring()(x) 298 except TypeError: 299 raise TypeError, "Multiplication is not defined." 300 f = dict() 301 for i in self._matrix_dictionary.keys(): 302 f[i] = y * self._matrix_dictionary[i] 303 return ChainComplexMorphism(f,self._domain,self._codomain) 304 280 305 def __sub__(self,x): 281 306 """ 282 307 Returns self-x. … … 318 343 sage: i = H.identity() 319 344 sage: x = i.associated_chain_complex_morphism() 320 345 sage: x 321 Chain complex morphism from Chain complex with at most 0 nonzero terms over Integer Ring . to Chain complex with at most 0 nonzero terms over Integer Ring.346 Chain complex morphism from Chain complex with at most 0 nonzero terms over Integer Ring to Chain complex with at most 0 nonzero terms over Integer Ring 322 347 sage: f = x._matrix_dictionary 323 348 sage: C = S.chain_complex() 324 349 sage: G = Hom(C,C) … … 343 368 sage: i = H.identity() 344 369 sage: x = i.associated_chain_complex_morphism() 345 370 sage: x 346 Chain complex morphism from Chain complex with at most 0 nonzero terms over Integer Ring . to Chain complex with at most 0 nonzero terms over Integer Ring.371 Chain complex morphism from Chain complex with at most 0 nonzero terms over Integer Ring to Chain complex with at most 0 nonzero terms over Integer Ring 347 372 sage: x._repr_() 348 'Chain complex morphism from Chain complex with at most 0 nonzero terms over Integer Ring . to Chain complex with at most 0 nonzero terms over Integer Ring.'373 'Chain complex morphism from Chain complex with at most 0 nonzero terms over Integer Ring to Chain complex with at most 0 nonzero terms over Integer Ring' 349 374 350 375 """ 351 376 return "Chain complex morphism from " + self._domain._repr_() + " to " + self._codomain._repr_() -
sage/homology/simplicial_complex.py
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/simplicial_complex.py
a b 1179 1179 1180 1180 sage: circle = SimplicialComplex(2, [[0,1], [1,2], [0, 2]]) 1181 1181 sage: circle.chain_complex() 1182 Chain complex with at most 2 nonzero terms over Integer Ring .1182 Chain complex with at most 2 nonzero terms over Integer Ring 1183 1183 sage: circle.chain_complex()._latex_() 1184 1184 '\\Bold{Z}^{3} \\xrightarrow{d_{1}} \\Bold{Z}^{3}' 1185 1185 sage: circle.chain_complex(base_ring=QQ, augmented=True) 1186 Chain complex with at most 3 nonzero terms over Rational Field .1186 Chain complex with at most 3 nonzero terms over Rational Field 1187 1187 """ 1188 1188 # initialize subcomplex 1189 1189 if subcomplex is None: … … 1750 1750 1751 1751 def generated_subcomplex(self,sub_vertex_set): 1752 1752 """ 1753 Returns the largest sub SimplicialComplex of self containing exactly the sub_vertex_set as vertices. 1753 Returns the largest sub-simplicial complex of self containing 1754 exactly ``sub_vertex_set`` as vertices. 1754 1755 1755 1756 EXAMPLES:: 1756 1757 -
sage/homology/simplicial_complex_morphism.py
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/simplicial_complex_morphism.py
a b 94 94 import sage.categories.category_types as category_types 95 95 from sage.rings.integer_ring import ZZ 96 96 from sage.homology.chain_complex_morphism import ChainComplexMorphism 97 from sage.combinat.permutation import Permutation 98 from sage.algebras.steenrod_algebra_element import convert_perm 97 99 98 100 def is_SimplicialComplexMorphism(x): 99 101 """ … … 193 195 else: 194 196 return True 195 197 196 def __call__(self,x ):198 def __call__(self,x,orientation=False): 197 199 """ 198 200 Input is a simplex of the domain. Output is the image simplex. 201 If optional argument ``orientation`` is True, return a pair 202 ``(image simplex, oriented)`` where ``oriented`` is 1 or `-1` 203 depending on whether the map preserves or reverses the 204 orientation of the image simplex. 199 205 200 206 EXAMPLES:: 201 207 … … 212 218 sage: x(Simplex([0,2,3])) 213 219 (0, 2, 3) 214 220 221 An orientation-reversing example:: 222 223 sage: X = SimplicialComplex(1, [[0,1]]) 224 sage: g = Hom(X,X)({0:1, 1:0}) 225 sage: g(Simplex([0,1])) 226 (0, 1) 227 sage: g(Simplex([0,1]), orientation=True) 228 ((0, 1), -1) 215 229 """ 216 230 dim = self._domain.dimension() 217 231 if not isinstance(x,simplicial_complex.Simplex) or x.dimension() > dim or not x in self._domain.faces()[x.dimension()]: … … 220 234 fx=[] 221 235 for j in tup: 222 236 fx.append(self._vertex_dictionary[j]) 223 return simplicial_complex.Simplex(set(fx)) 237 if orientation: 238 if len(set(fx)) == len(tup): 239 oriented = Permutation(convert_perm(fx)).signature() 240 else: 241 oriented = 1 242 return (simplicial_complex.Simplex(set(fx)), oriented) 243 else: 244 return simplicial_complex.Simplex(set(fx)) 224 245 225 246 def _repr_(self): 226 247 """ … … 255 276 Simplicial complex morphism {0: 0, 1: 1, 2: 2} from Simplicial complex with vertex set (0, 1, 2) and facets {(1, 2), (0, 2), (0, 1)} to Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 2, 3), (0, 1, 2), (1, 2, 3), (0, 1, 3)} 256 277 sage: a = x.associated_chain_complex_morphism() 257 278 sage: a 258 Chain complex morphism from Chain complex with at most 2 nonzero terms over Integer Ring . to Chain complex with at most 3 nonzero terms over Integer Ring.279 Chain complex morphism from Chain complex with at most 2 nonzero terms over Integer Ring to Chain complex with at most 3 nonzero terms over Integer Ring 259 280 sage: a._matrix_dictionary 260 281 {0: [0 0 0] 261 282 [0 1 0] … … 269 290 [0 0 1], 270 291 2: []} 271 292 sage: x.associated_chain_complex_morphism(augmented=True) 272 Chain complex morphism from Chain complex with at most 3 nonzero terms over Integer Ring . to Chain complex with at most 4 nonzero terms over Integer Ring.293 Chain complex morphism from Chain complex with at most 3 nonzero terms over Integer Ring to Chain complex with at most 4 nonzero terms over Integer Ring 273 294 sage: x.associated_chain_complex_morphism(cochain=True) 274 Chain complex morphism from Chain complex with at most 3 nonzero terms over Integer Ring . to Chain complex with at most 2 nonzero terms over Integer Ring.295 Chain complex morphism from Chain complex with at most 3 nonzero terms over Integer Ring to Chain complex with at most 2 nonzero terms over Integer Ring 275 296 sage: x.associated_chain_complex_morphism(augmented=True,cochain=True) 276 Chain complex morphism from Chain complex with at most 4 nonzero terms over Integer Ring . to Chain complex with at most 3 nonzero terms over Integer Ring.297 Chain complex morphism from Chain complex with at most 4 nonzero terms over Integer Ring to Chain complex with at most 3 nonzero terms over Integer Ring 277 298 sage: x.associated_chain_complex_morphism(base_ring=GF(11)) 278 Chain complex morphism from Chain complex with at most 2 nonzero terms over Finite Field of size 11 . to Chain complex with at most 3 nonzero terms over Finite Field of size 11.299 Chain complex morphism from Chain complex with at most 2 nonzero terms over Finite Field of size 11 to Chain complex with at most 3 nonzero terms over Finite Field of size 11 279 300 301 Some simplicial maps which reverse the orientation of a few simplices:: 302 303 sage: g = {0:1, 1:2, 2:0} 304 sage: H(g).associated_chain_complex_morphism()._matrix_dictionary 305 {0: [0 0 0] 306 [1 0 0] 307 [0 1 0] 308 [0 0 1], 1: [ 0 0 0] 309 [-1 0 0] 310 [ 0 0 0] 311 [ 0 0 1] 312 [ 0 0 0] 313 [ 0 -1 0], 2: []} 314 315 sage: X = SimplicialComplex(1, [[0, 1]]) 316 sage: Hom(X,X)({0:1, 1:0}).associated_chain_complex_morphism()._matrix_dictionary 317 {0: [0 1] 318 [1 0], 1: [-1]} 280 319 """ 281 320 max_dim = max(self._domain.dimension(),self._codomain.dimension()) 282 321 min_dim = min(self._domain.dimension(),self._codomain.dimension()) … … 294 333 num_faces_Y = len(Y_faces) 295 334 mval = [0 for i in range(num_faces_X*num_faces_Y)] 296 335 for i in X_faces: 297 y = self(i)336 y, oriented = self(i, orientation=True) 298 337 if y.dimension() < dim: 299 338 pass 300 339 else: 301 mval[X_faces.index(i)+(Y_faces.index(y)*num_faces_X)] = 1340 mval[X_faces.index(i)+(Y_faces.index(y)*num_faces_X)] = oriented 302 341 m = matrix.Matrix(base_ring,num_faces_Y,num_faces_X,mval,sparse=True) 303 342 if not cochain: 304 343 matrices[dim] = m