Update aplK.py
This commit is contained in:
parent
ca4194694c
commit
ff67beab63
38
aplK.py
38
aplK.py
@ -168,6 +168,7 @@ class AplN(DifferentialGCAlgebra_multigraded, UniqueRepresentation):
|
|||||||
for k in self.homogeneous_parts() if list(k)[0] == degree]
|
for k in self.homogeneous_parts() if list(k)[0] == degree]
|
||||||
return self.parent()(sum(parts))
|
return self.parent()(sum(parts))
|
||||||
|
|
||||||
|
#@cached_function
|
||||||
def reduce(self, relations=[]):
|
def reduce(self, relations=[]):
|
||||||
""""
|
""""
|
||||||
The method reduces the polynomial by the Ideal <sum(t_i)-1, sum(y_j)>
|
The method reduces the polynomial by the Ideal <sum(t_i)-1, sum(y_j)>
|
||||||
@ -350,7 +351,7 @@ class AplN(DifferentialGCAlgebra_multigraded, UniqueRepresentation):
|
|||||||
else:
|
else:
|
||||||
return w+theta.primitive()
|
return w+theta.primitive()
|
||||||
|
|
||||||
|
@cached_function
|
||||||
def AlgebraPL(n):
|
def AlgebraPL(n):
|
||||||
"""
|
"""
|
||||||
The graded commutative differential cochain algebra Apl of dimension ``n``
|
The graded commutative differential cochain algebra Apl of dimension ``n``
|
||||||
@ -435,7 +436,8 @@ class SimplicialAplN(AplN, UniqueRepresentation):
|
|||||||
yImages.append(codomain.gens()[n+k-2])
|
yImages.append(codomain.gens()[n+k-2])
|
||||||
images = tImages+yImages
|
images = tImages+yImages
|
||||||
return domain.hom(codomain=codomain, im_gens=images)
|
return domain.hom(codomain=codomain, im_gens=images)
|
||||||
|
|
||||||
|
@cached_method
|
||||||
def face(self, i):
|
def face(self, i):
|
||||||
""""
|
""""
|
||||||
|
|
||||||
@ -505,7 +507,8 @@ class SimplicialAplN(AplN, UniqueRepresentation):
|
|||||||
- A polynomial that is the degeneration 'j' of self
|
- A polynomial that is the degeneration 'j' of self
|
||||||
"""
|
"""
|
||||||
return self.degeneration_morphism(j)(self)
|
return self.degeneration_morphism(j)(self)
|
||||||
|
|
||||||
|
#@cached_function
|
||||||
def propagate(self, face_list, dest_dim):
|
def propagate(self, face_list, dest_dim):
|
||||||
"""
|
"""
|
||||||
Returns a polynomial in dimension 'dest_dim' that has 'self' as a face
|
Returns a polynomial in dimension 'dest_dim' that has 'self' as a face
|
||||||
@ -648,7 +651,7 @@ class SimplicialAplN(AplN, UniqueRepresentation):
|
|||||||
sol = Mdif.solve_right(v)
|
sol = Mdif.solve_right(v)
|
||||||
return sum(map(lambda x, y: x*y, sol, primitive_basis))
|
return sum(map(lambda x, y: x*y, sol, primitive_basis))
|
||||||
|
|
||||||
|
@cached_function
|
||||||
def SimplicialAlgebraplN(n):
|
def SimplicialAlgebraplN(n):
|
||||||
"""
|
"""
|
||||||
Returns the graded commutative differential cochain algebra (Apl)_n as part of
|
Returns the graded commutative differential cochain algebra (Apl)_n as part of
|
||||||
@ -749,6 +752,7 @@ class AlgebraAplK(UniqueRepresentation, Parent):
|
|||||||
"""
|
"""
|
||||||
return [tuple(e) for e in Set(simplex).subsets(length)]
|
return [tuple(e) for e in Set(simplex).subsets(length)]
|
||||||
|
|
||||||
|
@cached_function
|
||||||
def zero(self):
|
def zero(self):
|
||||||
"""
|
"""
|
||||||
Returns the zero element of the algebra
|
Returns the zero element of the algebra
|
||||||
@ -828,10 +832,12 @@ class AlgebraAplK(UniqueRepresentation, Parent):
|
|||||||
pol.propagate(face_indexes, dim)
|
pol.propagate(face_indexes, dim)
|
||||||
return propagation
|
return propagation
|
||||||
|
|
||||||
|
@cached_function
|
||||||
def cohomology_gens(self, degree):
|
def cohomology_gens(self, degree):
|
||||||
"""
|
"""
|
||||||
Returns the cohomolosy generators of a given degree
|
Returns the cohomolosy generators of a given degree
|
||||||
"""
|
"""
|
||||||
|
print("Cohomology_gens, degree " + str(degree), flush=True)
|
||||||
gens = {}
|
gens = {}
|
||||||
basis = self.K.cohomology_ring(QQ).basis()
|
basis = self.K.cohomology_ring(QQ).basis()
|
||||||
for k in basis.keys():
|
for k in basis.keys():
|
||||||
@ -839,7 +845,9 @@ class AlgebraAplK(UniqueRepresentation, Parent):
|
|||||||
gens[k] = basis[k]
|
gens[k] = basis[k]
|
||||||
return gens
|
return gens
|
||||||
|
|
||||||
|
@cached_function
|
||||||
def cohomology_group(self, n):
|
def cohomology_group(self, n):
|
||||||
|
print("Cohomology_group, degree " + str(n), flush=True)
|
||||||
chainComplex = self.K.chain_complex(base_ring=QQ)
|
chainComplex = self.K.chain_complex(base_ring=QQ)
|
||||||
cochainComplex = chainComplex.dual()
|
cochainComplex = chainComplex.dual()
|
||||||
Hn = cochainComplex.differential(n).right_kernel(
|
Hn = cochainComplex.differential(n).right_kernel(
|
||||||
@ -890,7 +898,7 @@ class AlgebraAplK(UniqueRepresentation, Parent):
|
|||||||
cochain_vector = self.cochain_to_vector(cochain, dim)
|
cochain_vector = self.cochain_to_vector(cochain, dim)
|
||||||
cochainComplex = self.K.chain_complex(base_ring=QQ).dual()
|
cochainComplex = self.K.chain_complex(base_ring=QQ).dual()
|
||||||
diff = cochainComplex.differential(dim-1)
|
diff = cochainComplex.differential(dim-1)
|
||||||
show(diff.echelon_form())
|
#show(diff.echelon_form())
|
||||||
result = diff.solve_right(cochain_vector)
|
result = diff.solve_right(cochain_vector)
|
||||||
return self.vector_to_cochain(result)
|
return self.vector_to_cochain(result)
|
||||||
|
|
||||||
@ -908,12 +916,14 @@ class AlgebraAplK(UniqueRepresentation, Parent):
|
|||||||
cochain[i[0].tuple()] = i[1]
|
cochain[i[0].tuple()] = i[1]
|
||||||
return cochain
|
return cochain
|
||||||
|
|
||||||
|
@cached_function
|
||||||
def get_cohomology_aplk(self, degree):
|
def get_cohomology_aplk(self, degree):
|
||||||
"""
|
"""
|
||||||
Returns a set of representative elements of Apl(K), one for each cohomology generator of a given degree
|
Returns a set of representative elements of Apl(K), one for each cohomology generator of a given degree
|
||||||
"""
|
"""
|
||||||
|
#print("Cohomology_aplk, degree " + str(degree), flush=True)
|
||||||
representative_aplk_elements = {}
|
representative_aplk_elements = {}
|
||||||
dic_gens = self.cohomology_gens(degree)
|
dic_gens = self.cohomology_gens(self,degree)
|
||||||
for key in dic_gens.keys():
|
for key in dic_gens.keys():
|
||||||
gen = dic_gens[key]
|
gen = dic_gens[key]
|
||||||
cochain = self.lift_cohomology_generator(gen)
|
cochain = self.lift_cohomology_generator(gen)
|
||||||
@ -1158,11 +1168,11 @@ class AlgebraAplK(UniqueRepresentation, Parent):
|
|||||||
dim = S.dimension()
|
dim = S.dimension()
|
||||||
min_dim = self.degree()
|
min_dim = self.degree()
|
||||||
for n in reversed(range(min_dim, dim+1)):
|
for n in reversed(range(min_dim, dim+1)):
|
||||||
#print("Primitive Basis: Working on dimension " + str(n), flush=True)
|
print("Primitive Basis: Working on dimension " + str(n), flush=True)
|
||||||
cells_sorted = S._n_cells_sorted(n)
|
cells_sorted = S._n_cells_sorted(n)
|
||||||
for simplex in cells_sorted:
|
for simplex in cells_sorted:
|
||||||
#print("Primitive Basis: Working on simplex " + str(simplex), flush=True)
|
#print("Primitive Basis: Working on simplex " + str(simplex), flush=True)
|
||||||
print("simplex "+str(simplex)+ " is at position " +str(cells_sorted.index(simplex)) + " out of " + str(len(cells_sorted)), flush=True)
|
#print("simplex "+str(simplex)+ " is at position " +str(cells_sorted.index(simplex)) + " out of " + str(len(cells_sorted)), flush=True)
|
||||||
if simplex.tuple() not in primitive_basis.keys():
|
if simplex.tuple() not in primitive_basis.keys():
|
||||||
primitive_basis[simplex.tuple()] = []
|
primitive_basis[simplex.tuple()] = []
|
||||||
# add primitive elements related to the assigned polynomial
|
# add primitive elements related to the assigned polynomial
|
||||||
@ -1271,7 +1281,7 @@ class AlgebraAplK(UniqueRepresentation, Parent):
|
|||||||
v_index = differentials.index(term)
|
v_index = differentials.index(term)
|
||||||
v[offset + v_index] = dic[monomial]
|
v[offset + v_index] = dic[monomial]
|
||||||
offset += len(differentials)
|
offset += len(differentials)
|
||||||
print("Vector diff coordinates: offset " + str(offset), flush=True)
|
#print("Vector diff coordinates: offset " + str(offset), flush=True)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _get_offsets_matrix(self, p_basis):
|
def _get_offsets_matrix(self, p_basis):
|
||||||
@ -1328,10 +1338,10 @@ class AlgebraAplK(UniqueRepresentation, Parent):
|
|||||||
dim = S.dimension()
|
dim = S.dimension()
|
||||||
min_dim = self.degree()
|
min_dim = self.degree()
|
||||||
for n in reversed(range(min_dim, dim+1)):
|
for n in reversed(range(min_dim, dim+1)):
|
||||||
#print("Face matrix: Working on dimension " + str(n), flush=True)
|
print("Face matrix: Working on dimension " + str(n), flush=True)
|
||||||
cells_sorted = S._n_cells_sorted(n)
|
cells_sorted = S._n_cells_sorted(n)
|
||||||
for simplex in cells_sorted:
|
for simplex in cells_sorted:
|
||||||
print("simplex "+str(simplex)+ " is at position " +str(cells_sorted.index(simplex)) + " out of " + str(len(cells_sorted)), flush=True)
|
#print("simplex "+str(simplex)+ " is at position " +str(cells_sorted.index(simplex)) + " out of " + str(len(cells_sorted)), flush=True)
|
||||||
offset_simplex = offsets[simplex.tuple()]
|
offset_simplex = offsets[simplex.tuple()]
|
||||||
primitives = p_basis[simplex.tuple()]
|
primitives = p_basis[simplex.tuple()]
|
||||||
for f in range(n+1):
|
for f in range(n+1):
|
||||||
@ -1373,9 +1383,9 @@ class AlgebraAplK(UniqueRepresentation, Parent):
|
|||||||
def solve_primitive(self):
|
def solve_primitive(self):
|
||||||
print("start _get_primitive_basis()",flush=True)
|
print("start _get_primitive_basis()",flush=True)
|
||||||
p_basis = self._get_primitive_basis()
|
p_basis = self._get_primitive_basis()
|
||||||
print("lenght primitive basis: ",len(p_basis),flush=True)
|
print("length primitive basis: ",len(p_basis),flush=True)
|
||||||
d_basis = self._get_differential_basis(p_basis)
|
d_basis = self._get_differential_basis(p_basis)
|
||||||
print("lenght differential basis: ",len(d_basis),flush=True)
|
print("length differential basis: ",len(d_basis),flush=True)
|
||||||
diff_matrix = self._get_differential_matrix(p_basis, d_basis)
|
diff_matrix = self._get_differential_matrix(p_basis, d_basis)
|
||||||
print("_get_vector_diff_coordinates()", flush=True)
|
print("_get_vector_diff_coordinates()", flush=True)
|
||||||
v_dif = self._get_vector_diff_coordinates(d_basis)
|
v_dif = self._get_vector_diff_coordinates(d_basis)
|
||||||
@ -1404,4 +1414,4 @@ class MorphismFromQQToAplK(Morphism):
|
|||||||
for c in S._n_cells_sorted(d):
|
for c in S._n_cells_sorted(d):
|
||||||
params[tuple(c)] = s(x)
|
params[tuple(c)] = s(x)
|
||||||
A = AlgebraAplK(S)
|
A = AlgebraAplK(S)
|
||||||
return AlgebraAplK.Element(A, params)
|
return AlgebraAplK.Element(A, params)
|
||||||
Loading…
Reference in New Issue
Block a user