Update test_battery.py

This commit is contained in:
calquezar 2024-08-21 13:26:28 +02:00
parent 0588ddbccd
commit ebff16e347

View File

@ -76,7 +76,7 @@ print("Finished battery test", flush=True)
""" """
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION APLn ######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION APLn
"""
def random_pol(apln): def random_pol(apln):
n = apln.n n = apln.n
coef = randint(1,10) coef = randint(1,10)
@ -84,15 +84,16 @@ def random_pol(apln):
gens = apln.gens() gens = apln.gens()
return apln.get_term(apln, coef, exp, gens) return apln.get_term(apln, coef, exp, gens)
n = 4 n = 5
s = SimplicialAlgebraplN(n) s = SimplicialAlgebraplN(n)
s.inject_variables() s.inject_variables()
#cofaces = [x for x in list(powerset(range(n+1)) if len(x) == n] #cofaces = [x for x in list(powerset(range(n+1)) if len(x) == n]
dp = random_pol(s)*prod(s.gens()[s.n+2:]) dp = random_pol(s)*prod(s.gens()[s.n+2:])
print("dp: ",dp, flush=True)
p = dp.solve_primitive().reduce() p = dp.solve_primitive().reduce()
fd = sum([((-1)**f)*p.face(f).integral() for f in range(n+1)]) fd = sum([((-1)**f)*p.face(f).integral() for f in range(n+1)])
print("sum([((-1)**f)*p.face(f).integral() for f in range(n+1)])== dq.integral(): ", fd == dp.integral(), flush=True) print("sum([((-1)**f)*p.face(f).integral() for f in range(n+1)])== dp.integral(): ", fd == dp.integral(), flush=True)
for f in range(n+1): for f in range(n+1):
coface = list(range(n+2)) coface = list(range(n+2))
@ -105,7 +106,45 @@ for f in range(n+1):
#print(q.face(f).reduce() == p, flush=True) #print(q.face(f).reduce() == p, flush=True)
print("(-1)**"+str(f)+")*p.face().integral() == dq.integral(): ", ((-1)**f)*dp.integral() == dq.integral(), flush=True) print("(-1)**"+str(f)+")*p.face().integral() == dq.integral(): ", ((-1)**f)*dp.integral() == dq.integral(), flush=True)
#print(p.integral() == dq.integral(), flush=True) #print(p.integral() == dq.integral(), flush=True)
"""
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION APL(K)
"""
def zip_with_constants(a, l):
return [(a, i) for i in l]
@parallel(ncpus=Integer(24))
def check(A,S):
"""
#S = simplicial_complexes.Sphere(6)
S = simplicial_complexes.K3Surface()
S.set_immutable()
cochainComplex = S.chain_complex(base_ring=QQ).dual()
A = AlgebraAplK(S)
for dim in range(4):
for i in range(1):
v = random_vector(QQ, len(S.n_cells(dim)))
print("Lifting random cochain dim ", dim, flush=True)
a = A.lift_cochain(A.vector_to_cochain(v,dim))
print("Check Apl(K) structure of the lifted element: ",a.check(), flush=True)
da = a.differential()
Diff = cochainComplex.differential(dim)
cda = A.cochain_to_vector(da.integral(),dim+1)
equal = Diff*v == cda
print("Diff*v == cda.integral()", equal, flush=True)
if not equal:
raise Exception("the integrals are not equal ", flush=True)
for cell in S.n_cells(dim+1):
d = da.elements[cell.tuple()]
#s = (-1)**(dim*(dim-1)//2) # [FHT, RHT, p.129]
di = sum([((-1)**(f))*a.elements[cell.face(f).tuple()].integral() for f in range(cell.dimension()+1)])
equal = di == d.integral()
if equal:
print("di == d.integral(): ", equal, flush=True)
else:
raise Exception("the integrals are not equal ", flush=True)
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION WITH RANDOM COCHAINS ######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION WITH RANDOM COCHAINS
@ -141,4 +180,4 @@ for degree in range(5):
print("Start parallel DIFF/INTEGRAL at degree " + str(degree), flush=True) print("Start parallel DIFF/INTEGRAL at degree " + str(degree), flush=True)
results = [i[1] for i in check(data)] results = [i[1] for i in check(data)]
print("Finished battery test", flush=True) print("Finished battery test", flush=True)
""" """