@@ -3,6 +3,9 @@ from flint.flintlib.types.fmpz_mod cimport fmpz_mod_ctx_t, fmpz_mod_mat_t, fmpz_
33
44cdef extern from * :
55 """
6+ #include <flint/fmpz_mod.h>
7+ #include <flint/fmpz_mod_poly.h>
8+
69 /*
710 * fmpz_mod_mat function signatures were changed in FLINT 3.1.0
811 */
@@ -28,6 +31,7 @@ cdef extern from *:
2831 #define compat_fmpz_mod_mat_transpose(B, A, ctx) fmpz_mod_mat_transpose(B, A, ctx)
2932 #define compat_fmpz_mod_mat_solve(X, A, B, ctx) fmpz_mod_mat_solve(X, A, B, ctx)
3033 #define compat_fmpz_mod_mat_rref(mat, ctx) fmpz_mod_mat_rref(mat, mat, ctx)
34+ #define compat_fmpz_mod_mat_det(res, mat, ctx) fmpz_mod_mat_det(res, mat, ctx)
3135 #define compat_fmpz_mod_mat_charpoly(p, M, ctx) fmpz_mod_mat_charpoly(p, M, ctx)
3236 #define compat_fmpz_mod_mat_minpoly(p, M, ctx) fmpz_mod_mat_minpoly(p, M, ctx)
3337
@@ -53,9 +57,26 @@ cdef extern from *:
5357 #define compat_fmpz_mod_mat_transpose(B, A, ctx) fmpz_mod_mat_transpose(B, A)
5458 #define compat_fmpz_mod_mat_solve(X, A, B, ctx) fmpz_mod_mat_solve(X, A, B)
5559 #define compat_fmpz_mod_mat_rref(mat, ctx) fmpz_mod_mat_rref(NULL, mat)
60+ #define compat_fmpz_mod_mat_det(res, mat, ctx) compat_fmpz_mod_mat_det_fallback(res, mat, ctx)
5661 #define compat_fmpz_mod_mat_charpoly(p, M, ctx) fmpz_mod_mat_charpoly(p, M, ctx)
5762 #define compat_fmpz_mod_mat_minpoly(p, M, ctx) fmpz_mod_mat_minpoly(p, M, ctx)
5863
64+ /* fmpz_mod_mat_det was added in FLINT 3.1.0 */
65+ static inline void
66+ compat_fmpz_mod_mat_det_fallback(fmpz_t res, const fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx)
67+ {
68+ fmpz_mod_poly_t p;
69+
70+ fmpz_mod_poly_init(p, ctx);
71+ fmpz_mod_mat_charpoly(p, mat, ctx);
72+ fmpz_mod_poly_get_coeff_fmpz(res, p, 0, ctx);
73+
74+ if (fmpz_mod_mat_nrows(mat) % 2)
75+ fmpz_mod_neg(res, res, ctx);
76+
77+ fmpz_mod_poly_clear(p, ctx);
78+ }
79+
5980 #endif
6081 """
6182
@@ -81,6 +102,7 @@ cdef extern from "flint/fmpz_mod_mat.h":
81102 void compat_fmpz_mod_mat_transpose(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, const fmpz_mod_ctx_t ctx)
82103 int compat_fmpz_mod_mat_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, const fmpz_mod_ctx_t ctx)
83104 slong compat_fmpz_mod_mat_rref(fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx)
105+ void compat_fmpz_mod_mat_det(fmpz_t res, const fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx)
84106 void compat_fmpz_mod_mat_charpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx)
85107 void compat_fmpz_mod_mat_minpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx)
86108 #
0 commit comments