From 7c1db6a7ad9612be625fc617364c7967f420c64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 30 Aug 2024 17:09:27 +0200 Subject: [PATCH 1/6] fix rst --- bin/rst_to_pxd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/rst_to_pxd.py b/bin/rst_to_pxd.py index d691ff0c..f6091b1f 100755 --- a/bin/rst_to_pxd.py +++ b/bin/rst_to_pxd.py @@ -76,7 +76,7 @@ def fill_import_dict(pyflintlibdir): def undecorate(str): """ - remove variable name, const, *, etc. to just get types + remove variable name, const, ``*``, etc. to just get types """ ret = str.strip() ret = ret[:ret.rfind(' ')] From 603ca1304ae463f63c7e2a0abdf75ee291c5b0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 30 Aug 2024 17:13:42 +0200 Subject: [PATCH 2/6] fix typos in src/ --- src/flint/test/test_all.py | 6 +++--- src/flint/types/acb.pyx | 4 ++-- src/flint/types/fmpz_mod.pyx | 6 +++--- src/flint/types/fmpz_mod_poly.pyx | 4 ++-- src/flint/types/fq_default_poly.pyx | 7 ++++--- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/flint/test/test_all.py b/src/flint/test/test_all.py index 1d91a734..fd7373b9 100644 --- a/src/flint/test/test_all.py +++ b/src/flint/test/test_all.py @@ -4188,7 +4188,7 @@ def test_fq_default(): assert raises(lambda: gf_5.one() + gf_5_2.one(), ValueError) # testing various equalties between types - # integers are the same if charactersitic is the same + # integers are the same if characteristic is the same # even with extensions assert gf_5.one() == gf_5_.one() assert hash(gf_5.one()) == hash(gf_5_.one()) @@ -4242,7 +4242,7 @@ def test_fq_default(): assert gf_5_2(-1) != R7(-1) assert gf_5_2(-1) != R7(4) - # test fq_default element arithemtic + # test fq_default element arithmetic for gf in [gf_5, gf_5_2, gf_127, gf_127_2]: @@ -4336,7 +4336,7 @@ def test_fq_default_poly(): assert R1(0).leading_coefficient() == 0 assert raises(lambda: R1.random_element().reverse(degree=-1), ValueError) - # some coersion + # some coercion assert raises(lambda: R3(F(1)), ValueError) assert R1.one() == R1(1) assert R1.one() == R1([1]) diff --git a/src/flint/types/acb.pyx b/src/flint/types/acb.pyx index 87f4f696..2386e767 100644 --- a/src/flint/types/acb.pyx +++ b/src/flint/types/acb.pyx @@ -747,7 +747,6 @@ cdef class acb(flint_scalar): acb_dirichlet_lerch_phi((u).val, (z).val, (s).val, (a).val, getprec()) return u - def dirichlet_l(s, chi): cdef dirichlet_char cchar if isinstance(chi, dirichlet_char): @@ -761,7 +760,7 @@ cdef class acb(flint_scalar): @staticmethod def pi(): """ - Returns tthe constant `\pi` as an *acb*. + Returns the constant `\pi` as an *acb*. >>> from flint import showgood >>> showgood(lambda: acb.pi(), dps=25) @@ -796,6 +795,7 @@ cdef class acb(flint_scalar): def rsqrt(s, bint analytic=False): r""" Reciprocal square root `1/\sqrt{s}`. + The *analytic* flag allows verifying that the branch cut is not touched; this is useful for numerical integration. diff --git a/src/flint/types/fmpz_mod.pyx b/src/flint/types/fmpz_mod.pyx index a29f290e..6f242593 100644 --- a/src/flint/types/fmpz_mod.pyx +++ b/src/flint/types/fmpz_mod.pyx @@ -35,7 +35,7 @@ from flint.utils.flint_exceptions import DomainError cdef class fmpz_mod_ctx: r""" - Context object for creating :class:`~.fmpz_mod` initalised + Context object for creating :class:`~.fmpz_mod` initialised with a modulus :math:`N`. >>> fmpz_mod_ctx(2**127 - 1) @@ -142,7 +142,7 @@ cdef class fmpz_mod_ctx: cdef discrete_log_pohlig_hellman_run(self, fmpz_t x, fmpz_t y): # First, Ensure that L has performed precomputations This generates a - # base which is a primative root, and used as the base in + # base which is a primitive root, and used as the base in # fmpz_mod_discrete_log_pohlig_hellman_run if not self._init_L: fmpz_mod_discrete_log_pohlig_hellman_precompute_prime(self.L, self.val.n) @@ -367,7 +367,7 @@ cdef class fmpz_mod(flint_scalar): fmpz_init(x_a) self.ctx.discrete_log_pohlig_hellman_run(x_a, (a).val) - # If g is not a primative root, then x_g and pm1 will share + # If g is not a primitive root, then x_g and pm1 will share # a common factor. We can use this to compute the order of # g. cdef fmpz_t g, g_order, x_g diff --git a/src/flint/types/fmpz_mod_poly.pyx b/src/flint/types/fmpz_mod_poly.pyx index 4b39b1b9..11ebc85d 100644 --- a/src/flint/types/fmpz_mod_poly.pyx +++ b/src/flint/types/fmpz_mod_poly.pyx @@ -22,7 +22,7 @@ from flint.utils.flint_exceptions import DomainError cdef class fmpz_mod_poly_ctx: r""" - Context object for creating :class:`~.fmpz_mod_poly` initalised + Context object for creating :class:`~.fmpz_mod_poly` initialised with a modulus :math:`N`. >>> fmpz_mod_poly_ctx(2**127 - 1) @@ -467,7 +467,7 @@ cdef class fmpz_mod_poly(flint_poly): def exact_division(self, right): """ Attempt to compute the exact quotient of self with other - Raises a value error if divison without remainer is not + Raises a value error if division without remainder is not possible. >>> R = fmpz_mod_poly_ctx(163) diff --git a/src/flint/types/fq_default_poly.pyx b/src/flint/types/fq_default_poly.pyx index 1adcd885..f0f69d4f 100644 --- a/src/flint/types/fq_default_poly.pyx +++ b/src/flint/types/fq_default_poly.pyx @@ -15,7 +15,7 @@ from flint.utils.flint_exceptions import DomainError cdef class fq_default_poly_ctx: r""" - Context object for creating :class:`~.fq_default_poly` initalised + Context object for creating :class:`~.fq_default_poly` initialised with a finite field `GF(p^d)`. >>> fq_default_poly_ctx(163, 3, fq_type="FQ_NMOD") @@ -733,8 +733,9 @@ cdef class fq_default_poly(flint_poly): def exact_division(self, other): """ - Attempt to compute the exact quotient of self with other - Raises a value error if divison without remainer is not + Attempt to compute the exact quotient of self with other. + + Raises a value error if division without remainder is not possible. >>> R = fq_default_poly_ctx(163) From 4216934a8226c2c5a083f9955d3dfab215f39544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 30 Aug 2024 17:23:17 +0200 Subject: [PATCH 3/6] fix invalid escape seqs in doc strings --- src/flint/types/acb.pyx | 16 +++++------ src/flint/types/arb.pyx | 43 +++++++++++++++-------------- src/flint/types/fmpz_mod.pyx | 2 +- src/flint/types/fmpz_mod_poly.pyx | 12 ++++---- src/flint/types/fq_default_poly.pyx | 8 +++--- src/flint/types/nmod_poly.pyx | 8 +++--- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/flint/types/acb.pyx b/src/flint/types/acb.pyx index 2386e767..67d492e1 100644 --- a/src/flint/types/acb.pyx +++ b/src/flint/types/acb.pyx @@ -655,7 +655,7 @@ cdef class acb(flint_scalar): return u def gamma(s): - """ + r""" Gamma function `\Gamma(s)`. >>> from flint import showgood @@ -667,7 +667,7 @@ cdef class acb(flint_scalar): return u def rgamma(s): - """ + r""" Reciprocal gamma function `1/\Gamma(s)`, avoiding division by zero at the poles of the gamma function. @@ -684,7 +684,7 @@ cdef class acb(flint_scalar): return u def lgamma(s): - """ + r""" Logarithmic gamma function `\log \Gamma(s)`. The function is defined to be continuous away from the negative half-axis and thus differs from `\log(\Gamma(s))` in general. @@ -701,7 +701,7 @@ cdef class acb(flint_scalar): return u def digamma(s): - """ + r""" Digamma function `\psi(s)`. >>> from flint import showgood @@ -713,7 +713,7 @@ cdef class acb(flint_scalar): return u def zeta(s, a=None): - """ + r""" Riemann zeta function `\zeta(s)`, or the Hurwitz zeta function `\zeta(s,a)` if a second parameter is passed. @@ -734,7 +734,7 @@ cdef class acb(flint_scalar): return u def lerch_phi(z, s, a): - """ + r""" Lerch transcendent `\Phi(z,s,a)`. >>> from flint import showgood @@ -759,7 +759,7 @@ cdef class acb(flint_scalar): @staticmethod def pi(): - """ + r""" Returns the constant `\pi` as an *acb*. >>> from flint import showgood @@ -1134,7 +1134,7 @@ cdef class acb(flint_scalar): return u, v def polylog(self, s): - """ + r""" Computes the polylogarithm `\operatorname{Li}_s(z)` where the argument *z* is given by *self* and the order *s* is given as an extra parameter. diff --git a/src/flint/types/arb.pyx b/src/flint/types/arb.pyx index 3a28a4ea..98fd481e 100644 --- a/src/flint/types/arb.pyx +++ b/src/flint/types/arb.pyx @@ -304,7 +304,7 @@ cdef class arb(flint_scalar): return x def lower(self): - """ + r""" Lower bound for *self* (towards `-\infty`). The output is an *arb* holding an exact floating-point number that has been rounded down to the current precision. @@ -317,7 +317,7 @@ cdef class arb(flint_scalar): return x def upper(self): - """ + r""" Upper bound for *self* (towards `+\infty`). The output is an *arb* holding an exact floating-point number that has been rounded up to the current precision. @@ -330,7 +330,7 @@ cdef class arb(flint_scalar): return x def mid_rad_10exp(self, long n=0): - """ + r""" Returns an *fmpz* triple (*mid*, *rad*, *exp*) where the larger of *mid* and *rad* has *n* digits plus a few digits (*n* defaults to the current precision), such that *self* is contained in @@ -670,7 +670,7 @@ cdef class arb(flint_scalar): return u def floor(s): - ur""" + r""" Floor function `\lfloor s \rfloor`. >>> print(arb.pi().floor()) @@ -683,7 +683,7 @@ cdef class arb(flint_scalar): return u def ceil(s): - ur""" + r""" Ceiling function `\lceil s \rceil`. >>> print(arb.pi().ceil()) @@ -986,7 +986,7 @@ cdef class arb(flint_scalar): return u, v def sec(s): - """ + r""" Secant function `\operatorname{sec}(s)`. >>> from flint import showgood @@ -998,7 +998,7 @@ cdef class arb(flint_scalar): return u def csc(s): - """ + r""" Cosecant function `\operatorname{csc}(s)`. >>> from flint import showgood @@ -1208,7 +1208,7 @@ cdef class arb(flint_scalar): return u def gamma(s): - """ + r""" Gamma function `\Gamma(s)`. >>> from flint import showgood @@ -1229,7 +1229,7 @@ cdef class arb(flint_scalar): @staticmethod def gamma_fmpq(fmpq s): - """ + r""" Computes the gamma function `\Gamma(s)` of a given *fmpq* *s*, exploiting the fact that *s* is an exact rational number to improve performance. @@ -1244,7 +1244,7 @@ cdef class arb(flint_scalar): return u def rgamma(s): - ur""" + r""" Reciprocal gamma function `1/\Gamma(s)`, avoiding division by zero at the poles of the gamma function. @@ -1263,7 +1263,7 @@ cdef class arb(flint_scalar): return u def lgamma(s): - """ + r""" Logarithmic gamma function `\log \Gamma(s)`. >>> from flint import showgood @@ -1278,7 +1278,7 @@ cdef class arb(flint_scalar): return u def digamma(s): - """ + r""" Digamma function `\psi(s)`. >>> from flint import showgood @@ -1326,6 +1326,7 @@ cdef class arb(flint_scalar): """ Computes the rising factorial `(s)_n` where *n* is an unsigned integer, along with the first derivative with respect to `(s)_n`. + The current implementation does not use the gamma function, so *n* should be moderate. @@ -1340,7 +1341,7 @@ cdef class arb(flint_scalar): return u, v def zeta(s, a=None): - """ + r""" Riemann zeta function `\zeta(s)` or the Hurwitz zeta function `\zeta(s,a)` if a second parameter is passed. @@ -1488,7 +1489,7 @@ cdef class arb(flint_scalar): return u def bin(s, ulong k): - """ + r""" Binomial coefficient `{s \choose k}`. Currently *k* is limited to an integer; this restriction will be removed in the future by using the gamma function. @@ -1505,7 +1506,7 @@ cdef class arb(flint_scalar): @staticmethod def bin_uiui(ulong n, ulong k): - """ + r""" Binomial coefficient `{n \choose k}`. >>> print(arb.bin_uiui(10, 5)) @@ -1533,7 +1534,7 @@ cdef class arb(flint_scalar): return u def polylog(self, s): - """ + r""" Polylogarithm `\operatorname{Li}_s(z)` where the argument *z* is given by *self* and the order *s* is given as an extra parameter. @@ -2261,7 +2262,7 @@ cdef class arb(flint_scalar): @staticmethod def pi(): - """ + r""" Returns the constant `\pi` as an *arb*. >>> from flint import showgood @@ -2274,7 +2275,7 @@ cdef class arb(flint_scalar): @staticmethod def const_sqrt_pi(): - """ + r""" The constant `\sqrt{\pi}`. >>> from flint import showgood @@ -2287,7 +2288,7 @@ cdef class arb(flint_scalar): @staticmethod def const_log2(): - """ + r""" The constant `\log(2)`. >>> from flint import showgood @@ -2300,7 +2301,7 @@ cdef class arb(flint_scalar): @staticmethod def const_log10(): - """ + r""" The constant `\log(10)`. >>> from flint import showgood @@ -2313,7 +2314,7 @@ cdef class arb(flint_scalar): @staticmethod def const_euler(): - """ + r""" Euler's constant `\gamma`. >>> from flint import showgood diff --git a/src/flint/types/fmpz_mod.pyx b/src/flint/types/fmpz_mod.pyx index 6f242593..2b8ec8eb 100644 --- a/src/flint/types/fmpz_mod.pyx +++ b/src/flint/types/fmpz_mod.pyx @@ -328,7 +328,7 @@ cdef class fmpz_mod(flint_scalar): return res def discrete_log(self, a): - """ + r""" Solve the discrete logarithm problem, using `self = g` as a base. Assumes a solution, :math:`a = g^x \pmod p` exists. diff --git a/src/flint/types/fmpz_mod_poly.pyx b/src/flint/types/fmpz_mod_poly.pyx index 11ebc85d..7f5edc06 100644 --- a/src/flint/types/fmpz_mod_poly.pyx +++ b/src/flint/types/fmpz_mod_poly.pyx @@ -807,7 +807,7 @@ cdef class fmpz_mod_poly(flint_poly): return res def compose_mod(self, other, modulus): - """ + r""" Returns the composition of two polynomials modulo a third. To be precise about the order of composition, given ``self``, and ``other`` @@ -1047,7 +1047,7 @@ cdef class fmpz_mod_poly(flint_poly): cdef fmpz_mod_poly res cdef fmpz_t f - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() if not check: fmpz_mod_poly_make_monic( res.val, self.val, self.ctx.mod.val @@ -1142,7 +1142,7 @@ cdef class fmpz_mod_poly(flint_poly): return res def pow_mod(self, e, modulus, mod_rev_inv=None): - """ + r""" Returns ``self`` raised to the power ``e`` modulo ``modulus``: :math:`f^e \mod g`/ @@ -1655,7 +1655,7 @@ cdef class fmpz_mod_poly(flint_poly): return res def pow_trunc(self, slong e, slong n): - """ + r""" Returns ``self`` raised to the power ``e`` modulo `x^n`: :math:`f^e \mod x^n`/ @@ -1885,14 +1885,14 @@ cdef class fmpz_mod_poly(flint_poly): return res def real_roots(self): - """ + r""" This method is not implemented for polynomials in :math:`(\mathbb{Z}/N\mathbb{Z})[X]` """ raise DomainError("Cannot compute real roots for polynomials over integers modulo N") def complex_roots(self): - """ + r""" This method is not implemented for polynomials in :math:`(\mathbb{Z}/N\mathbb{Z})[X]` """ diff --git a/src/flint/types/fq_default_poly.pyx b/src/flint/types/fq_default_poly.pyx index f0f69d4f..a623f259 100644 --- a/src/flint/types/fq_default_poly.pyx +++ b/src/flint/types/fq_default_poly.pyx @@ -406,7 +406,7 @@ cdef class fq_default_poly(flint_poly): return res def truncate(self, slong n): - """ + r""" Notionally truncate the polynomial to have length ``n``. If ``n`` is larger than the length of the input, then ``self`` is returned. If ``n`` is not positive, then the zero polynomial @@ -655,7 +655,7 @@ cdef class fq_default_poly(flint_poly): return res def pow_mod(self, e, modulus): - """ + r""" Returns ``self`` raised to the power ``e`` modulo ``modulus``: :math:`f^e \mod g`/ @@ -1135,7 +1135,7 @@ cdef class fq_default_poly(flint_poly): return res def pow_trunc(self, slong e, slong n): - """ + r""" Returns ``self`` raised to the power ``e`` modulo `x^n`: :math:`f^e \mod x^n`/ @@ -1434,7 +1434,7 @@ cdef class fq_default_poly(flint_poly): return res def compose_mod(self, other, modulus): - """ + r""" Returns the composition of two polynomials modulo a third. To be precise about the order of composition, given ``self``, and ``other`` diff --git a/src/flint/types/nmod_poly.pyx b/src/flint/types/nmod_poly.pyx index d0856b20..c1cc1546 100644 --- a/src/flint/types/nmod_poly.pyx +++ b/src/flint/types/nmod_poly.pyx @@ -300,7 +300,7 @@ cdef class nmod_poly(flint_poly): return res def compose_mod(self, other, modulus): - """ + r""" Returns the composition of two polynomials modulo a third. To be precise about the order of composition, given ``self``, and ``other`` @@ -508,7 +508,7 @@ cdef class nmod_poly(flint_poly): return res def pow_mod(self, e, modulus, mod_rev_inv=None): - """ + r""" Returns ``self`` raised to the power ``e`` modulo ``modulus``: :math:`f^e \mod g`/ @@ -717,14 +717,14 @@ cdef class nmod_poly(flint_poly): return v, int(n) def real_roots(self): - """ + r""" This method is not implemented for polynomials in :math:`(\mathbb{Z}/N\mathbb{Z})[X]` """ raise DomainError("Cannot compute real roots for polynomials over integers modulo N") def complex_roots(self): - """ + r""" This method is not implemented for polynomials in :math:`(\mathbb{Z}/N\mathbb{Z})[X]` """ From e2f20c8e8d4f34685ae3567943eb9979a6e8d2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 30 Aug 2024 17:29:40 +0200 Subject: [PATCH 4/6] remove trailing spaces --- src/flint/flint_base/flint_context.pyx | 2 +- src/flint/flintlib/acb_mat.pxd | 1 - src/flint/flintlib/dirichlet.pxd | 1 - src/flint/flintlib/fmpz_mod_poly.pxd | 38 +++++++++++++------------- src/flint/flintlib/fq_zech.pxd | 10 +++---- src/flint/pyflint.pxd | 1 - src/flint/types/acb.pyx | 4 +-- src/flint/types/acb_series.pyx | 2 +- src/flint/types/arb.pyx | 10 ++++--- src/flint/types/arb_poly.pyx | 2 +- src/flint/types/dirichlet.pyx | 5 ++-- src/flint/types/fmpq.pyx | 2 +- src/flint/types/fmpq_poly.pxd | 2 +- src/flint/types/fmpz.pxd | 3 +- src/flint/types/fmpz.pyx | 4 +-- src/flint/types/fmpz_mod.pxd | 2 +- src/flint/types/fmpz_mod.pyx | 22 +++++++-------- src/flint/types/fmpz_mod_poly.pyx | 2 +- src/flint/types/nmod_poly.pyx | 28 +++++++++---------- 19 files changed, 69 insertions(+), 72 deletions(-) diff --git a/src/flint/flint_base/flint_context.pyx b/src/flint/flint_base/flint_context.pyx index fd4dc324..761390a4 100644 --- a/src/flint/flint_base/flint_context.pyx +++ b/src/flint/flint_base/flint_context.pyx @@ -51,7 +51,7 @@ cdef class FlintContext: @property def threads(self): return flint_get_num_threads() - + @threads.setter def threads(self, long num): assert num >= 1 and num <= 64 diff --git a/src/flint/flintlib/acb_mat.pxd b/src/flint/flintlib/acb_mat.pxd index fdc6b0ff..72366980 100644 --- a/src/flint/flintlib/acb_mat.pxd +++ b/src/flint/flintlib/acb_mat.pxd @@ -130,4 +130,3 @@ cdef extern from "flint/acb_mat.h": int acb_mat_eig_simple(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) int acb_mat_eig_multiple_rump(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec) - diff --git a/src/flint/flintlib/dirichlet.pxd b/src/flint/flintlib/dirichlet.pxd index 60d82010..c62d6f2b 100644 --- a/src/flint/flintlib/dirichlet.pxd +++ b/src/flint/flintlib/dirichlet.pxd @@ -65,4 +65,3 @@ cdef extern from "flint/dirichlet.h": void dirichlet_char_pow(dirichlet_char_t c, const dirichlet_group_t G, const dirichlet_char_t a, ulong n) void dirichlet_char_lift(dirichlet_char_t chi_G, const dirichlet_group_t G, const dirichlet_char_t chi_H, const dirichlet_group_t H) void dirichlet_char_lower(dirichlet_char_t chi_H, const dirichlet_group_t H, const dirichlet_char_t chi_G, const dirichlet_group_t G) - diff --git a/src/flint/flintlib/fmpz_mod_poly.pxd b/src/flint/flintlib/fmpz_mod_poly.pxd index d241e0df..f9dc4110 100644 --- a/src/flint/flintlib/fmpz_mod_poly.pxd +++ b/src/flint/flintlib/fmpz_mod_poly.pxd @@ -77,7 +77,7 @@ cdef extern from "flint/fmpz_mod_poly.h": void _fmpz_mod_poly_set_length(fmpz_mod_poly_t poly, slong len) void fmpz_mod_poly_truncate(fmpz_mod_poly_t poly, slong len, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_set_trunc(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) - + # Randomisation void fmpz_mod_poly_randtest(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_randtest_irreducible(fmpz_mod_poly_t f, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) @@ -90,12 +90,12 @@ cdef extern from "flint/fmpz_mod_poly.h": void fmpz_mod_poly_randtest_pentomial(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_randtest_pentomial_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, slong max_attempts, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_randtest_sparse_irreducible(fmpz_mod_poly_t poly, flint_rand_t state, slong len, const fmpz_mod_ctx_t ctx) - + # Attributes slong fmpz_mod_poly_degree(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) slong fmpz_mod_poly_length(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) fmpz_struct * fmpz_mod_poly_lead(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - + # Assignment and Basic Manipulation void fmpz_mod_poly_set(fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_swap(fmpz_mod_poly_t poly1, fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) @@ -103,7 +103,7 @@ cdef extern from "flint/fmpz_mod_poly.h": void fmpz_mod_poly_one(fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_zero_coeffs(fmpz_mod_poly_t poly, slong i, slong j, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_reverse(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) - + # Conversion void fmpz_mod_poly_set_ui(fmpz_mod_poly_t f, ulong c, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_set_fmpz(fmpz_mod_poly_t f, const fmpz_t c, const fmpz_mod_ctx_t ctx) @@ -111,27 +111,27 @@ cdef extern from "flint/fmpz_mod_poly.h": void fmpz_mod_poly_get_fmpz_poly(fmpz_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_get_nmod_poly(nmod_poly_t f, const fmpz_mod_poly_t g) void fmpz_mod_poly_set_nmod_poly(fmpz_mod_poly_t f, const nmod_poly_t g) - + # Comparison int fmpz_mod_poly_equal(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_equal_trunc(const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_is_zero(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_is_one(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_is_gen(const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - + # Getting and Setting coefficients void fmpz_mod_poly_set_coeff_fmpz(fmpz_mod_poly_t poly, slong n, const fmpz_t x, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_set_coeff_ui(fmpz_mod_poly_t poly, slong n, ulong x, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) # void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly, slong n, const mpz_t x, const fmpz_mod_ctx_t ctx) # void fmpz_mod_poly_get_coeff_mpz(mpz_t x, const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx) - + # Shifiting void _fmpz_mod_poly_shift_left(fmpz_struct * res, const fmpz_struct * poly, slong len, slong n, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_shift_left(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) void _fmpz_mod_poly_shift_right(fmpz_struct * res, const fmpz_struct * poly, slong len, slong n, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_shift_right(fmpz_mod_poly_t f, const fmpz_mod_poly_t g, slong n, const fmpz_mod_ctx_t ctx) - + # Addition and Subtraction void _fmpz_mod_poly_add(fmpz_struct *res, const fmpz_struct *poly1, slong len1, const fmpz_struct *poly2, slong len2, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_add(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) @@ -141,14 +141,14 @@ cdef extern from "flint/fmpz_mod_poly.h": void fmpz_mod_poly_sub_series(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, slong n, const fmpz_mod_ctx_t ctx) void _fmpz_mod_poly_neg(fmpz_struct *res, const fmpz_struct *poly, slong len, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_neg(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) - + # Scalar Multiplication and division void _fmpz_mod_poly_scalar_mul_fmpz(fmpz_struct *res, const fmpz_struct *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_scalar_mul_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_scalar_addmul_fmpz(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, const fmpz_t x, const fmpz_mod_ctx_t ctx) void _fmpz_mod_poly_scalar_div_fmpz(fmpz_struct *res, const fmpz_struct *poly, slong len, const fmpz_t x, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_scalar_div_fmpz(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_t x, const fmpz_mod_ctx_t ctx) - + # Multiplication void _fmpz_mod_poly_mul(fmpz_struct *res, const fmpz_struct *poly1, slong len1, const fmpz_struct *poly2, slong len2, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_mul(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx) @@ -161,12 +161,12 @@ cdef extern from "flint/fmpz_mod_poly.h": void fmpz_mod_poly_mulmod(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) void _fmpz_mod_poly_mulmod_preinv(fmpz_struct * res, const fmpz_struct * poly1, slong len1, const fmpz_struct * poly2, slong len2, const fmpz_struct * f, slong lenf, const fmpz_struct* finv, slong lenfinv, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_mulmod_preinv(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, const fmpz_mod_ctx_t ctx) - + # Products void _fmpz_mod_poly_product_roots_fmpz_vec(fmpz_struct * poly, const fmpz_struct * xs, slong n, fmpz_t f) void fmpz_mod_poly_product_roots_fmpz_vec(fmpz_mod_poly_t poly, const fmpz_struct * xs, slong n, fmpz_t f, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_find_distinct_nonzero_roots(fmpz_struct * roots, const fmpz_mod_poly_t A, const fmpz_mod_ctx_t ctx) - + # Powering void _fmpz_mod_poly_pow(fmpz_struct *rop, const fmpz_struct *op, slong len, ulong e, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_pow(fmpz_mod_poly_t rop, const fmpz_mod_poly_t op, ulong e, const fmpz_mod_ctx_t ctx) @@ -193,7 +193,7 @@ cdef extern from "flint/fmpz_mod_poly.h": void fmpz_mod_poly_frobenius_power(fmpz_mod_poly_t res, fmpz_mod_poly_frobenius_powers_2exp_t pow, const fmpz_mod_poly_t f, ulong m, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_frobenius_powers_precomp(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_poly_t f, const fmpz_mod_poly_t finv, ulong m, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_frobenius_powers_clear(fmpz_mod_poly_frobenius_powers_t pow, const fmpz_mod_ctx_t ctx) - + # Division void _fmpz_mod_poly_divrem_basecase(fmpz_struct * Q, fmpz_struct * R, const fmpz_struct * A, slong lenA, const fmpz_struct * B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_divrem_basecase(fmpz_mod_poly_t Q, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) @@ -213,20 +213,20 @@ cdef extern from "flint/fmpz_mod_poly.h": void _fmpz_mod_poly_rem_f(fmpz_t f, fmpz_struct *R, const fmpz_struct *A, slong lenA, const fmpz_struct *B, slong lenB, const fmpz_t invB, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_rem_f(fmpz_t f, fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_rem(fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx) - + # Divisibility testing int _fmpz_mod_poly_divides_classical(fmpz_struct * Q, const fmpz_struct * A, slong lenA, const fmpz_struct * B, slong lenB, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_divides_classical(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, fmpz_mod_ctx_t ctx) int _fmpz_mod_poly_divides(fmpz_struct * Q, const fmpz_struct * A, slong lenA, const fmpz_struct * B, slong lenB, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_divides(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, fmpz_mod_ctx_t ctx) - + # Power series division void _fmpz_mod_poly_inv_series(fmpz_struct * Qinv, const fmpz_struct * Q, slong n, const fmpz_t cinv, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_inv_series(fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_inv_series_f(fmpz_t f, fmpz_mod_poly_t Qinv, const fmpz_mod_poly_t Q, slong n, const fmpz_mod_ctx_t ctx) void _fmpz_mod_poly_div_series(fmpz_struct * Q, const fmpz_struct * A, slong Alen, const fmpz_struct * B, slong Blen, const fmpz_t p, slong n) void fmpz_mod_poly_div_series(fmpz_mod_poly_t Q, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, slong n, const fmpz_mod_ctx_t ctx) - + # Greatest common divisor void fmpz_mod_poly_make_monic(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) @@ -254,7 +254,7 @@ cdef extern from "flint/fmpz_mod_poly.h": int _fmpz_mod_poly_invmod_f(fmpz_t f, fmpz_struct *A, const fmpz_struct *B, slong lenB, const fmpz_struct *P, slong lenP, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_invmod(fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) int fmpz_mod_poly_invmod_f(fmpz_t f, fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_poly_t P, const fmpz_mod_ctx_t ctx) - + # Minpoly slong _fmpz_mod_poly_minpoly_bm(fmpz_struct* poly, const fmpz_struct* seq, slong len, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_minpoly_bm(fmpz_mod_poly_t poly, const fmpz_struct* seq, slong len, const fmpz_mod_ctx_t ctx) @@ -262,7 +262,7 @@ cdef extern from "flint/fmpz_mod_poly.h": void fmpz_mod_poly_minpoly_hgcd(fmpz_mod_poly_t poly, const fmpz_struct* seq, slong len, const fmpz_mod_ctx_t ctx) slong _fmpz_mod_poly_minpoly(fmpz_struct* poly, const fmpz_struct* seq, slong len, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_minpoly(fmpz_mod_poly_t poly, const fmpz_struct* seq, slong len, const fmpz_mod_ctx_t ctx) - + # Resultant void _fmpz_mod_poly_resultant_euclidean(fmpz_t res, const fmpz_struct *poly1, slong len1, const fmpz_struct *poly2, slong len2, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_resultant_euclidean(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_poly_t g, const fmpz_mod_ctx_t ctx) @@ -278,7 +278,7 @@ cdef extern from "flint/fmpz_mod_poly.h": void fmpz_mod_poly_evaluate_fmpz(fmpz_t res, const fmpz_mod_poly_t poly, const fmpz_t a, const fmpz_mod_ctx_t ctx) void _fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz_struct * ys, const fmpz_struct * coeffs, slong len, const fmpz_struct * xs, slong n, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_evaluate_fmpz_vec_iter(fmpz_struct * ys, const fmpz_mod_poly_t poly, const fmpz_struct * xs, slong n, const fmpz_mod_ctx_t ctx) - void _fmpz_mod_poly_evaluate_fmpz_vec_fast_precomp(fmpz_struct * vs, const fmpz_struct * poly, slong plen, fmpz_poly_struct * const * tree, slong len, const fmpz_mod_ctx_t ctx) + void _fmpz_mod_poly_evaluate_fmpz_vec_fast_precomp(fmpz_struct * vs, const fmpz_struct * poly, slong plen, fmpz_poly_struct * const * tree, slong len, const fmpz_mod_ctx_t ctx) void _fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz_struct * ys, const fmpz_struct * poly, slong plen, const fmpz_struct * xs, slong n, const fmpz_mod_ctx_t ctx) void fmpz_mod_poly_evaluate_fmpz_vec_fast(fmpz_struct * ys, const fmpz_mod_poly_t poly, const fmpz_struct * xs, slong n, const fmpz_mod_ctx_t ctx) void _fmpz_mod_poly_evaluate_fmpz_vec(fmpz_struct * ys, const fmpz_struct * coeffs, slong len, const fmpz_struct * xs, slong n, const fmpz_mod_ctx_t ctx) diff --git a/src/flint/flintlib/fq_zech.pxd b/src/flint/flintlib/fq_zech.pxd index 8b20aef3..387510b7 100644 --- a/src/flint/flintlib/fq_zech.pxd +++ b/src/flint/flintlib/fq_zech.pxd @@ -12,19 +12,19 @@ cdef extern from "flint/fq_zech.h": ctypedef fq_zech_struct fq_zech_t[1] ctypedef struct fq_zech_ctx_struct: - mp_limb_t qm1 # q - 1 - mp_limb_t qm1o2 # (q - 1) / 2 or 1 when p == 2 - mp_limb_t qm1opm1 # (q - 1) / (p - 1) + mp_limb_t qm1 # q - 1 + mp_limb_t qm1o2 # (q - 1) / 2 or 1 when p == 2 + mp_limb_t qm1opm1 # (q - 1) / (p - 1) mp_limb_t p double ppre - mp_limb_t prime_root # primitive root for prime subfield + mp_limb_t prime_root # primitive root for prime subfield mp_limb_t * zech_log_table mp_limb_t * prime_field_table mp_limb_t * eval_table fq_nmod_ctx_struct * fq_nmod_ctx int owns_fq_nmod_ctx - int is_conway # whether field was generated using Flint Conway tables (assures primitivity) + int is_conway # whether field was generated using Flint Conway tables (assures primitivity) ctypedef fq_zech_ctx_struct fq_zech_ctx_t[1] ctypedef struct fq_zech_mat_struct: diff --git a/src/flint/pyflint.pxd b/src/flint/pyflint.pxd index 19779743..ec18e14c 100644 --- a/src/flint/pyflint.pxd +++ b/src/flint/pyflint.pxd @@ -14,4 +14,3 @@ cdef class Context: cdef public bint pretty cdef public long prec cdef arf_rnd_t rnd - diff --git a/src/flint/types/acb.pyx b/src/flint/types/acb.pyx index 67d492e1..83989ac1 100644 --- a/src/flint/types/acb.pyx +++ b/src/flint/types/acb.pyx @@ -1176,7 +1176,7 @@ cdef class acb(flint_scalar): >>> from flint import showgood >>> for i in range(4): ... showgood(lambda: acb(1+1j).modular_theta(1.25+3j)[i], dps=25) - ... + ... 1.820235910124989594900076 - 1.216251950154477951760042j -1.220790267576967690128359 - 1.827055516791154669091679j 0.9694430387796704100046143 - 0.03055696120816803328582847j @@ -1420,7 +1420,7 @@ cdef class acb(flint_scalar): def bits(self): r"""Returns maximum of :meth:`.arb.bits` called on real and imaginary part. - + >>> acb("2047/2048").bits() 11 """ diff --git a/src/flint/types/acb_series.pyx b/src/flint/types/acb_series.pyx index d9161913..4e953ec9 100644 --- a/src/flint/types/acb_series.pyx +++ b/src/flint/types/acb_series.pyx @@ -652,7 +652,7 @@ cdef class acb_series(flint_series): libc.stdlib.free(aa) libc.stdlib.free(bb) (u).prec = cap - return u + return u def airy_ai(s): cdef long cap diff --git a/src/flint/types/arb.pyx b/src/flint/types/arb.pyx index 98fd481e..12259088 100644 --- a/src/flint/types/arb.pyx +++ b/src/flint/types/arb.pyx @@ -803,8 +803,9 @@ cdef class arb(flint_scalar): return u def log_base(s, ulong b): - r"""Returns `\log_b(s)`, computed exactly when possible. - + r""" + Returns `\log_b(s)`, computed exactly when possible. + >>> arb(2048).log_base(2) 11.0000000000000 """ @@ -2421,8 +2422,9 @@ cdef class arb(flint_scalar): return arb_rel_one_accuracy_bits(self.val) def bits(self): - r"""Returns number of bits needed to represent absolute value of mantissa of the midpoint; returns 0 if midpoint is special value. - + r""" + Returns number of bits needed to represent absolute value of mantissa of the midpoint; returns 0 if midpoint is special value. + >>> arb("2047/2048").bits() 11 """ diff --git a/src/flint/types/arb_poly.pyx b/src/flint/types/arb_poly.pyx index cb38d272..f0b2bbcc 100644 --- a/src/flint/types/arb_poly.pyx +++ b/src/flint/types/arb_poly.pyx @@ -115,7 +115,7 @@ cdef class arb_poly(flint_poly): def complex_roots(self, **kwargs): """ - Compute the complex roots of the polynomial by converting + Compute the complex roots of the polynomial by converting from arb_poly to acb_poly """ return acb_poly(self).roots(**kwargs) diff --git a/src/flint/types/dirichlet.pyx b/src/flint/types/dirichlet.pyx index 613ca704..a34c0f24 100644 --- a/src/flint/types/dirichlet.pyx +++ b/src/flint/types/dirichlet.pyx @@ -61,7 +61,7 @@ cdef class dirichlet_char(object): >>> chi = dirichlet_char(7, 1) >>> for n in range(7): ... print(chi(n)) - ... + ... 0 1.00000000000000 1.00000000000000 @@ -72,7 +72,7 @@ cdef class dirichlet_char(object): >>> chi = dirichlet_char(7, 3) >>> for n in range(7): ... print(chi(n)) - ... + ... 0 1.00000000000000 -0.500000000000000 + [0.866025403784439 +/- 5.15e-16]j @@ -206,4 +206,3 @@ cdef class dirichlet_char(object): v = acb.__new__(acb) acb_dirichlet_hardy_z((v).val, (s).val, self.G.val, self.val, 1, getprec()) return v - diff --git a/src/flint/types/fmpq.pyx b/src/flint/types/fmpq.pyx index 28a9dc67..05cbff2f 100644 --- a/src/flint/types/fmpq.pyx +++ b/src/flint/types/fmpq.pyx @@ -302,7 +302,7 @@ cdef class fmpq(flint_scalar): ... b.append(b[-1].next(signed=False)) ... c.append(c[-1].next(minimal=False)) ... d.append(d[-1].next(signed=False, minimal=False)) - ... + ... >>> a [0, 1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, 3, -3, 2/3, -2/3, 3/2, -3/2, 1/4, -1/4, 4, -4, 3/4, -3/4] >>> b diff --git a/src/flint/types/fmpq_poly.pxd b/src/flint/types/fmpq_poly.pxd index 2353cded..b50d015d 100644 --- a/src/flint/types/fmpq_poly.pxd +++ b/src/flint/types/fmpq_poly.pxd @@ -4,6 +4,6 @@ from flint.flintlib.fmpq_poly cimport fmpq_poly_t cdef fmpq_poly_set_list(fmpq_poly_t poly, list val) cdef any_as_fmpq_poly(obj) cdef class fmpq_poly(flint_poly): - cdef fmpq_poly_t val + cdef fmpq_poly_t val cpdef long length(self) cpdef long degree(self) diff --git a/src/flint/types/fmpz.pxd b/src/flint/types/fmpz.pxd index eaf8cad3..bad897ee 100644 --- a/src/flint/types/fmpz.pxd +++ b/src/flint/types/fmpz.pxd @@ -32,6 +32,5 @@ cdef class fmpz(flint_scalar): >>> fmpz(3) ** 25 847288609443 - """ - + """ cdef fmpz_t val diff --git a/src/flint/types/fmpz.pyx b/src/flint/types/fmpz.pyx index 3c4c75e8..af5e6cd6 100644 --- a/src/flint/types/fmpz.pyx +++ b/src/flint/types/fmpz.pyx @@ -684,9 +684,9 @@ cdef class fmpz(flint_scalar): def is_perfect_power(self): r""" - Return True if this integer is of the form `r^k` with `k>1`, False otherwise. + Return ``True`` if this integer is of the form `r^k` with `k>1`, False otherwise. `0, 1, -1` are considered perfect powers. - + >>> fmpz(81).is_perfect_power() True >>> fmpz(1234).is_perfect_power() diff --git a/src/flint/types/fmpz_mod.pxd b/src/flint/types/fmpz_mod.pxd index f0356953..7133dfdb 100644 --- a/src/flint/types/fmpz_mod.pxd +++ b/src/flint/types/fmpz_mod.pxd @@ -14,7 +14,7 @@ cdef class fmpz_mod_ctx: cdef set_any_as_fmpz_mod(self, fmpz_t val, obj) cdef any_as_fmpz_mod(self, obj) cdef discrete_log_pohlig_hellman_run(self, fmpz_t x, fmpz_t y) - + cdef class fmpz_mod(flint_scalar): cdef fmpz_mod_ctx ctx cdef fmpz_t val diff --git a/src/flint/types/fmpz_mod.pyx b/src/flint/types/fmpz_mod.pyx index 2b8ec8eb..099c6426 100644 --- a/src/flint/types/fmpz_mod.pyx +++ b/src/flint/types/fmpz_mod.pyx @@ -35,7 +35,7 @@ from flint.utils.flint_exceptions import DomainError cdef class fmpz_mod_ctx: r""" - Context object for creating :class:`~.fmpz_mod` initialised + Context object for creating :class:`~.fmpz_mod` initialised with a modulus :math:`N`. >>> fmpz_mod_ctx(2**127 - 1) @@ -106,7 +106,7 @@ cdef class fmpz_mod_ctx: >>> F.zero() fmpz_mod(0, 163) """ - cdef fmpz_mod res + cdef fmpz_mod res res = fmpz_mod.__new__(fmpz_mod) fmpz_zero(res.val) res.ctx = self @@ -121,7 +121,7 @@ cdef class fmpz_mod_ctx: >>> F.one() fmpz_mod(1, 163) """ - cdef fmpz_mod res + cdef fmpz_mod res res = fmpz_mod.__new__(fmpz_mod) fmpz_one(res.val) res.ctx = self @@ -157,15 +157,15 @@ cdef class fmpz_mod_ctx: raise ValueError("moduli must match") fmpz_set(val, (obj).val) return 0 - + # Try and convert obj to fmpz if not typecheck(obj, fmpz): obj = any_as_fmpz(obj) if obj is NotImplemented: return NotImplemented - + fmpz_mod_set_fmpz(val, (obj).val, self.val) - + return 0 cdef any_as_fmpz_mod(self, obj): @@ -184,7 +184,7 @@ cdef class fmpz_mod_ctx: if check is NotImplemented: return NotImplemented res.ctx = self - + return res def __eq__(self, other): @@ -192,11 +192,11 @@ cdef class fmpz_mod_ctx: # If we could cache contexts, then we would ensure that only # the a is b check is needed for equality. - # Most often, we expect both `fmpz_mod` to be pointing to the + # Most often, we expect both `fmpz_mod` to be pointing to the # same ctx, so this seems the fastest way to check if self is other: return True - + # If they're not the same object in memory, they may have the # same modulus, which is good enough if typecheck(other, fmpz_mod_ctx): @@ -217,7 +217,7 @@ cdef class fmpz_mod_ctx: cdef class fmpz_mod(flint_scalar): """ - The *fmpz_mod* type represents integer modulo an + The *fmpz_mod* type represents integer modulo an arbitrary-size modulus. For wordsize modulus, see :class:`~.nmod`. @@ -297,7 +297,7 @@ cdef class fmpz_mod(flint_scalar): Computes :math:`a^{-1} \pmod N` When check=False, the solutions is assumed to exist and Flint will abort on - failure. + failure. >>> mod_ctx = fmpz_mod_ctx(163) >>> mod_ctx(2).inverse() diff --git a/src/flint/types/fmpz_mod_poly.pyx b/src/flint/types/fmpz_mod_poly.pyx index 7f5edc06..699815b9 100644 --- a/src/flint/types/fmpz_mod_poly.pyx +++ b/src/flint/types/fmpz_mod_poly.pyx @@ -188,7 +188,7 @@ cdef class fmpz_mod_poly_ctx: return 0 cdef set_any_as_fmpz_mod_poly(self, fmpz_mod_poly_t poly, obj): - # Set val from fmpz_mod_poly + # Set val from fmpz_mod_poly if typecheck(obj, fmpz_mod_poly): if self != (obj).ctx: raise ValueError("moduli must match") diff --git a/src/flint/types/nmod_poly.pyx b/src/flint/types/nmod_poly.pyx index c1cc1546..ea4239d6 100644 --- a/src/flint/types/nmod_poly.pyx +++ b/src/flint/types/nmod_poly.pyx @@ -213,7 +213,7 @@ cdef class nmod_poly(flint_poly): """ cdef nmod_poly res cdef slong d - + if degree is not None: d = degree if d != degree or d < 0: @@ -266,7 +266,7 @@ cdef class nmod_poly(flint_poly): """ if n <= 0: raise ValueError(f"{n = } must be positive") - + if self.is_zero(): raise ValueError(f"cannot invert the zero element") @@ -280,7 +280,7 @@ cdef class nmod_poly(flint_poly): """ Returns the composition of two polynomials - To be precise about the order of composition, given ``self``, and ``other`` + To be precise about the order of composition, given ``self``, and ``other`` by `f(x)`, `g(x)`, returns `f(g(x))`. >>> f = nmod_poly([1,2,3], 163) @@ -296,15 +296,15 @@ cdef class nmod_poly(flint_poly): raise TypeError("cannot convert input to nmod_poly") res = nmod_poly.__new__(nmod_poly) nmod_poly_init_preinv(res.val, self.val.mod.n, self.val.mod.ninv) - nmod_poly_compose(res.val, self.val, (other).val) - return res + nmod_poly_compose(res.val, self.val, (other).val) + return res def compose_mod(self, other, modulus): r""" Returns the composition of two polynomials modulo a third. - To be precise about the order of composition, given ``self``, and ``other`` - and ``modulus`` by `f(x)`, `g(x)` and `h(x)`, returns `f(g(x)) \mod h(x)`. + To be precise about the order of composition, given ``self``, and ``other`` + and ``modulus`` by `f(x)`, `g(x)` and `h(x)`, returns `f(g(x)) \mod h(x)`. We require that `h(x)` is non-zero. >>> f = nmod_poly([1,2,3,4,5], 163) @@ -319,18 +319,18 @@ cdef class nmod_poly(flint_poly): g = any_as_nmod_poly(other, self.val.mod) if g is NotImplemented: raise TypeError(f"cannot convert {other = } to nmod_poly") - + h = any_as_nmod_poly(modulus, self.val.mod) if h is NotImplemented: raise TypeError(f"cannot convert {modulus = } to nmod_poly") - + if modulus.is_zero(): raise ZeroDivisionError("cannot reduce modulo zero") res = nmod_poly.__new__(nmod_poly) nmod_poly_init_preinv(res.val, self.val.mod.n, self.val.mod.ninv) - nmod_poly_compose_mod(res.val, self.val, (other).val, (modulus).val) - return res + nmod_poly_compose_mod(res.val, self.val, (other).val, (modulus).val) + return res def __call__(self, other): cdef mp_limb_t c @@ -520,8 +520,8 @@ cdef class nmod_poly(flint_poly): >>> f = 30*x**6 + 104*x**5 + 76*x**4 + 33*x**3 + 70*x**2 + 44*x + 65 >>> g = 43*x**6 + 91*x**5 + 77*x**4 + 113*x**3 + 71*x**2 + 132*x + 60 >>> mod = x**4 + 93*x**3 + 78*x**2 + 72*x + 149 - >>> - >>> f.pow_mod(123, mod) + >>> + >>> f.pow_mod(123, mod) 3*x^3 + 25*x^2 + 115*x + 161 >>> f.pow_mod(2**64, mod) 52*x^3 + 96*x^2 + 136*x + 9 @@ -541,7 +541,7 @@ cdef class nmod_poly(flint_poly): # Output polynomial res = nmod_poly.__new__(nmod_poly) nmod_poly_init_preinv(res.val, self.val.mod.n, self.val.mod.ninv) - + # For small exponents, use a simple binary exponentiation method if e.bit_length() < 32: nmod_poly_powmod_ui_binexp( From 1ebdbdab134bfbdfccc0da7f6a5922e73c32ca35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 30 Aug 2024 17:31:19 +0200 Subject: [PATCH 5/6] fix indentation --- src/flint/types/acb_series.pyx | 4 ++-- src/flint/types/arb_series.pyx | 4 ++-- src/flint/types/fq_default.pyx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/flint/types/acb_series.pyx b/src/flint/types/acb_series.pyx index 4e953ec9..a7b7137d 100644 --- a/src/flint/types/acb_series.pyx +++ b/src/flint/types/acb_series.pyx @@ -293,8 +293,8 @@ cdef class acb_series(flint_series): cap = getcap() cap = min(cap, (s).prec) if s.length() < 2 or (not acb_is_zero(&s.val.coeffs[0])) or \ - (acb_contains_zero(&s.val.coeffs[1])): - raise ValueError("power series reversion requires valuation 1") + (acb_contains_zero(&s.val.coeffs[1])): + raise ValueError("power series reversion requires valuation 1") u = acb_series.__new__(acb_series) acb_poly_revert_series((u).val, (s).val, cap, getprec()) (u).prec = cap diff --git a/src/flint/types/arb_series.pyx b/src/flint/types/arb_series.pyx index dc901175..4f58a72f 100644 --- a/src/flint/types/arb_series.pyx +++ b/src/flint/types/arb_series.pyx @@ -285,8 +285,8 @@ cdef class arb_series(flint_series): cap = getcap() cap = min(cap, (s).prec) if s.length() < 2 or (not arb_is_zero(&s.val.coeffs[0])) or \ - (not arb_is_nonzero(&s.val.coeffs[1])): - raise ValueError("power series reversion requires valuation 1") + (not arb_is_nonzero(&s.val.coeffs[1])): + raise ValueError("power series reversion requires valuation 1") u = arb_series.__new__(arb_series) arb_poly_revert_series((u).val, (s).val, cap, getprec()) (u).prec = cap diff --git a/src/flint/types/fq_default.pyx b/src/flint/types/fq_default.pyx index b2593961..6b6e2bee 100644 --- a/src/flint/types/fq_default.pyx +++ b/src/flint/types/fq_default.pyx @@ -545,10 +545,10 @@ cdef class fq_default(flint_scalar): # For nmod and fmpz_mod if the modulus does not match the characteristic # then we return false. if typecheck(other, nmod) and self.ctx.characteristic() != (other).modulus(): - res = False + res = False elif typecheck(other, fmpz_mod) and self.ctx.characteristic() != (other).ctx.modulus(): - res = False + res = False else: # Convert from int, fmpz, fmpz_mod and nmod to fq_default From 6c4fb2ce2811471d9ed96ddefff6cb50765f1e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 30 Aug 2024 17:33:42 +0200 Subject: [PATCH 6/6] fix empty lines --- src/flint/flintlib/arb.pxd | 1 - src/flint/flintlib/fmpq.pxd | 3 --- src/flint/flintlib/nmod_poly.pxd | 1 - src/flint/functions/showgood.pyx | 2 ++ src/flint/types/acb.pyx | 1 + src/flint/types/acb_theta.pyx | 1 + src/flint/types/arb_series.pyx | 1 + src/flint/types/fmpz_mod.pyx | 1 - 8 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/flint/flintlib/arb.pxd b/src/flint/flintlib/arb.pxd index e0887ff9..eff2161f 100644 --- a/src/flint/flintlib/arb.pxd +++ b/src/flint/flintlib/arb.pxd @@ -254,7 +254,6 @@ cdef extern from "flint/arb.h": void arb_lambertw(arb_t z, const arb_t x, int flags, long prec) - void arb_rising_ui_bs(arb_t y, const arb_t x, ulong n, long prec) void arb_rising_ui_rs(arb_t y, const arb_t x, ulong n, ulong m, long prec) void arb_rising_ui_rec(arb_t y, const arb_t x, ulong n, long prec) diff --git a/src/flint/flintlib/fmpq.pxd b/src/flint/flintlib/fmpq.pxd index b9934e50..c10cf64a 100644 --- a/src/flint/flintlib/fmpq.pxd +++ b/src/flint/flintlib/fmpq.pxd @@ -218,9 +218,6 @@ cdef extern from "flint/fmpq.h": void fmpq_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k) void fmpq_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k) - - - # void fmpq_init(fmpq_t x) # void fmpq_clear(fmpq_t x) # void fmpq_zero(fmpq_t res) diff --git a/src/flint/flintlib/nmod_poly.pxd b/src/flint/flintlib/nmod_poly.pxd index 3448cbd6..f24f72ce 100644 --- a/src/flint/flintlib/nmod_poly.pxd +++ b/src/flint/flintlib/nmod_poly.pxd @@ -364,7 +364,6 @@ cdef extern from "flint/nmod_poly.h": # const nmod_poly_struct * nmod_berlekamp_massey_V_poly(const nmod_berlekamp_massey_t B) # const nmod_poly_struct * nmod_berlekamp_massey_R_poly(const nmod_berlekamp_massey_t B) - # void nmod_poly_init(nmod_poly_t poly, mp_limb_t n) # void nmod_poly_init_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv) # void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, long alloc) diff --git a/src/flint/functions/showgood.pyx b/src/flint/functions/showgood.pyx index 34870625..ac7a87fd 100644 --- a/src/flint/functions/showgood.pyx +++ b/src/flint/functions/showgood.pyx @@ -36,6 +36,7 @@ cdef goodstr(x): return x.str(radius=False) raise TypeError("must be a element/tuple/list of arb, acb, arb_mat, acb_mat, arb_poly, acb_poly, arb_series, or acb_series") + def good(func, slong prec=0, slong maxprec=0, slong dps=0, slong maxdps=0, slong padding=10, bint verbose=False, bint show=False, bint parts=True, metric=None): """ @@ -113,6 +114,7 @@ def good(func, slong prec=0, slong maxprec=0, slong dps=0, ctx.prec = orig raise ValueError("no convergence (maxprec=%i, try higher maxprec)" % maxprec) + def showgood(func, **kwargs): """ Evaluates *func* accurately with :func:`good`, printing the decimal diff --git a/src/flint/types/acb.pyx b/src/flint/types/acb.pyx index 83989ac1..7bfce702 100644 --- a/src/flint/types/acb.pyx +++ b/src/flint/types/acb.pyx @@ -97,6 +97,7 @@ cdef any_as_arb_or_acb(x): return acb(x) """ + # Copied with modifications from sage/rings/complex_arb.pyx @cython.internal cdef class IntegrationContext: diff --git a/src/flint/types/acb_theta.pyx b/src/flint/types/acb_theta.pyx index 52cca748..ae11ce17 100644 --- a/src/flint/types/acb_theta.pyx +++ b/src/flint/types/acb_theta.pyx @@ -5,6 +5,7 @@ from flint.flintlib.acb cimport * from flint.flintlib.acb_mat cimport * from flint.flintlib.acb_theta cimport * + def acb_theta(acb_mat z, acb_mat tau, ulong square=False): r""" Computes the vector valued Riemann theta function diff --git a/src/flint/types/arb_series.pyx b/src/flint/types/arb_series.pyx index 4f58a72f..4488bb57 100644 --- a/src/flint/types/arb_series.pyx +++ b/src/flint/types/arb_series.pyx @@ -803,6 +803,7 @@ cdef class arb_series(flint_series): """ orig_cap = ctx.cap + def xsgn(x): if x < 0: return -1 diff --git a/src/flint/types/fmpz_mod.pyx b/src/flint/types/fmpz_mod.pyx index 099c6426..475a5ef0 100644 --- a/src/flint/types/fmpz_mod.pyx +++ b/src/flint/types/fmpz_mod.pyx @@ -409,7 +409,6 @@ cdef class fmpz_mod(flint_scalar): else: return not res - def __bool__(self): return not self.is_zero()