# How to access the chains of the chain complex of a simplex? Anonymous

I have a simplicial complex and I want to get the chains of its chain complex. I have the following code:

S = SimplicialComplex([[1,2],[1,3],[1,4],[2,3],[2,4]])
print(S.chain_complex().homology(generators=True))


It prints:

Chain(1:(1, 0, -1, 0, 1))


which is one of the chains of dimension one. It is of type

 <class 'sage.homology.chain_comenter code hereplex.ChainComplex_class_with_category.element_class'>


How do I access the list of numbers (1, 0, -1, 0, 1) of this chain?

edit retag close merge delete

Sort by » oldest newest most voted You want the vector method:

sage: S = SimplicialComplex([[1,2],[1,3],[1,4],[2,3],[2,4]])
sage: H = S.chain_complex().homology(generators=True)
sage: H.vector?
Signature:      H.vector(degree)
Docstring:
Return the free module element in "degree".

EXAMPLES:

sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
sage: c = C({0:vector([1, 2, 3]), 1:vector([4, 5])})
sage: c.vector(0)
(1, 2, 3)
sage: c.vector(1)
(4, 5)
sage: c.vector(2)
()
Init docstring: Initialize self.  See help(type(self)) for accurate signature.
File:           ~/Desktop/Sage/git/sage/src/sage/homology/chain_complex.py
Type:           method
sage: H.vector(1)
(1, 0, -1, 0, 1)
sage: v = H.vector(1)
sage: type(v)
<class 'sage.modules.vector_integer_dense.Vector_integer_dense'>

more