Path: blob/master/sage/homology/chain_complex_homspace.py
4108 views
r"""1Homspaces between chain complexes23Note that some significant functionality is lacking. Namely, the homspaces4are not actually modules over the base ring. It will be necessary to5enrich some of the structure of chain complexes for this to be naturally6available. On other hand, there are various overloaded operators. __mul__7acts as composition. One can __add__, and one can __mul__ with a ring element8on the right.910EXAMPLES::1112sage: S = simplicial_complexes.Sphere(2)13sage: T = simplicial_complexes.Torus()14sage: C = S.chain_complex(augmented=True,cochain=True)15sage: D = T.chain_complex(augmented=True,cochain=True)16sage: G = Hom(C,D)17sage: G18Set 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 Ring1920sage: S = simplicial_complexes.ChessboardComplex(3,3)21sage: H = Hom(S,S)22sage: i = H.identity()23sage: x = i.associated_chain_complex_morphism(augmented=True)24sage: x25Chain 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 Ring26sage: x._matrix_dictionary27{0: [1 0 0 0 0 0 0 0 0]28[0 1 0 0 0 0 0 0 0]29[0 0 1 0 0 0 0 0 0]30[0 0 0 1 0 0 0 0 0]31[0 0 0 0 1 0 0 0 0]32[0 0 0 0 0 1 0 0 0]33[0 0 0 0 0 0 1 0 0]34[0 0 0 0 0 0 0 1 0]35[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]36[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]37[0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]38[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]39[0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]40[0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]41[0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]42[0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]43[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]44[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]45[0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]46[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]47[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]48[0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]49[0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]50[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]51[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0]52[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]53[0 1 0 0 0 0]54[0 0 1 0 0 0]55[0 0 0 1 0 0]56[0 0 0 0 1 0]57[0 0 0 0 0 1], -1: [1]}5859sage: S = simplicial_complexes.Sphere(2)60sage: A = Hom(S,S)61sage: i = A.identity()62sage: x = i.associated_chain_complex_morphism()63sage: x64Chain 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 Ring65sage: y = x*466sage: z = y*y67sage: (y+z)68Chain 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 Ring69sage: f = x._matrix_dictionary70sage: C = S.chain_complex()71sage: G = Hom(C,C)72sage: w = G(f)73sage: w==x74True7576"""7778#*****************************************************************************79# Copyright (C) 2009 D. Benjamin Antieau <[email protected]>80#81# Distributed under the terms of the GNU General Public License (GPL)82#83# This code is distributed in the hope that it will be useful,84# but WITHOUT ANY WARRANTY; without even the implied warranty85# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.86#87# See the GNU General Public License for more details; the full text88# is available at:89#90# http://www.gnu.org/licenses/91#92#*****************************************************************************9394import sage.categories.homset95import sage.homology.chain_complex_morphism as chain_complex_morphism9697def is_ChainComplexHomspace(x):98"""99Returns True if and only if x is a morphism of chain complexes.100101EXAMPLES::102103sage: from sage.homology.chain_complex_homspace import is_ChainComplexHomspace104sage: T = SimplicialComplex(17,[[1,2,3,4],[7,8,9]])105sage: C = T.chain_complex(augmented=True,cochain=True)106sage: G = Hom(C,C)107sage: is_ChainComplexHomspace(G)108True109110"""111return isinstance(x,ChainComplexHomspace)112113class ChainComplexHomspace(sage.categories.homset.Homset):114"""115Class of homspaces of chain complex morphisms.116117EXAMPLES::118119sage: T = SimplicialComplex(17,[[1,2,3,4],[7,8,9]])120sage: C = T.chain_complex(augmented=True,cochain=True)121sage: G = Hom(C,C)122sage: G123Set 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 Ring124125"""126def __call__(self, f):127"""128f is a dictionary of matrices in the basis of the chain complex.129130EXAMPLES::131132sage: S = simplicial_complexes.Sphere(5)133sage: H = Hom(S,S)134sage: i = H.identity()135sage: C = S.chain_complex()136sage: G = Hom(C,C)137sage: x = i.associated_chain_complex_morphism()138sage: f = x._matrix_dictionary139sage: y = G(f)140sage: x==y141True142143"""144return chain_complex_morphism.ChainComplexMorphism(f, self.domain(), self.codomain())145146147