1 | initial version |
From your question it is not completely clear to me what you expect, since i guess you do not want to play with elements of the symbolic ring, so i imagine that you want to give Python names to the elements of your basis. Here is a suggestion, please explicit more if it is not satisfactory.
When you write:
sage: H = TorusComplex.homology(generators=true) ; H
{0: [(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(0:(1)))],
1: [(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(1:(1, 0))),
(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(1:(0, 1)))],
2: [(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(2:(1)))]}
H
is a dictionary that maps a dimension (an element of the set {0,1,2}) to a
list of 2-uples (vector space, generator). So, you need to recover the list of
generators that appear as second projection of the values of this dictionary.
Here is a possible way:
sage: D = dict()
sage: for dim in H:
....: for n in range(len(H[dim])):
....: D[dim,n] = H[dim][n][1]
sage: D
{(0, 0): Chain(0:(1)),
(1, 0): Chain(1:(1, 0)),
(1, 1): Chain(1:(0, 1)),
(2, 0): Chain(2:(1))}
Now you can easily give Python names to those four chains, that form your graded basis:
sage: a,b,c,d = D[0,0], D[1,0], D[1,1], D[2,0]
Then you can play with them:
sage: a+a
Trivial chain
sage: a+b+a == b
True
sage: a+b
Chain with 2 nonzero terms over Ring of integers modulo 2
sage: b+c
Chain(1:(1, 1))
sage: (a+b+2*c+d)._vec
{0: (1), 1: (1, 0), 2: (1)}
2 | No.2 Revision |
From your question it is not completely clear to me what you expect, since i
i guess you do not want to play with elements of the symbolic ring, ring (which is what "symbol" usually refers to in Sage), so i imagine
that suspect you want to give Python names to the elements of your graded basis. Here is a
a suggestion, please explicit more if it is not satisfactory.
When you write:
sage: H = TorusComplex.homology(generators=true) ; H
{0: [(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(0:(1)))],
1: [(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(1:(1, 0))),
(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(1:(0, 1)))],
2: [(Vector space of dimension 1 over Ring of integers modulo 2,
Chain(2:(1)))]}
H
is a dictionary that maps a dimension (an element of the set {0,1,2}) to a
list of 2-uples (vector space, generator). So, you need to recover the list of
generators that appear as second projection of the values of this dictionary.
Here is a possible way:
sage: D = dict()
sage: for dim in H:
....: for n in range(len(H[dim])):
....: D[dim,n] = H[dim][n][1]
sage: D
{(0, 0): Chain(0:(1)),
(1, 0): Chain(1:(1, 0)),
(1, 1): Chain(1:(0, 1)),
(2, 0): Chain(2:(1))}
Now you can easily give Python names to those four chains, that form your graded basis:
sage: a,b,c,d = D[0,0], D[1,0], D[1,1], D[2,0]
Then you can play with them:
sage: a+a
Trivial chain
sage: a+b+a == b
True
sage: a+b
Chain with 2 nonzero terms over Ring of integers modulo 2
sage: b+c
Chain(1:(1, 1))
sage: (a+b+2*c+d)._vec
{0: (1), 1: (1, 0), 2: (1)}
sage: ascii_art(a+b+2*c+d)
d_2 d_1 d_0 d_-1
0 <---- [1] <---- [1] <---- [1] <----- 0
[0]
As you can see, an element of the homology is stored as dictionary that map each dimension to a vector in the corresponding vector space, which is somehow richer than flat names such as a,b,c,d
since it keeps the graded information.