Skip to content

Commit 9e9fefb

Browse files
committed
Made functions less dependent on base field
1 parent 4e3c9ce commit 9e9fefb

File tree

4 files changed

+26
-47
lines changed

4 files changed

+26
-47
lines changed

darmonpoints/arithgroup.py

+17-25
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def geodesic_circle(alpha, beta, return_equation=True):
8585
assert C.imag().abs() < 10**-10, C
8686
try:
8787
r2 = (alpha - C).norm()
88-
except AttributError:
88+
except AttributeError:
8989
r2 = (alpha - C) ** 2
9090
x, y = PolynomialRing(C.parent(), 2, names="x,y").gens()
9191
return (
@@ -284,12 +284,12 @@ def get_embgquats_twisted(self, P=None):
284284
if P is None:
285285
CC = ComplexField(800)
286286
P = CC(90) / CC(100) * CC.gen()
287-
embgquats = self.embgquats
288287
Pconj = P.conjugate()
289288
m = Matrix([[Pconj, -P], [1, -1]])
290289
madj = m.adjugate()
291290
return [None] + [tuple((madj * o * m).list()) for o in self.embgquats[1:]]
292291

292+
293293
def get_word_rep(self, delta, P=None): # fuchsian generic
294294
while True:
295295
try:
@@ -390,7 +390,7 @@ def magma_word_problem(self, Gm, x):
390390
def draw_mat_list(self, x0, g1, mlist, color="blue"):
391391
phi = self.get_archimedean_embedding(1000)
392392
P = hyperbolic_arc(x0, act_flt(phi(g1.quaternion_rep), x0), color="red")
393-
vlist = G._fundamental_domain
393+
vlist = self.fundamental_domain()
394394
for g in mlist:
395395
new_polygon = [act_flt(phi(g), v) for v in vlist]
396396
P += hyperbolic_polygon(new_polygon, color=color)
@@ -401,19 +401,18 @@ def mat_list(self, x1, x2, check_fundom=True): # generic
401401
Returns a list S of matrices such that the geodesic (x1, x2) is contained in the union
402402
of the translates s*D (with s in S) of the standard fundamental domain D.
403403
"""
404+
CC = x1.parent()
405+
emb = self.get_archimedean_embedding(CC.precision())
404406
verbose("Calling mat_list with x1 = %s and x2 = %s" % (x1, x2))
405-
x1_orig = x1
406-
x2_orig = x2
407407
n = 0
408408
g = 1
409409
if check_fundom and not self.is_in_fundom(x1):
410410
t0, g = self.find_fundom_rep(x1)
411-
x1, x2 = t0, self(g**-1) * x2
411+
x1, x2 = t0, act_flt(emb(self(g**-1).quaternion_rep), x2)
412412

413413
# Here we can assume that x1 is in the fundamental domain
414414
ans = [self(g)]
415415
while not self.is_in_fundom(x2):
416-
found = False
417416
intersection_candidates = []
418417
for i, (v1, v2) in enumerate(self.fundamental_domain_data()):
419418
z = intersect_geodesic_arcs(v1, v2, x1, x2)
@@ -423,29 +422,22 @@ def mat_list(self, x1, x2, check_fundom=True): # generic
423422
z1, z2 = perturb_point_on_arc(x1, x2, z, eps)
424423
if not self.is_in_fundom(z1):
425424
z1, z2 = z2, z1
426-
try:
427-
assert self.is_in_fundom(
428-
z1
429-
), "z1 and z2 are both outside of fundom!"
430-
assert not self.is_in_fundom(
431-
z2
432-
), "z1 and z2 are both inside of fundom!"
425+
if self.is_in_fundom(z1) and not self.is_in_fundom(z2):
433426
intersection_candidates.append(((z1, z2), i, (v1, v2)))
434-
except AssertionError:
435-
pass
436427
assert len(intersection_candidates) > 0, "No intersection candidates!!"
437428
if len(intersection_candidates) > 1:
438429
verbose(intersection_candidates)
439430
z1, z2 = intersection_candidates[
440431
ZZ.random_element(len(intersection_candidates))
441432
][0]
433+
found = False
442434
for g in self.gquats[1:]:
443-
t0 = self(g) ** -1 * z2
435+
t0 = act_flt(emb((self(g) ** -1).quaternion_rep), z2)
444436
if self.is_in_fundom(t0):
445437
assert not found, "Found more than one!"
446438
found = True
447439
x1 = t0
448-
x2 = self(g) ** -1 * x2
440+
x2 = act_flt(emb((self(g) ** -1).quaternion_rep), x2)
449441
verbose("x1 = %s, x2 = %s" % (x1, x2))
450442
ans.append(ans[-1] * self(g))
451443
break # DEBUG
@@ -472,7 +464,7 @@ def _fix_sign(self, x, N):
472464
return x
473465

474466
def find_fundom_rep(
475-
self, z0_H, v0=None, return_alternative=False, max_iters=100
467+
self, z0_H, v0 =None, return_alternative=False, max_iters=100
476468
): # generic -- Take z0 to the fundamental domain
477469
r"""
478470
Returns t0 and g such that g * t0 = z0_H, and t0 is in the fundamental domain
@@ -541,8 +533,8 @@ def find_fundom_rep(
541533
oldji, oldgg = ji, gg
542534
wd.append(gg)
543535
verbose("New g = %s\t delta = %s\t z0=%s" % (gg, delta, z0))
544-
t0 = self(delta) * z0_H
545-
t1 = self(wd[-1] ** -1 * delta) * z0_H
536+
t0 = act_flt(emb(self(delta).quaternion_rep),z0_H)
537+
t1 = act_flt(emb(self(wd[-1] ** -1 * delta).quaternion_rep),z0_H)
546538
delta_inv = delta**-1
547539
if return_alternative:
548540
return (t0, delta_inv), (t1, delta_inv * wd[-1])
@@ -1288,17 +1280,17 @@ def mat_list(
12881280
of the translates s*D (with s in S) of the standard fundamental domain D.
12891281
"""
12901282
CC = x1.parent()
1291-
x1 += CC.random_element(10**-1) * x1.imag() ** 2
1292-
x2 += CC.random_element(10**-1) * x2.imag() ** 2
1283+
x1 += CC.random_element(0.1) * x1.imag() ** 2
1284+
x2 += CC.random_element(0.1) * x2.imag() ** 2
12931285
if debug:
12941286
from sage.repl.rich_output.pretty_print import show
12951287

12961288
self._debug_plot = hyperbolic_polygon(
12971289
[
1298-
CC(-0.5, 10 ^ 2),
1290+
CC(-0.5, 10 ** 2),
12991291
self.fundamental_domain()[1],
13001292
self.fundamental_domain()[2],
1301-
CC(0.5, 10 ^ 2),
1293+
CC(0.5, 10 ** 2),
13021294
]
13031295
)
13041296
if v0 is None:

darmonpoints/arithgroup_element.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,17 @@
1111

1212
from sage.algebras.quatalg.all import QuaternionAlgebra
1313
from sage.functions.generalized import sgn
14-
from sage.functions.trig import arctan
15-
from sage.groups.group import AlgebraicGroup
16-
from sage.matrix.all import Matrix, matrix
17-
from sage.misc.all import cached_method, lazy_attribute, walltime
14+
from sage.misc.all import cached_method, lazy_attribute
1815
from sage.misc.misc_c import prod
19-
from sage.misc.persist import db
20-
from sage.modules.all import vector
21-
from sage.modules.free_module import FreeModule_generic
2216
from sage.rings.all import (
2317
QQ,
24-
RR,
2518
ZZ,
26-
ComplexField,
2719
NumberField,
2820
PolynomialRing,
2921
Qp,
3022
QuadraticField,
31-
RealField,
3223
)
3324
from sage.structure.element import MultiplicativeGroupElement
34-
from sage.structure.parent import Parent
35-
from sage.structure.richcmp import richcmp
36-
from sage.structure.sage_object import SageObject, load, save
3725

3826
from .util import *
3927

@@ -211,7 +199,8 @@ def __iter__(self):
211199
def matrix(self, prec=-1):
212200
return self.embed(prec)
213201

214-
def acton(self, x):
202+
def _act_on_(self, x, on_left):
203+
assert on_left == True
215204
return act_flt(self.matrix(), x)
216205

217206
def conjugate_by(self, w):

darmonpoints/darmonvonk.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,6 @@ def __init__(self, G, x0, gamma_tau, tau_p):
804804

805805
self._tau = tau_p
806806
tau = self._tau
807-
tau_bar = tau.trace() - tau
808807
self._gamma_tau = gamma_tau
809808

810809
action_map = lambda g, x: act_flt(vinf(g.quaternion_rep), x)
@@ -835,14 +834,13 @@ def evaluate(self, gamma):
835834
Div = Divisors(self._tau.parent())
836835
if gamma.quaternion_rep == 1 or gamma.quaternion_rep == -1:
837836
return Div(0)
838-
wlist = set([])
839837
x0 = self._x0
840838
gamma_of_x0 = gamma * x0
841839
tau = x0.parent()(self._tau_inf)
842840
tau_bar = x0.parent()(self._tau_inf_bar)
843841
ans = Div(0)
842+
c1 = HH.get_geodesic(x0, gamma_of_x0)
844843
for g in self.all_matrix_candidates(gamma):
845-
c1 = HH.get_geodesic(x0, gamma_of_x0)
846844
gtau = g * tau
847845
gtau_bar = g * tau_bar
848846
c2 = HH.get_geodesic(gtau, gtau_bar)

darmonpoints/meromorphic.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __call__(self, D):
9898
def polynomial_approximation(self, z, m):
9999
K = self.parent().base_ring()
100100
a, b, c, d = self._parameter.list()
101-
phi = lambda Q: K(a) / c if Q == Infinity else (a * Q + b) / (c * Q + d)
101+
phi = lambda Q: a / c if Q == Infinity else (a * Q + b) / (c * Q + d)
102102
try:
103103
pt = phi(self.normalize_point)
104104
pole = -d / c
@@ -121,7 +121,7 @@ def evaluate(self, D): # meromorphic functions
121121
if type(D) in (int, Integer):
122122
D = K(D)
123123
a, b, c, d = self._parameter.list()
124-
phi = lambda Q: K(a) / c if Q == Infinity else K(a * Q + b) / K(c * Q + d)
124+
phi = lambda Q: a / c if Q == Infinity else (a * Q + b) / (c * Q + d)
125125
try:
126126
pt = phi(self.normalize_point)
127127
pole = -d / c
@@ -152,7 +152,7 @@ def eval_derivative(self, D):
152152
raise NotImplementedError
153153
K = self.parent().base_ring()
154154
a, b, c, d = self._parameter.list()
155-
phi = lambda Q: K(a) / c if Q == Infinity else K(a * Q + b) / K(c * Q + d)
155+
phi = lambda Q: a / c if Q == Infinity else (a * Q + b) / (c * Q + d)
156156
valder = self.power_series().derivative().list()
157157
try:
158158
pt = phi(self.normalize_point)
@@ -249,9 +249,9 @@ def divisor_to_pseries(parameter, Ps, data, prec):
249249
for Q, n in data:
250250
K = Q.parent()
251251
if n > 0:
252-
num *= (1 - K(((c * Q + d) / (a * Q + b))) * t) ** ZZ(n)
252+
num *= (1 - ((c * Q + d) / (a * Q + b)) * t) ** ZZ(n)
253253
else:
254-
den *= (1 - K(((c * Q + d) / (a * Q + b))) * t) ** ZZ(-n)
254+
den *= (1 - ((c * Q + d) / (a * Q + b)) * t) ** ZZ(-n)
255255
ans = Ps(num).add_bigoh(prec) * ~(Ps(den).add_bigoh(prec))
256256
return ans
257257

0 commit comments

Comments
 (0)