From ff67beab63b3880804bc37c2f6af7b7f8d97e08c Mon Sep 17 00:00:00 2001 From: calquezar Date: Sun, 18 Aug 2024 13:05:23 +0200 Subject: [PATCH] Update aplK.py --- aplK.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/aplK.py b/aplK.py index dea1778..c48bf87 100644 --- a/aplK.py +++ b/aplK.py @@ -168,6 +168,7 @@ class AplN(DifferentialGCAlgebra_multigraded, UniqueRepresentation): for k in self.homogeneous_parts() if list(k)[0] == degree] return self.parent()(sum(parts)) + #@cached_function def reduce(self, relations=[]): """" The method reduces the polynomial by the Ideal @@ -350,7 +351,7 @@ class AplN(DifferentialGCAlgebra_multigraded, UniqueRepresentation): else: return w+theta.primitive() - +@cached_function def AlgebraPL(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]) images = tImages+yImages return domain.hom(codomain=codomain, im_gens=images) - + + @cached_method def face(self, i): """" @@ -505,7 +507,8 @@ class SimplicialAplN(AplN, UniqueRepresentation): - A polynomial that is the degeneration 'j' of self """ return self.degeneration_morphism(j)(self) - + + #@cached_function def propagate(self, face_list, dest_dim): """ 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) return sum(map(lambda x, y: x*y, sol, primitive_basis)) - +@cached_function def SimplicialAlgebraplN(n): """ 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)] + @cached_function def zero(self): """ Returns the zero element of the algebra @@ -828,10 +832,12 @@ class AlgebraAplK(UniqueRepresentation, Parent): pol.propagate(face_indexes, dim) return propagation + @cached_function def cohomology_gens(self, degree): """ Returns the cohomolosy generators of a given degree """ + print("Cohomology_gens, degree " + str(degree), flush=True) gens = {} basis = self.K.cohomology_ring(QQ).basis() for k in basis.keys(): @@ -839,7 +845,9 @@ class AlgebraAplK(UniqueRepresentation, Parent): gens[k] = basis[k] return gens + @cached_function def cohomology_group(self, n): + print("Cohomology_group, degree " + str(n), flush=True) chainComplex = self.K.chain_complex(base_ring=QQ) cochainComplex = chainComplex.dual() Hn = cochainComplex.differential(n).right_kernel( @@ -890,7 +898,7 @@ class AlgebraAplK(UniqueRepresentation, Parent): cochain_vector = self.cochain_to_vector(cochain, dim) cochainComplex = self.K.chain_complex(base_ring=QQ).dual() diff = cochainComplex.differential(dim-1) - show(diff.echelon_form()) + #show(diff.echelon_form()) result = diff.solve_right(cochain_vector) return self.vector_to_cochain(result) @@ -908,12 +916,14 @@ class AlgebraAplK(UniqueRepresentation, Parent): cochain[i[0].tuple()] = i[1] return cochain + @cached_function def get_cohomology_aplk(self, 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 = {} - dic_gens = self.cohomology_gens(degree) + dic_gens = self.cohomology_gens(self,degree) for key in dic_gens.keys(): gen = dic_gens[key] cochain = self.lift_cohomology_generator(gen) @@ -1158,11 +1168,11 @@ class AlgebraAplK(UniqueRepresentation, Parent): dim = S.dimension() min_dim = self.degree() 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) for simplex in cells_sorted: #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(): primitive_basis[simplex.tuple()] = [] # add primitive elements related to the assigned polynomial @@ -1271,7 +1281,7 @@ class AlgebraAplK(UniqueRepresentation, Parent): v_index = differentials.index(term) v[offset + v_index] = dic[monomial] offset += len(differentials) - print("Vector diff coordinates: offset " + str(offset), flush=True) + #print("Vector diff coordinates: offset " + str(offset), flush=True) return v def _get_offsets_matrix(self, p_basis): @@ -1328,10 +1338,10 @@ class AlgebraAplK(UniqueRepresentation, Parent): dim = S.dimension() min_dim = self.degree() 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) 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()] primitives = p_basis[simplex.tuple()] for f in range(n+1): @@ -1373,9 +1383,9 @@ class AlgebraAplK(UniqueRepresentation, Parent): def solve_primitive(self): print("start _get_primitive_basis()",flush=True) 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) - 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) print("_get_vector_diff_coordinates()", flush=True) v_dif = self._get_vector_diff_coordinates(d_basis) @@ -1404,4 +1414,4 @@ class MorphismFromQQToAplK(Morphism): for c in S._n_cells_sorted(d): params[tuple(c)] = s(x) A = AlgebraAplK(S) - return AlgebraAplK.Element(A, params) + return AlgebraAplK.Element(A, params) \ No newline at end of file