58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
|
def magma_module_decomposition(A, B, text = False, prefix="", sufix="", matrices=True):
|
||
|
"""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()
|
||
|
p = q.factor()[0][0]
|
||
|
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 = prefix
|
||
|
if q != p:
|
||
|
result += "F<a> := GF(" + str(q) + ");"
|
||
|
result += "A := MatrixAlgebra<GF("+str(q) + "),"+ str(n) + "|"
|
||
|
result += A + "," + B
|
||
|
result += ">;"
|
||
|
result += "M := RModule(RSpace(GF("+str(q)+")," + str(n) + "), A);"
|
||
|
result += "L := IndecomposableSummands(M); L;"
|
||
|
if matrices:
|
||
|
result += "for i in [1 .. #L] do print(Generators(Action(L[i]))); end for;"
|
||
|
result += sufix
|
||
|
if text:
|
||
|
return result
|
||
|
return(magma_free(result))
|
||
|
|
||
|
def magma_is_isomorphic(A1, B1, A2, B2, text=0):
|
||
|
q = parent(A1).base_ring().order()
|
||
|
p = q.factor()[0][0]
|
||
|
n = A1.dimensions()[0]
|
||
|
A1 = str(list(A1))
|
||
|
B1 = str(list(B1))
|
||
|
A2 = str(list(A2))
|
||
|
B2 = str(list(B2))
|
||
|
A1 = A1.replace("(", "")
|
||
|
A1 = A1.replace(")", "")
|
||
|
A2 = A2.replace("(", "")
|
||
|
A2 = A2.replace(")", "")
|
||
|
B1 = B1.replace("(", "")
|
||
|
B1 = B1.replace(")", "")
|
||
|
B2 = B2.replace("(", "")
|
||
|
B2 = B2.replace(")", "")
|
||
|
result = ""
|
||
|
if q != p:
|
||
|
result += "F<a> := GF(" + str(q) + ");"
|
||
|
result += "A1 := MatrixAlgebra<GF("+str(q) + "),"+ str(n) + "|"
|
||
|
result += A1 + "," + B1
|
||
|
result += ">;"
|
||
|
result += "M1 := RModule(RSpace(GF("+str(q)+")," + str(n) + "), A1);"
|
||
|
result += "A2 := MatrixAlgebra<GF("+str(q) + "),"+ str(n) + "|"
|
||
|
result += A2 + "," + B2
|
||
|
result += ">;"
|
||
|
result += "M2 := RModule(RSpace(GF("+str(q)+")," + str(n) + "), A2);"
|
||
|
result += "IsIsomorphic(M1, M2);"
|
||
|
if text:
|
||
|
return result
|
||
|
return(magma_free(result))
|