Skip to content

Commit c18403d

Browse files
committed
reviewer comments
1 parent 8b1fff9 commit c18403d

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

src/flint/types/fq_default_poly.pyx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -445,21 +445,16 @@ cdef class fq_default_poly(flint_poly):
445445
)
446446
return res
447447

448-
def monic(self, check=True):
448+
def monic(self):
449449
"""
450450
Return this polynomial divided by its leading coefficient.
451451
452-
If ``check`` is True, raises ValueError if the leading coefficient
453-
is not invertible modulo N. If ``check`` is False and the leading
454-
coefficient is not invertible, the output is undefined.
455-
456452
>>> R = fq_default_poly_ctx(163)
457453
>>> f = R([1,2,3])
458454
>>> f.monic()
459455
x^2 + 55*x + 109
460456
"""
461457
cdef fq_default_poly res
462-
463458
res = self.ctx.new_ctype_poly()
464459
fq_default_poly_make_monic(
465460
res.val, self.val, self.ctx.field.val
@@ -1168,7 +1163,9 @@ cdef class fq_default_poly(flint_poly):
11681163

11691164
def sqrt_trunc(self, slong n):
11701165
"""
1171-
Returns the squareroot of ``self`` modulo `x^n`.
1166+
Returns the square root of ``self`` modulo `x^n`.
1167+
1168+
Requires that the constant coefficient of the polynomial is one.
11721169
11731170
>>> R = fq_default_poly_ctx(163, 3)
11741171
>>> x = R.gen()
@@ -1182,10 +1179,9 @@ cdef class fq_default_poly(flint_poly):
11821179
"""
11831180
cdef fq_default_poly res
11841181

1185-
# FLINT assumes the constant term is one
1186-
c = self.constant_coefficient()
1187-
if not c.is_one():
1188-
self = self / c
1182+
# FLINT requires the constant term is one
1183+
if not self.constant_coefficient().is_one():
1184+
raise ValueError("constant coefficient of the polynomial must be one")
11891185

11901186
res = self.ctx.new_ctype_poly()
11911187
fq_default_poly_sqrt_series(
@@ -1195,22 +1191,22 @@ cdef class fq_default_poly(flint_poly):
11951191

11961192
def inv_sqrt_trunc(self, slong n):
11971193
"""
1198-
Returns the squareroot of ``self`` modulo `x^n`.
1194+
Returns the inverse of the square root of ``self`` modulo `x^n`.
1195+
1196+
Requires that the constant coefficient of the polynomial is one.
11991197
12001198
>>> R = fq_default_poly_ctx(163, 3)
12011199
>>> x = R.gen()
12021200
>>> z = R.base_field().gen()
12031201
>>> f = (37*z + 54)*x**3 + (8*z + 94)*x**2 + (52*z + 142)*x + 1
1204-
>>> h = f.sqrt_trunc(5)
1205-
>>> h
1202+
>>> f.sqrt_trunc(5)
12061203
(60*z^2 + 17*z + 158)*x^4 + (7*z^2 + 17*z + 148)*x^3 + (151*z^2 + 114*z + 53)*x^2 + (26*z + 71)*x + 1
12071204
"""
12081205
cdef fq_default_poly res
12091206

1210-
# FLINT assumes the constant term is one
1211-
c = self.constant_coefficient()
1212-
if not c.is_one():
1213-
self = self / c
1207+
# FLINT requires the constant term is one
1208+
if not self.constant_coefficient().is_one():
1209+
raise ValueError("constant coefficient of the polynomial must be one")
12141210

12151211
res = self.ctx.new_ctype_poly()
12161212
fq_default_poly_invsqrt_series(

0 commit comments

Comments
 (0)