diff --git a/src/flint/flintlib/fmpz_mpoly.pxd b/src/flint/flintlib/fmpz_mpoly.pxd index 6cc7d167..82610dc2 100644 --- a/src/flint/flintlib/fmpz_mpoly.pxd +++ b/src/flint/flintlib/fmpz_mpoly.pxd @@ -242,9 +242,9 @@ cdef extern from "flint/fmpz_mpoly.h": void fmpz_mpoly_symmetric_gens(fmpz_mpoly_t res, ulong k, slong * vars, slong n, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_symmetric(fmpz_mpoly_t res, ulong k, const fmpz_mpoly_ctx_t ctx) # undocumented functions - void _fmpz_mpoly_push_exp_ffmpz(fmpz_mpoly_t A, const fmpz_struct * exp, const fmpz_mpoly_ctx_t ctx); - void _fmpz_mpoly_push_exp_pfmpz(fmpz_mpoly_t A, fmpz_struct * const * exp, const fmpz_mpoly_ctx_t ctx); - void _fmpz_mpoly_push_exp_ui(fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx); + void _fmpz_mpoly_push_exp_ffmpz(fmpz_mpoly_t A, const fmpz_struct * exp, const fmpz_mpoly_ctx_t ctx) + void _fmpz_mpoly_push_exp_pfmpz(fmpz_mpoly_t A, fmpz_struct * const * exp, const fmpz_mpoly_ctx_t ctx) + void _fmpz_mpoly_push_exp_ui(fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx) # Macros fmpz_mpoly_struct *fmpz_mpoly_vec_entry(fmpz_mpoly_vec_t vec, slong i) diff --git a/src/flint/flintlib/fmpz_mpoly_factor.pxd b/src/flint/flintlib/fmpz_mpoly_factor.pxd index 62335351..0c3eff2c 100644 --- a/src/flint/flintlib/fmpz_mpoly_factor.pxd +++ b/src/flint/flintlib/fmpz_mpoly_factor.pxd @@ -14,7 +14,7 @@ cdef extern from "flint/fmpz_mpoly_factor.h": slong num slong alloc - ctypedef fmpz_mpoly_factor_struct fmpz_mpoly_factor_t[1]; + ctypedef fmpz_mpoly_factor_struct fmpz_mpoly_factor_t[1] void fmpz_mpoly_factor_init(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) void fmpz_mpoly_factor_clear(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) diff --git a/src/flint/flintlib/fq_nmod.pxd b/src/flint/flintlib/fq_nmod.pxd index da598834..b7bb2ceb 100644 --- a/src/flint/flintlib/fq_nmod.pxd +++ b/src/flint/flintlib/fq_nmod.pxd @@ -100,8 +100,8 @@ cdef extern from "flint/fq_nmod.h": void fq_nmod_one(fq_nmod_t rop, const fq_nmod_ctx_t ctx) void fq_nmod_gen(fq_nmod_t rop, const fq_nmod_ctx_t ctx) int fq_nmod_get_fmpz(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx) - void fq_nmod_get_nmod_poly(nmod_poly_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx); - void fq_nmod_set_nmod_poly(fq_nmod_t a, const nmod_poly_t b, const fq_nmod_ctx_t ctx); + void fq_nmod_get_nmod_poly(nmod_poly_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx) + void fq_nmod_set_nmod_poly(fq_nmod_t a, const nmod_poly_t b, const fq_nmod_ctx_t ctx) void fq_nmod_get_nmod_mat(nmod_mat_t col, const fq_nmod_t a, const fq_nmod_ctx_t ctx) void fq_nmod_set_nmod_mat(fq_nmod_t a, const nmod_mat_t col, const fq_nmod_ctx_t ctx) int fq_nmod_is_zero(const fq_nmod_t op, const fq_nmod_ctx_t ctx) diff --git a/src/flint/types/acb.pyx b/src/flint/types/acb.pyx index 7bfce702..f29e3520 100644 --- a/src/flint/types/acb.pyx +++ b/src/flint/types/acb.pyx @@ -202,7 +202,8 @@ cdef class acb(flint_scalar): res = acb_eq(s.val, tval) else: res = acb_ne(s.val, tval) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return res def __contains__(self, other): @@ -402,7 +403,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_add((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def __radd__(s, t): @@ -413,7 +415,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_add((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def __sub__(s, t): @@ -424,7 +427,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_sub((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def __rsub__(s, t): @@ -435,7 +439,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_sub((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def __mul__(s, t): @@ -446,7 +451,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_mul((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def __rmul__(s, t): @@ -457,7 +463,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_mul((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def __truediv__(s, t): @@ -468,7 +475,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_div((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def __rtruediv__(s, t): @@ -479,7 +487,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_div((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def __pow__(s, t, u): @@ -492,7 +501,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_pow((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def __rpow__(s, t, u): @@ -505,7 +515,8 @@ cdef class acb(flint_scalar): return NotImplemented u = acb.__new__(acb) acb_pow((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: acb_clear(tval) + if ttype == FMPZ_TMP: + acb_clear(tval) return u def union(s, t): @@ -1535,11 +1546,16 @@ cdef class acb(flint_scalar): c = any_as_acb(c) u = acb.__new__(acb) flags = 0 - if regularized: flags |= 1 - if ab: flags |= 2 - if ac: flags |= 4 - if bc: flags |= 8 - if abc: flags |= 16 + if regularized: + flags |= 1 + if ab: + flags |= 2 + if ac: + flags |= 4 + if bc: + flags |= 8 + if abc: + flags |= 16 acb_hypgeom_2f1((u).val, (a).val, (b).val, (c).val, (self).val, flags, getprec()) return u diff --git a/src/flint/types/arb.pyx b/src/flint/types/arb.pyx index 12259088..e139819b 100644 --- a/src/flint/types/arb.pyx +++ b/src/flint/types/arb.pyx @@ -479,14 +479,22 @@ cdef class arb(flint_scalar): if ttype == FMPZ_UNKNOWN: return NotImplemented res = 0 - if op == 2: res = arb_eq(sval, tval) - elif op == 3: res = arb_ne(sval, tval) - elif op == 0: res = arb_lt(sval, tval) - elif op == 1: res = arb_le(sval, tval) - elif op == 4: res = arb_gt(sval, tval) - elif op == 5: res = arb_ge(sval, tval) - if stype == FMPZ_TMP: arb_clear(sval) - if ttype == FMPZ_TMP: arb_clear(tval) + if op == 2: + res = arb_eq(sval, tval) + elif op == 3: + res = arb_ne(sval, tval) + elif op == 0: + res = arb_lt(sval, tval) + elif op == 1: + res = arb_le(sval, tval) + elif op == 4: + res = arb_gt(sval, tval) + elif op == 5: + res = arb_ge(sval, tval) + if stype == FMPZ_TMP: + arb_clear(sval) + if ttype == FMPZ_TMP: + arb_clear(tval) return res def __contains__(self, other): @@ -563,7 +571,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_add((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def __radd__(s, t): @@ -574,7 +583,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_add((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def __sub__(s, t): @@ -585,7 +595,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_sub((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def __rsub__(s, t): @@ -596,7 +607,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_sub((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def __mul__(s, t): @@ -607,7 +619,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_mul((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def __rmul__(s, t): @@ -618,7 +631,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_mul((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def __truediv__(s, t): @@ -629,7 +643,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_div((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def __rtruediv__(s, t): @@ -640,7 +655,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_div((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def __pow__(s, t, modulus): @@ -653,7 +669,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_pow((u).val, (s).val, tval, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def __rpow__(s, t, modulus): @@ -666,7 +683,8 @@ cdef class arb(flint_scalar): return NotImplemented u = arb.__new__(arb) arb_pow((u).val, tval, s.val, getprec()) - if ttype == FMPZ_TMP: arb_clear(tval) + if ttype == FMPZ_TMP: + arb_clear(tval) return u def floor(s): @@ -2252,11 +2270,16 @@ cdef class arb(flint_scalar): c = any_as_arb(c) u = arb.__new__(arb) flags = 0 - if regularized: flags |= 1 - if ab: flags |= 2 - if ac: flags |= 4 - if bc: flags |= 8 - if abc: flags |= 16 + if regularized: + flags |= 1 + if ab: + flags |= 2 + if ac: + flags |= 4 + if bc: + flags |= 8 + if abc: + flags |= 16 arb_hypgeom_2f1((u).val, (a).val, (b).val, (c).val, (self).val, flags, getprec()) return u diff --git a/src/flint/types/arf.pyx b/src/flint/types/arf.pyx index 53d1ef30..5c8fcb23 100644 --- a/src/flint/types/arf.pyx +++ b/src/flint/types/arf.pyx @@ -127,12 +127,18 @@ cdef class arf: cdef bint res = 0 if not typecheck(t, arf): t = arf(t) - if op == 2: res = arf_equal((s).val, (t).val) - elif op == 3: res = not arf_equal((s).val, (t).val) - elif op == 0: res = arf_cmp((s).val, (t).val) < 0 - elif op == 1: res = arf_cmp((s).val, (t).val) <= 0 - elif op == 4: res = arf_cmp((s).val, (t).val) > 0 - elif op == 5: res = arf_cmp((s).val, (t).val) >= 0 + if op == 2: + res = arf_equal((s).val, (t).val) + elif op == 3: + res = not arf_equal((s).val, (t).val) + elif op == 0: + res = arf_cmp((s).val, (t).val) < 0 + elif op == 1: + res = arf_cmp((s).val, (t).val) <= 0 + elif op == 4: + res = arf_cmp((s).val, (t).val) > 0 + elif op == 5: + res = arf_cmp((s).val, (t).val) >= 0 return res def __pos__(self): diff --git a/src/flint/types/fmpq.pyx b/src/flint/types/fmpq.pyx index 05cbff2f..ab5aa985 100644 --- a/src/flint/types/fmpq.pyx +++ b/src/flint/types/fmpq.pyx @@ -120,11 +120,16 @@ cdef class fmpq(flint_scalar): return res else: # todo: use fmpq_cmp when available - if op == 0: res = (s-t).p < 0 - elif op == 1: res = (s-t).p <= 0 - elif op == 4: res = (s-t).p > 0 - elif op == 5: res = (s-t).p >= 0 - else: raise ValueError + if op == 0: + res = (s-t).p < 0 + elif op == 1: + res = (s-t).p <= 0 + elif op == 4: + res = (s-t).p > 0 + elif op == 5: + res = (s-t).p >= 0 + else: + raise ValueError return res def numer(self): @@ -474,13 +479,15 @@ cdef class fmpq(flint_scalar): return NotImplemented if fmpq_is_zero((self).val) and fmpz_sgn(nval) == -1: - if ntype == FMPZ_TMP: fmpz_clear(nval) + if ntype == FMPZ_TMP: + fmpz_clear(nval) raise ZeroDivisionError v = fmpq.__new__(fmpq) success = fmpq_pow_fmpz(v.val, (self).val, nval) - if ntype == FMPZ_TMP: fmpz_clear(nval) + if ntype == FMPZ_TMP: + fmpz_clear(nval) if success: return v diff --git a/src/flint/types/fmpz.pyx b/src/flint/types/fmpz.pyx index af5e6cd6..c6c1d30d 100644 --- a/src/flint/types/fmpz.pyx +++ b/src/flint/types/fmpz.pyx @@ -130,12 +130,18 @@ cdef class fmpz(flint_scalar): sval = &((s).val[0]) ttype = fmpz_set_any_ref(tval, t) if ttype != FMPZ_UNKNOWN: - if op == 2: res = fmpz_equal(sval, tval) - elif op == 3: res = not fmpz_equal(sval, tval) - elif op == 0: res = fmpz_cmp(sval, tval) < 0 - elif op == 1: res = fmpz_cmp(sval, tval) <= 0 - elif op == 4: res = fmpz_cmp(sval, tval) > 0 - elif op == 5: res = fmpz_cmp(sval, tval) >= 0 + if op == 2: + res = fmpz_equal(sval, tval) + elif op == 3: + res = not fmpz_equal(sval, tval) + elif op == 0: + res = fmpz_cmp(sval, tval) < 0 + elif op == 1: + res = fmpz_cmp(sval, tval) <= 0 + elif op == 4: + res = fmpz_cmp(sval, tval) > 0 + elif op == 5: + res = fmpz_cmp(sval, tval) >= 0 if ttype == FMPZ_TMP: fmpz_clear(tval) if ttype == FMPZ_UNKNOWN: @@ -192,7 +198,8 @@ cdef class fmpz(flint_scalar): if ttype != FMPZ_UNKNOWN: u = fmpz.__new__(fmpz) fmpz_add((u).val, (s).val, tval) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __radd__(s, t): @@ -203,7 +210,8 @@ cdef class fmpz(flint_scalar): if ttype != FMPZ_UNKNOWN: u = fmpz.__new__(fmpz) fmpz_add((u).val, tval, (s).val) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __sub__(s, t): @@ -214,7 +222,8 @@ cdef class fmpz(flint_scalar): if ttype != FMPZ_UNKNOWN: u = fmpz.__new__(fmpz) fmpz_sub((u).val, (s).val, tval) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __rsub__(s, t): @@ -225,7 +234,8 @@ cdef class fmpz(flint_scalar): if ttype != FMPZ_UNKNOWN: u = fmpz.__new__(fmpz) fmpz_sub((u).val, tval, (s).val) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __mul__(s, t): @@ -236,7 +246,8 @@ cdef class fmpz(flint_scalar): if ttype != FMPZ_UNKNOWN: u = fmpz.__new__(fmpz) fmpz_mul((u).val, (s).val, tval) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __rmul__(s, t): @@ -247,7 +258,8 @@ cdef class fmpz(flint_scalar): if ttype != FMPZ_UNKNOWN: u = fmpz.__new__(fmpz) fmpz_mul((u).val, tval, (s).val) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __truediv__(s, t): @@ -270,7 +282,8 @@ cdef class fmpz(flint_scalar): exact = fmpz_is_zero(rval) fmpz_clear(rval) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) if exact: return q @@ -295,7 +308,8 @@ cdef class fmpz(flint_scalar): raise ZeroDivisionError("fmpz division by zero") u = fmpz.__new__(fmpz) fmpz_fdiv_q((u).val, (s).val, tval) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __rfloordiv__(s, t): @@ -310,7 +324,8 @@ cdef class fmpz(flint_scalar): raise ZeroDivisionError("fmpz division by zero") u = fmpz.__new__(fmpz) fmpz_fdiv_q((u).val, tval, (s).val) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __mod__(s, t): @@ -325,7 +340,8 @@ cdef class fmpz(flint_scalar): raise ZeroDivisionError("fmpz division by zero") u = fmpz.__new__(fmpz) fmpz_fdiv_r((u).val, (s).val, tval) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __rmod__(s, t): @@ -340,7 +356,8 @@ cdef class fmpz(flint_scalar): raise ZeroDivisionError("fmpz division by zero") u = fmpz.__new__(fmpz) fmpz_fdiv_r((u).val, tval, (s).val) - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __divmod__(s, t): @@ -357,7 +374,8 @@ cdef class fmpz(flint_scalar): u2 = fmpz.__new__(fmpz) fmpz_fdiv_qr((u1).val, (u2).val, (s).val, tval) u = u1, u2 - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __rdivmod__(s, t): @@ -374,7 +392,8 @@ cdef class fmpz(flint_scalar): u2 = fmpz.__new__(fmpz) fmpz_fdiv_qr((u1).val, (u2).val, tval, (s).val) u = u1, u2 - if ttype == FMPZ_TMP: fmpz_clear(tval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) return u def __pow__(s, t, m): @@ -427,9 +446,12 @@ cdef class fmpz(flint_scalar): return u finally: - if stype == FMPZ_TMP: fmpz_clear(sval) - if ttype == FMPZ_TMP: fmpz_clear(tval) - if mtype == FMPZ_TMP: fmpz_clear(mval) + if stype == FMPZ_TMP: + fmpz_clear(sval) + if ttype == FMPZ_TMP: + fmpz_clear(tval) + if mtype == FMPZ_TMP: + fmpz_clear(mval) def __rpow__(s, t, m): t = any_as_fmpz(t) diff --git a/src/flint/types/fmpz_mod_poly.pyx b/src/flint/types/fmpz_mod_poly.pyx index 699815b9..ec216a06 100644 --- a/src/flint/types/fmpz_mod_poly.pyx +++ b/src/flint/types/fmpz_mod_poly.pyx @@ -1819,7 +1819,7 @@ cdef class fmpz_mod_poly(flint_poly): return (constant, []) fmpz_mod_poly_factor_init(fac, self.ctx.mod.val) - if algorithm == None: + if algorithm is None: fmpz_mod_poly_factor(fac, self.val, self.ctx.mod.val) elif algorithm == "cantor_zassenhaus": fmpz_mod_poly_factor_cantor_zassenhaus(fac, self.val, self.ctx.mod.val) diff --git a/src/flint/types/fmpz_poly.pyx b/src/flint/types/fmpz_poly.pyx index a32d3a92..37eedcb7 100644 --- a/src/flint/types/fmpz_poly.pyx +++ b/src/flint/types/fmpz_poly.pyx @@ -461,7 +461,7 @@ cdef class fmpz_poly(flint_poly): fmpz_poly_factor_init(fac) fmpz_poly_factor_squarefree(fac, self.val) for 0 <= i < fac.num: - deg = fmpz_poly_degree(&fac.p[i]); + deg = fmpz_poly_degree(&fac.p[i]) exp = fac.exp[i] croots = _acb_vec_init(deg) arb_fmpz_poly_complex_roots(croots, &fac.p[i], flags, getprec())