Skip to content

Commit 79d8be5

Browse files
committed
use in_base in invert method
1 parent 7f8ba08 commit 79d8be5

File tree

3 files changed

+52
-31
lines changed

3 files changed

+52
-31
lines changed

src/sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -437,37 +437,38 @@ def invert(self, ore_pol):
437437
"""
438438
deg = ore_pol.degree()
439439
r = self.rank()
440-
base_over_Fq = self.base_over_constants_field()
440+
E = self.base()
441+
K = self.base_over_constants_field()
441442
if ore_pol not in self._ore_polring:
442443
raise TypeError('input must be an Ore polynomial')
443-
if ore_pol.degree() == 0:
444-
coord = base_over_Fq(self._base(ore_pol)).vector()
445-
if coord.nonzero_positions == [0]:
446-
return self._Fq(coord[0])
447-
if ore_pol == 0:
448-
return self._Fq.zero()
449444
if deg % r != 0:
450-
raise ValueError('input must be in the image of the Drinfeld '
451-
'module')
445+
raise ValueError('input must be in the image of the Drinfeld module')
446+
447+
if ore_pol.degree() <= 0:
448+
return K(ore_pol[0]).in_base()
452449

453450
k = deg // r
454-
T = self._function_ring.gen()
455-
mat_lines = [[0 for _ in range(k+1)] for _ in range(k+1)]
456-
for i in range(k+1):
457-
phi_T_i = self(T**i)
451+
A = self._function_ring
452+
T = A.gen()
453+
mat_rows = [[E.zero() for _ in range(k+1)] for _ in range(k+1)]
454+
mat_rows[0][0] = E.one()
455+
phiT = self.gen()
456+
phiTi = self.ore_polring().one()
457+
for i in range(1, k+1):
458+
phiTi *= phiT
458459
for j in range(i+1):
459-
mat_lines[j][i] = phi_T_i[r*j]
460-
mat = Matrix(mat_lines)
461-
vec = vector([list(ore_pol)[r*j] for j in range(k+1)])
462-
coeffs_K = list((mat**(-1)) * vec)
463-
coeffs_Fq = list(map(lambda x: base_over_Fq(x).vector()[0], coeffs_K))
464-
pre_image = self._function_ring(coeffs_Fq)
465-
466-
if self(pre_image) == ore_pol:
467-
return pre_image
468-
else:
469-
raise ValueError('input must be in the image of the Drinfeld '
470-
'module')
460+
mat_rows[j][i] = phiTi[r*j]
461+
mat = Matrix(mat_rows)
462+
vec = vector([ore_pol[r*j] for j in range(k+1)])
463+
coeffs_K = list(mat.inverse() * vec)
464+
try:
465+
coeffs_Fq = [K(c).in_base() for c in coeffs_K]
466+
pre_image = A(coeffs_Fq)
467+
if self(pre_image) == ore_pol:
468+
return pre_image
469+
except ValueError:
470+
pass
471+
raise ValueError('input must be in the image of the Drinfeld module')
471472

472473
def is_ordinary(self):
473474
r"""

src/sage/rings/function_field/drinfeld_modules/homset.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ class DrinfeldModuleHomset(Homset):
200200
False
201201
sage: frobenius_endomorphism in H
202202
False
203-
"""
204203
204+
"""
205205
Element = DrinfeldModuleMorphism
206-
__contains__ = Parent.__contains__
207206

208207
def __init__(self, X, Y, category=None, check=True):
209208
"""
@@ -238,8 +237,7 @@ def __init__(self, X, Y, category=None, check=True):
238237
if check:
239238
if X.category() != Y.category() \
240239
or not isinstance(X.category(), DrinfeldModules):
241-
raise ValueError('Drinfeld modules must be in the same '
242-
'category')
240+
raise ValueError('Drinfeld modules must be in the same category')
243241
if category != X.category():
244242
raise ValueError('category should be DrinfeldModules')
245243
base = category.base()

src/sage/rings/function_field/drinfeld_modules/morphism.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,13 @@ class DrinfeldModuleMorphism(Morphism, UniqueRepresentation,
9696
9797
TESTS::
9898
99-
sage: morphism.parent() == Hom(phi, psi)
99+
sage: morphism.parent() is Hom(phi, psi)
100100
True
101+
sage: Hom(phi, psi)(morphism) == morphism
102+
True
103+
104+
::
105+
101106
sage: phi.frobenius_endomorphism().parent() == End(phi)
102107
True
103108
sage: End(phi)(0).parent() == End(phi)
@@ -115,8 +120,8 @@ class DrinfeldModuleMorphism(Morphism, UniqueRepresentation,
115120
Defn: t + z^5 + z^3 + z + 1
116121
sage: DrinfeldModuleMorphism(Hom(phi, psi), ore_pol) is morphism
117122
True
118-
"""
119123
124+
"""
120125
@staticmethod
121126
def __classcall_private__(cls, parent, x):
122127
"""
@@ -627,6 +632,14 @@ def dual_isogeny(self):
627632
sage: f * g == psi.hom(a)
628633
True
629634
635+
TESTS::
636+
637+
sage: zero = phi.hom(0)
638+
sage: zero.dual_isogeny()
639+
Traceback (most recent call last):
640+
...
641+
ValueError: the dual isogeny of the zero morphism is not defined
642+
630643
"""
631644
if not self.is_isogeny():
632645
raise ValueError("the dual isogeny of the zero morphism is not defined")
@@ -670,6 +683,15 @@ def characteristic_polynomial(self, var='X'):
670683
sage: f.characteristic_polynomial(var='Y')
671684
Y^3 + (T + 1)*Y^2 + (2*T + 3)*Y + 2*T^3 + T + 1
672685
686+
TESTS::
687+
688+
sage: t = phi.ore_variable()
689+
sage: isog = phi.hom(t + 1)
690+
sage: isog.characteristic_polynomial()
691+
Traceback (most recent call last):
692+
...
693+
ValueError: characteristic polynomial is only defined for endomorphisms
694+
673695
"""
674696
if self.domain() is not self.codomain():
675697
raise ValueError("characteristic polynomial is only defined for endomorphisms")

0 commit comments

Comments
 (0)