Skip to content

Commit e8fa5b2

Browse files
Merge pull request #233 from Jake-Moss/main
Fix build error in fmpz_mod_mpoly when using flint HEAD
2 parents 71cab5c + a4a242a commit e8fa5b2

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from flint.flintlib.types.flint cimport slong
2+
from flint.flintlib.types.fmpz_mod cimport fmpz_mod_mpoly_ctx_t, fmpz_mod_mpoly_t
3+
4+
5+
cdef extern from *:
6+
"""
7+
#if __FLINT_RELEASE < 30200 /* Flint < 3.2.0 */
8+
9+
#define compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(...) (void)0
10+
11+
#else
12+
13+
#define compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(...) fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(__VA_ARGS__)
14+
15+
#endif
16+
"""
17+
void compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const slong * c, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC)

src/flint/flintlib/types/flint.pxd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ cdef extern from *:
5252
#define flint_rand_clear flint_randclear
5353
5454
#endif
55-
56-
/* FIXME: add version guard when https://github.com/flintlib/flint/pull/2068 */
57-
/* is resolved */
58-
#define fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(...) (void)0
5955
"""
6056

6157
cdef extern from "flint/flint.h":

src/flint/types/fmpz_mod_mpoly.pyx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ from flint.flint_base.flint_base cimport (
55
ordering_c_to_py,
66
)
77

8+
from flint.flint_base.flint_base import FLINT_RELEASE
9+
810
from flint.utils.typecheck cimport typecheck
911
from flint.utils.flint_exceptions import DomainError, IncompatibleContextError
1012

@@ -19,7 +21,6 @@ from flint.flintlib.functions.fmpz_mod_mpoly cimport (
1921
fmpz_mod_mpoly_add_fmpz,
2022
fmpz_mod_mpoly_clear,
2123
fmpz_mod_mpoly_compose_fmpz_mod_mpoly,
22-
# fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen,
2324
fmpz_mod_mpoly_ctx_get_modulus,
2425
fmpz_mod_mpoly_ctx_init,
2526
fmpz_mod_mpoly_deflate,
@@ -69,9 +70,11 @@ from flint.flintlib.functions.fmpz_mod_mpoly_factor cimport (
6970
fmpz_mod_mpoly_factor_squarefree,
7071
fmpz_mod_mpoly_factor_t,
7172
)
73+
from flint.flintlib.functions.compat cimport compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen
7274

7375
from flint.types.fmpz_mpoly cimport fmpz_mpoly_ctx, fmpz_mpoly
7476

77+
7578
from cpython.object cimport Py_EQ, Py_NE
7679
cimport libc.stdlib
7780

@@ -1093,26 +1096,27 @@ cdef class fmpz_mod_mpoly(flint_mpoly):
10931096
return list(stride), list(shift)
10941097

10951098
cdef _compose_gens_(self, ctx, slong *mapping):
1096-
# FIXME: Remove this when https://github.com/flintlib/flint/pull/2068 is
1097-
# resolved
1098-
1099-
# cdef fmpz_mod_mpoly res = create_fmpz_mod_mpoly(ctx)
1100-
# fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(
1101-
# res.val,
1102-
# self.val,
1103-
# mapping,
1104-
# self.ctx.val,
1105-
# (<fmpz_mod_mpoly_ctx>ctx).val
1106-
# )
1099+
# FIXME: Remove this when FLINT < 3.2 is dropped
1100+
cdef fmpz_mod_mpoly res
1101+
if FLINT_RELEASE >= 30200:
1102+
res = create_fmpz_mod_mpoly(ctx)
1103+
compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(
1104+
res.val,
1105+
self.val,
1106+
mapping,
1107+
self.ctx.val,
1108+
(<fmpz_mod_mpoly_ctx>ctx).val
1109+
)
1110+
return res
11071111

11081112
cdef:
11091113
fmpz_mpoly_ctx mpoly_ctx = fmpz_mpoly_ctx.from_context(self.context())
11101114
fmpz_mpoly_ctx res_ctx = fmpz_mpoly_ctx.from_context(ctx)
11111115

11121116
fmpz_mpoly poly = mpoly_ctx.from_dict(self.to_dict())
1113-
fmpz_mpoly res = poly._compose_gens_(res_ctx, mapping)
1117+
fmpz_mpoly res1 = poly._compose_gens_(res_ctx, mapping)
11141118

1115-
return ctx.from_dict(res.to_dict())
1119+
return ctx.from_dict(res1.to_dict())
11161120

11171121

11181122
cdef class fmpz_mod_mpoly_vec:

0 commit comments

Comments
 (0)