DeRhamComputation/sage/superelliptic_drw/superelliptic_drw_form.sage

94 lines
2.8 KiB
Python

class superelliptic_drw_form:
def __init__(self, h1, omega, h2):
'''Form [h1] d[x] + V(omega) + dV([h])'''
self.curve = h1.curve
self.h1 = h1
self.omega = omega
self.h2 = h2
def r(self):
C = self.curve
h1 = self.h1
return superelliptic_form(C, h1.function)
def __eq__(self, other):
eq1 = (self.h1 == self.h1)
try:
H = (self.h2 - other.h2).pth_root()
except:
return False
eq2 = ((other.omega - self.omega).cartier() - H.diffn()) == 0*self.curve.dx
if eq1 and eq2:
return True
return False
def __repr__(self):
C = self.curve
h1 = self.h1
omega = self.omega
h2 = self.h2
result = ""
if h1.function != 0:
result += "[" + str(h1) + "] d[x]"
if (h1.function !=0 and omega.form != 0) or (h2.function !=0 and omega.form != 0):
result += " + "
if omega.form != 0:
result += "V(" + str(omega) + ")"
if h2.function !=0 and omega.form != 0:
result += " + "
if h2.function != 0:
result += "dV([" + str(h2) +"])"
if result == "":
result += "0"
return result
def __rmul__(self, other):
h1 = self.h1
h2 = self.h2
omega = self.omega
p = self.curve.characteristic
if other in ZZ:
if other == 0:
return superelliptic_drw_form(0*C.x, 0*C.dx, 0*C.x)
if other > 0:
return self + (other-1)*self
if other < 0:
return (-other)*(-self)
if other in QQ:
other_integer = Integers(p^2)(other)
return other_integer*self
t = other.t
f = other.f
aux_form = t^p*omega - h2*t^(p-1)*t.diffn() + f*h1^p*(C.x)^(p-1)*C.dx
return superelliptic_drw_form(t*h1, aux_form, t^p*h2)
def __neg__(self):
C = self.curve
h1 = self.h1
h2 = self.h2
omega = self.omega
return superelliptic_drw_form(-h1, -omega, -h2)
def __sub__(self, other):
return self + (-other)
def __add__(self, other):
C = self.curve
h1 = self.h1
h2 = self.h2
omega = self.omega
H1 = other.h1
H2 = other.h2
OMEGA = other.omega
aux = (teichmuller(h1) + teichmuller(H1))*superelliptic_drw_form(C.one, 0*C.dx, 0*C.x)
h1_aux = aux.h1
h2_aux = aux.h2
omega_aux = aux.omega
return superelliptic_drw_form(h1_aux, omega + OMEGA + omega_aux, h2 + H2 + h2_aux)
def frobenius(self):
C = self.curve
h1 = self.h1
h2 = self.h2
p = C.characteristic
return h1^p*C.x^(p-1)*C.dx + h2.diffn()