# HG changeset patch
# User J. H. Palmieri
# Date 1257896204 28800
# Node ID 3fd8b455bb0dda45d8859f01af291fc1e3074ac0
# Parent e5f49948e6673f928ed062b69389dc31cdb2082d
ref patch for #6099
diff -r e5f49948e667 -r 3fd8b455bb0d doc/en/reference/homology.rst
--- a/doc/en/reference/homology.rst Fri Nov 06 15:16:06 2009 -0600
+++ b/doc/en/reference/homology.rst Tue Nov 10 15:36:44 2009 -0800
@@ -12,5 +12,5 @@
sage/homology/simplicial_complex_homset
sage/homology/chain_complex
sage/homology/chain_complex_morphism
- sage/homology/chain_complex_homset
+ sage/homology/chain_complex_homspace
sage/homology/examples
diff -r e5f49948e667 -r 3fd8b455bb0d sage/categories/category_types.py
--- a/sage/categories/category_types.py Fri Nov 06 15:16:06 2009 -0600
+++ b/sage/categories/category_types.py Tue Nov 10 15:36:44 2009 -0800
@@ -1311,7 +1311,7 @@
GroupAlgebras : [MonoidAlgebras, Algebras, Sets],\
MatrixAlgebras : [Algebras, Sets],\
RingModules : [AbelianGroups, Sets],\
- ChainComplexes : [],\
+ ChainComplexes : [RingModules, AbelianGroups, Sets],\
FreeModules : [RingModules, AbelianGroups, Sets],\
VectorSpaces : [FreeModules, RingModules, AbelianGroups, Sets],\
HeckeModules : [FreeModules, RingModules, AbelianGroups, Sets],\
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/chain_complex.py
--- a/sage/homology/chain_complex.py Fri Nov 06 15:16:06 2009 -0600
+++ b/sage/homology/chain_complex.py Tue Nov 10 15:36:44 2009 -0800
@@ -338,12 +338,12 @@
EXAMPLES::
sage: ChainComplex()
- Chain complex with at most 0 nonzero terms over Integer Ring.
+ Chain complex with at most 0 nonzero terms over Integer Ring
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
sage: C
- Chain complex with at most 2 nonzero terms over Integer Ring.
+ Chain complex with at most 2 nonzero terms over Integer Ring
sage: D = ChainComplex([matrix(ZZ, 2, 2, [0, 1, 0, 0]), matrix(ZZ, 2, 2, [0, 1, 0, 0])], base_ring=GF(2)); D
- Chain complex with at most 3 nonzero terms over Finite Field of size 2.
+ Chain complex with at most 3 nonzero terms over Finite Field of size 2
sage: D == loads(dumps(D))
True
@@ -361,9 +361,9 @@
Defining the base ring implicitly::
sage: ChainComplex([matrix(QQ, 3, 1), matrix(ZZ, 4, 3)])
- Chain complex with at most 2 nonzero terms over Rational Field.
+ Chain complex with at most 2 nonzero terms over Rational Field
sage: ChainComplex([matrix(GF(125, 'a'), 3, 1), matrix(ZZ, 4, 3)])
- Chain complex with at most 2 nonzero terms over Finite Field in a of size 5^3.
+ Chain complex with at most 2 nonzero terms over Finite Field in a of size 5^3
If the matrices are defined over incompatible rings, an error results::
@@ -389,10 +389,10 @@
EXAMPLES::
sage: C = ChainComplex(); C
- Chain complex with at most 0 nonzero terms over Integer Ring.
+ Chain complex with at most 0 nonzero terms over Integer Ring
sage: D = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
sage: D
- Chain complex with at most 2 nonzero terms over Integer Ring.
+ Chain complex with at most 2 nonzero terms over Integer Ring
"""
try:
deg = grading_group(degree)
@@ -882,12 +882,12 @@
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
sage: C._repr_()
- 'Chain complex with at most 2 nonzero terms over Integer Ring.'
+ 'Chain complex with at most 2 nonzero terms over Integer Ring'
"""
diffs = filter(lambda mat: mat.nrows() + mat.ncols() > 0,
self._diff.values())
string1 = "Chain complex with at most"
- string2 = " %s nonzero terms over %s." % (len(diffs),
+ string2 = " %s nonzero terms over %s" % (len(diffs),
self._base_ring)
return string1 + string2
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/chain_complex_homspace.py
--- a/sage/homology/chain_complex_homspace.py Fri Nov 06 15:16:06 2009 -0600
+++ b/sage/homology/chain_complex_homspace.py Tue Nov 10 15:36:44 2009 -0800
@@ -16,14 +16,14 @@
sage: D = T.chain_complex(augmented=True,cochain=True)
sage: G = Hom(C,D)
sage: G
- 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
+ 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
sage: S = simplicial_complexes.ChessboardComplex(3,3)
sage: H = Hom(S,S)
sage: i = H.identity()
sage: x = i.associated_chain_complex_morphism(augmented=True)
sage: x
- 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.
+ 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
sage: x._matrix_dictionary
{0: [1 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0]
@@ -62,11 +62,11 @@
sage: i = A.identity()
sage: x = i.associated_chain_complex_morphism()
sage: x
- 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.
+ 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
sage: y = x*4
sage: z = y*y
sage: (y+z)
- 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.
+ 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
sage: f = x._matrix_dictionary
sage: C = S.chain_complex()
sage: G = Hom(C,C)
@@ -122,7 +122,7 @@
sage: C = T.chain_complex(augmented=True,cochain=True)
sage: G = Hom(C,C)
sage: G
- 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
+ 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
"""
def __call__(self, f):
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/chain_complex_morphism.py
--- a/sage/homology/chain_complex_morphism.py Fri Nov 06 15:16:06 2009 -0600
+++ b/sage/homology/chain_complex_morphism.py Tue Nov 10 15:36:44 2009 -0800
@@ -5,7 +5,7 @@
- Benjamin Antieau (2009.06)
-This module implements morphisms of simplicial complexes. The input is a dictionary whose
+This module implements morphisms of chain complexes. The input is a dictionary whose
keys are in the grading group of the chain complex and whose values are matrix morphisms.
EXAMPLES::
@@ -23,7 +23,7 @@
sage: G = Hom(C,C)
sage: x = G(f)
sage: x
- 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.
+ 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
sage: x._matrix_dictionary
{0: [0 0 0]
[0 0 0]
@@ -69,7 +69,7 @@
sage: i = H.identity()
sage: x = i.associated_chain_complex_morphism()
sage: x # indirect doctest
- 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.
+ 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
sage: is_ChainComplexMorphism(x)
True
@@ -99,7 +99,7 @@
sage: G = Hom(C,C)
sage: x = G(f)
sage: x
- 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.
+ 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
sage: x._matrix_dictionary
{0: [0 0 0]
[0 0 0]
@@ -225,6 +225,7 @@
Returns self*x if self and x are composable morphisms or if x is an element of the base_ring.
EXAMPLES::
+
sage: S = simplicial_complexes.Sphere(2)
sage: H = Hom(S,S)
sage: i = H.identity()
@@ -270,13 +271,37 @@
raise TypeError, "Multiplication is not defined."
f = dict()
for i in self._matrix_dictionary.keys():
- f[i] = y * self._matrix_dictionary[i]
+ f[i] = self._matrix_dictionary[i] * y
return ChainComplexMorphism(f,self._domain,self._codomain)
f = dict()
for i in self._matrix_dictionary.keys():
f[i] = x._matrix_dictionary[i]*self._matrix_dictionary[i]
return ChainComplexMorphism(f,self._domain,x._codomain)
+ def __rmul__(self,x):
+ """
+ Returns x*self if x is an element of the base_ring.
+
+ EXAMPLES::
+
+ sage: S = simplicial_complexes.Sphere(2)
+ sage: H = Hom(S,S)
+ sage: i = H.identity()
+ sage: x = i.associated_chain_complex_morphism()
+ sage: 2*x == x*2
+ True
+ sage: 3*x == x*2
+ False
+ """
+ try:
+ y = self._domain.base_ring()(x)
+ except TypeError:
+ raise TypeError, "Multiplication is not defined."
+ f = dict()
+ for i in self._matrix_dictionary.keys():
+ f[i] = y * self._matrix_dictionary[i]
+ return ChainComplexMorphism(f,self._domain,self._codomain)
+
def __sub__(self,x):
"""
Returns self-x.
@@ -318,7 +343,7 @@
sage: i = H.identity()
sage: x = i.associated_chain_complex_morphism()
sage: x
- 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.
+ 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
sage: f = x._matrix_dictionary
sage: C = S.chain_complex()
sage: G = Hom(C,C)
@@ -343,9 +368,9 @@
sage: i = H.identity()
sage: x = i.associated_chain_complex_morphism()
sage: x
- 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.
+ 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
sage: x._repr_()
- '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.'
+ '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'
"""
return "Chain complex morphism from " + self._domain._repr_() + " to " + self._codomain._repr_()
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/simplicial_complex.py
--- a/sage/homology/simplicial_complex.py Fri Nov 06 15:16:06 2009 -0600
+++ b/sage/homology/simplicial_complex.py Tue Nov 10 15:36:44 2009 -0800
@@ -1179,11 +1179,11 @@
sage: circle = SimplicialComplex(2, [[0,1], [1,2], [0, 2]])
sage: circle.chain_complex()
- Chain complex with at most 2 nonzero terms over Integer Ring.
+ Chain complex with at most 2 nonzero terms over Integer Ring
sage: circle.chain_complex()._latex_()
'\\Bold{Z}^{3} \\xrightarrow{d_{1}} \\Bold{Z}^{3}'
sage: circle.chain_complex(base_ring=QQ, augmented=True)
- Chain complex with at most 3 nonzero terms over Rational Field.
+ Chain complex with at most 3 nonzero terms over Rational Field
"""
# initialize subcomplex
if subcomplex is None:
@@ -1750,7 +1750,8 @@
def generated_subcomplex(self,sub_vertex_set):
"""
- Returns the largest sub SimplicialComplex of self containing exactly the sub_vertex_set as vertices.
+ Returns the largest sub-simplicial complex of self containing
+ exactly ``sub_vertex_set`` as vertices.
EXAMPLES::
diff -r e5f49948e667 -r 3fd8b455bb0d sage/homology/simplicial_complex_morphism.py
--- a/sage/homology/simplicial_complex_morphism.py Fri Nov 06 15:16:06 2009 -0600
+++ b/sage/homology/simplicial_complex_morphism.py Tue Nov 10 15:36:44 2009 -0800
@@ -94,6 +94,8 @@
import sage.categories.category_types as category_types
from sage.rings.integer_ring import ZZ
from sage.homology.chain_complex_morphism import ChainComplexMorphism
+from sage.combinat.permutation import Permutation
+from sage.algebras.steenrod_algebra_element import convert_perm
def is_SimplicialComplexMorphism(x):
"""
@@ -193,9 +195,13 @@
else:
return True
- def __call__(self,x):
+ def __call__(self,x,orientation=False):
"""
Input is a simplex of the domain. Output is the image simplex.
+ If optional argument ``orientation`` is True, return a pair
+ ``(image simplex, oriented)`` where ``oriented`` is 1 or `-1`
+ depending on whether the map preserves or reverses the
+ orientation of the image simplex.
EXAMPLES::
@@ -212,6 +218,14 @@
sage: x(Simplex([0,2,3]))
(0, 2, 3)
+ An orientation-reversing example::
+
+ sage: X = SimplicialComplex(1, [[0,1]])
+ sage: g = Hom(X,X)({0:1, 1:0})
+ sage: g(Simplex([0,1]))
+ (0, 1)
+ sage: g(Simplex([0,1]), orientation=True)
+ ((0, 1), -1)
"""
dim = self._domain.dimension()
if not isinstance(x,simplicial_complex.Simplex) or x.dimension() > dim or not x in self._domain.faces()[x.dimension()]:
@@ -220,7 +234,14 @@
fx=[]
for j in tup:
fx.append(self._vertex_dictionary[j])
- return simplicial_complex.Simplex(set(fx))
+ if orientation:
+ if len(set(fx)) == len(tup):
+ oriented = Permutation(convert_perm(fx)).signature()
+ else:
+ oriented = 1
+ return (simplicial_complex.Simplex(set(fx)), oriented)
+ else:
+ return simplicial_complex.Simplex(set(fx))
def _repr_(self):
"""
@@ -255,7 +276,7 @@
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)}
sage: a = x.associated_chain_complex_morphism()
sage: a
- 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.
+ 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
sage: a._matrix_dictionary
{0: [0 0 0]
[0 1 0]
@@ -269,14 +290,32 @@
[0 0 1],
2: []}
sage: x.associated_chain_complex_morphism(augmented=True)
- 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.
+ 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
sage: x.associated_chain_complex_morphism(cochain=True)
- 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.
+ 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
sage: x.associated_chain_complex_morphism(augmented=True,cochain=True)
- 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.
+ 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
sage: x.associated_chain_complex_morphism(base_ring=GF(11))
- 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.
+ 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
+ Some simplicial maps which reverse the orientation of a few simplices::
+
+ sage: g = {0:1, 1:2, 2:0}
+ sage: H(g).associated_chain_complex_morphism()._matrix_dictionary
+ {0: [0 0 0]
+ [1 0 0]
+ [0 1 0]
+ [0 0 1], 1: [ 0 0 0]
+ [-1 0 0]
+ [ 0 0 0]
+ [ 0 0 1]
+ [ 0 0 0]
+ [ 0 -1 0], 2: []}
+
+ sage: X = SimplicialComplex(1, [[0, 1]])
+ sage: Hom(X,X)({0:1, 1:0}).associated_chain_complex_morphism()._matrix_dictionary
+ {0: [0 1]
+ [1 0], 1: [-1]}
"""
max_dim = max(self._domain.dimension(),self._codomain.dimension())
min_dim = min(self._domain.dimension(),self._codomain.dimension())
@@ -294,11 +333,11 @@
num_faces_Y = len(Y_faces)
mval = [0 for i in range(num_faces_X*num_faces_Y)]
for i in X_faces:
- y = self(i)
+ y, oriented = self(i, orientation=True)
if y.dimension() < dim:
pass
else:
- mval[X_faces.index(i)+(Y_faces.index(y)*num_faces_X)] = 1
+ mval[X_faces.index(i)+(Y_faces.index(y)*num_faces_X)] = oriented
m = matrix.Matrix(base_ring,num_faces_Y,num_faces_X,mval,sparse=True)
if not cochain:
matrices[dim] = m