working on propagate method and bug on sorted faces

This commit is contained in:
carlos alquezar 2023-09-20 00:08:54 +02:00
parent f1707006b1
commit 13857b8aca
3 changed files with 97 additions and 13 deletions

17
aplK.py
View File

@ -782,7 +782,7 @@ class AlgebraAplK(UniqueRepresentation, Parent):
apl.integrand(cochain[k]) apl.integrand(cochain[k])
else: else:
values[k] = apl(cochain[k]) values[k] = apl(cochain[k])
# second, we propagate the simplicial information # second, we propagate the simplicial information
simplicial_structure = {} simplicial_structure = {}
for n in reversed(range(max_dim+1)): for n in reversed(range(max_dim+1)):
@ -792,9 +792,10 @@ class AlgebraAplK(UniqueRepresentation, Parent):
simplicial_structure[k] = values[k] + \ simplicial_structure[k] = values[k] + \
self._propagate(cochain, k) self._propagate(cochain, k)
# print(simplicial_structure) # print(simplicial_structure)
return AlgebraAplK.Element(self, simplicial_structure) return AlgebraAplK.Element(self, simplicial_structure)
def _propagate(self, cochain, simplex): def _propagate(self, cochain, simplex):
""" """
Returns the part of the polynomial assigned to 'simplex' related to the Returns the part of the polynomial assigned to 'simplex' related to the
propagation of the simplicial information of its faces propagation of the simplicial information of its faces
@ -807,11 +808,13 @@ class AlgebraAplK(UniqueRepresentation, Parent):
apl = SimplicialAlgebraplN(n) apl = SimplicialAlgebraplN(n)
# we propagate the polynomial (y_1...y_n) # we propagate the polynomial (y_1...y_n)
pol = apl(prod(apl.gens()[n+2:])) pol = apl(prod(apl.gens()[n+2:]))
for f in faces: dict_set_keys = {c:set(c) for c in cochain.keys()}
if f in cochain.keys(): for f in faces: #CUIDADO AQUÍ CON CÓMO ESTÁN ORDENADOS LOS IDENTIFICADORES DE LOS SIMPLICES
value = cochain[f] if set(f) in dict_set_keys.values():
face_indexes = [simplex.index(i) for i in f] face = [k for k, v in dict_set_keys.items() if v == set(f)][0] # get_keys_from_value(dict, value)
#print("dim: ",n," pol: ",pol," face_idx: ",face_indexes," dim: ", n) value = cochain[face]
face_indexes = [simplex.index(i) for i in face]
#print("dim: ",n," pol: ",pol," face_idx: ",face_indexes)
propagation += value * \ propagation += value * \
((-1) ** ((n * (n-1)) // 2)) * factorial(n) * \ ((-1) ** ((n * (n-1)) // 2)) * factorial(n) * \
pol.propagate(face_indexes, dim) pol.propagate(face_indexes, dim)

View File

@ -23,6 +23,8 @@ p012 = 2-t1+t2
#values = {(0,): p0, (1,): p1, (2,): p2, (0,1): p01, (0,2): p02, (1,2): p12, (0,1,2): p012} #values = {(0,): p0, (1,): p1, (2,): p2, (0,1): p01, (0,2): p02, (1,2): p12, (0,1,2): p012}
e1 = A._element_constructor_(values) e1 = A._element_constructor_(values)
""" """
######################################################################
"""
S = SimplicialComplex([[0,1,2,3]],is_mutable=False) S = SimplicialComplex([[0,1,2,3]],is_mutable=False)
A = AlgebraAplK(S) A = AlgebraAplK(S)
s3 = SimplicialAlgebraplN(3) s3 = SimplicialAlgebraplN(3)
@ -55,7 +57,76 @@ values = {(0,): p0, (1,): p1, (2,): p2, (3,):p3,
(0,1,2,3):p0123} (0,1,2,3):p0123}
e1 = A._element_constructor_(values) e1 = A._element_constructor_(values)
de1 = e1.differential() de1 = e1.differential()
"""
#####################################################################
"""
S = SimplicialComplex([[0,1,2],[0,2,3]],is_mutable=False)
A = AlgebraAplK(S)
s2 = SimplicialAlgebraplN(2)
s2.inject_variables()
p012 = t0*y2+t2*y0
p023 = t0*y1+t1*y0
s1 = SimplicialAlgebraplN(1)
s1.inject_variables()
p01 = p012.face(2)
p02 = p012.face(1)
p03 = p023.face(1)
p12 = p012.face(0)
p23 = p023.face(0)
s0 = SimplicialAlgebraplN(0)
s0.inject_variables()
p0 = p01.face(1)
p1 = p01.face(0)
p2 = p12.face(0)
p3 = p03.face(0)
values = {(0,): p0, (1,): p1, (2,): p2, (3,):p3,
(0,1): p01, (0,2): p02, (0,3): p03, (1,2): p12, (2,3): p23,
(0,1,2): p012, (0,2,3): p023}
e1 = A._element_constructor_(values)
de1 = e1.differential()
"""
#####################################################################
S = SimplicialComplex([[0,1,2,3],[0,2,3,4]],is_mutable=False)
A = AlgebraAplK(S)
s3.inject_variables()
p0123 = (t1**2)*y1+t3*y0+y2+t1*y2+t2*y1
p0234 = (t1**2)*y1+t3*y0+y2+t1*y2+t2*y1
s2 = SimplicialAlgebraplN(2)
s2.inject_variables()
p012 = p0123.face(3)
p013 = p0123.face(2)
p023 = p0123.face(1)
p123 = p0123.face(0)
p024 = p0234.face(2)
p034 = p0234.face(1)
p234 = p0234.face(0)
s1 = SimplicialAlgebraplN(1)
s1.inject_variables()
p01 = p012.face(2)
p02 = p012.face(1)
p03 = p013.face(1)
p04 = p024.face(1)
p12 = p012.face(0)
p13 = p013.face(0)
p23 = p123.face(0)
p24 = p024.face(2)
p34 = p034.face(0)
s0 = SimplicialAlgebraplN(0)
s0.inject_variables()
p0 = p01.face(1)
p1 = p01.face(0)
p2 = p12.face(0)
p3 = p03.face(0)
p4 = p04.face(0)
values = {(0,): p0, (1,): p1, (2,): p2, (3,):p3, (4,):p4,
(0,1): p01, (0,2): p02, (0,3): p03, (0,4): p04, (1,2): p12, (1,3):p13, (2,3): p23,
(0,1,2): p012, (0,2,3): p023}
e1 = A._element_constructor_(values)
de1 = e1.differential()
#####################################################################
""" """
for k in de1.elements.keys(): for k in de1.elements.keys():
e = de1.elements[k] e = de1.elements[k]
@ -63,13 +134,14 @@ for k in de1.elements.keys():
if e: if e:
print(e.total_degree()) print(e.total_degree())
""" """
e2 = de1.solve_primitive() e2 = e1.solve_primitive()
print("de1: ",de1) print("de1: ",de1)
print("e2: ",e2) print("e2: ",e2)
print("e1: ",e1)
if e1.differential() == e2.differential(): if e1 == e2.differential():
print("the differentials of e1 and e2 are equal") print("the differential of e2 is EQUAL to e1")
else: else:
print("the differentials are different") print("the differential of e1 is NOT EQUAL to e1")
############################################# #############################################

View File

@ -1,14 +1,23 @@
from sage.all import * from sage.all import *
import itertools
load('aplK.py') load('aplK.py')
load('minimalModel.py') load('minimalModel.py')
####################################################### #######################################################
# TESTS # TESTS
#S1 = simplicial_complexes.Sphere(3) def findsubsests(S,m):
return set(itertools.combinations(S,m))
simplices = [list(e) for e in findsubsets([0,1,2,3],3)]
simplices += [list(e) for e in findsubsets([0,1,2,4],3)]
simplices += [list(e) for e in findsubsets([2,3,4,5],3)]
S = SimplicialComplex(simplices,is_mutable=False)
#S1 = simplicial_complexes.Sphere(2)
#S2 = simplicial_complexes.Sphere(3) #S2 = simplicial_complexes.Sphere(3)
#S = S1.wedge(S2, is_mutable=False) #S = S1.wedge(S2, is_mutable=False)
#S = simplicial_complexes.KleinBottle().suspension() #S = simplicial_complexes.KleinBottle().suspension()
#S.set_immutable() #S.set_immutable()
S = simplicial_complexes.K3Surface() #S = simplicial_complexes.K3Surface()
#print("Complejo simplicial") #print("Complejo simplicial")
#print(S.facets()) #print(S.facets())
####################################################### #######################################################