DeRhamComputation/sage/as_covers/as_auxilliary.sage

56 lines
2.0 KiB
Python

def magmathis(A, B, text = False):
"""Find decomposition of Z/p^2-module given by matrices A, B into indecomposables using magma.
If text = True, print the command for Magma. Else - return the output of Magma free."""
q = parent(A).base_ring().order()
n = A.dimensions()[0]
A = str(list(A))
B = str(list(B))
A = A.replace("(", "")
A = A.replace(")", "")
B = B.replace("(", "")
B = B.replace(")", "")
result = "A := MatrixAlgebra<GF("+str(q) + "),"+ str(n) + "|"
result += A + "," + B
result += ">;"
result += "M := RModule(RSpace(GF("+str(q)+")," + str(n) + "), A);"
result += "IndecomposableSummands(M);"
if text:
return result
print(magma_free(result))
def as_reduction(AS, fct):
n = AS.height
F = AS.base_ring
variable_names = 'x, y'
for i in range(n):
variable_names += ', z' + str(i)
Rxyz = PolynomialRing(F, n+2, variable_names)
x, y = Rxyz.gens()[:2]
z = Rxyz.gens()[2:]
RxyzQ = FractionField(Rxyz)
ff = AS.functions
ff = [RxyzQ(F.function) for F in ff]
fct = RxyzQ(fct)
fct1 = numerator(fct)
fct2 = denominator(fct)
if fct2 != 1:
return as_reduction(AS, fct1)/as_reduction(AS, fct2)
result = RxyzQ(0)
change = 0
for a in fct1.monomials():
degrees_zi = [a.degree(z[i]) for i in range(n)]
d_div = [a.degree(z[i])//p for i in range(n)]
if d_div != n*[0]:
change = 1
d_rem = [a.degree(z[i])%p for i in range(n)]
monomial = fct1.coefficient(a)*x^(a.degree(x))*y^(a.degree(y))*prod(z[i]^(d_rem[i]) for i in range(n))*prod((z[i] + ff[i])^(d_div[i]) for i in range(n))
result += RxyzQ(fct1.coefficient(a)*x^(a.degree(x))*y^(a.degree(y))*prod(z[i]^(d_rem[i]) for i in range(n))*prod((z[i] + ff[i])^(d_div[i]) for i in range(n)))
if change == 0:
return RxyzQ(result)
else:
print(fct, '\n')
return as_reduction(AS, RxyzQ(result))