Skip to content

Commit de73121

Browse files
committed
Fix fmpz_mod_mat equal and rref
1 parent 2f6c941 commit de73121

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/flint/flintlib/fmpz_mod_mat.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ cdef extern from *:
4444
#define compat_fmpz_mod_mat_inv(B, A, ctx) fmpz_mod_mat_inv(B, A, ctx)
4545
#define compat_fmpz_mod_mat_transpose(B, A, ctx) fmpz_mod_mat_transpose(B, A, ctx)
4646
#define compat_fmpz_mod_mat_solve(X, A, B, ctx) fmpz_mod_mat_solve(X, A, B, ctx)
47-
#define compat_fmpz_mod_mat_rref(perm, mat, ctx) fmpz_mod_mat_rref(perm, mat, ctx)
47+
#define compat_fmpz_mod_mat_rref(mat, ctx) fmpz_mod_mat_rref(mat, mat, ctx)
4848
#define compat_fmpz_mod_mat_charpoly(p, M, ctx) fmpz_mod_mat_charpoly(p, M, ctx)
4949
#define compat_fmpz_mod_mat_minpoly(p, M, ctx) fmpz_mod_mat_minpoly(p, M, ctx)
5050
@@ -69,7 +69,7 @@ cdef extern from *:
6969
#define compat_fmpz_mod_mat_inv(B, A, ctx) fmpz_mod_mat_inv(B, A)
7070
#define compat_fmpz_mod_mat_transpose(B, A, ctx) fmpz_mod_mat_transpose(B, A)
7171
#define compat_fmpz_mod_mat_solve(X, A, B, ctx) fmpz_mod_mat_solve(X, A, B)
72-
#define compat_fmpz_mod_mat_rref(perm, mat, ctx) fmpz_mod_mat_rref(perm, mat)
72+
#define compat_fmpz_mod_mat_rref(mat, ctx) fmpz_mod_mat_rref(NULL, perm, mat)
7373
#define compat_fmpz_mod_mat_charpoly(p, M, ctx) fmpz_mod_mat_charpoly(p, M, ctx)
7474
#define compat_fmpz_mod_mat_minpoly(p, M, ctx) fmpz_mod_mat_minpoly(p, M, ctx)
7575
@@ -97,7 +97,7 @@ cdef extern from "flint/fmpz_mod_mat.h":
9797
int compat_fmpz_mod_mat_inv(fmpz_mod_mat_t B, fmpz_mod_mat_t A, const fmpz_mod_ctx_t ctx)
9898
void compat_fmpz_mod_mat_transpose(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, const fmpz_mod_ctx_t ctx)
9999
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)
100-
slong compat_fmpz_mod_mat_rref(slong * perm, fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx)
100+
slong compat_fmpz_mod_mat_rref(fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx)
101101
void compat_fmpz_mod_mat_charpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx)
102102
void compat_fmpz_mod_mat_minpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx)
103103
#

src/flint/types/fmpz_mod_mat.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,10 @@ cdef class fmpz_mod_mat(flint_mat):
320320
if other is NotImplemented:
321321
return other
322322

323-
res = compat_fmpz_mod_mat_equal((<fmpz_mod_mat>self).val, (<fmpz_mod_mat>other).val, self.ctx.val)
323+
if (<fmpz_mod_mat>self).ctx != (<fmpz_mod_mat>other).ctx:
324+
res = 0
325+
else:
326+
res = compat_fmpz_mod_mat_equal((<fmpz_mod_mat>self).val, (<fmpz_mod_mat>other).val, self.ctx.val)
324327

325328
if op == 2:
326329
return res
@@ -652,5 +655,5 @@ cdef class fmpz_mod_mat(flint_mat):
652655
res = self
653656
else:
654657
res = self._copy()
655-
r = compat_fmpz_mod_mat_rref(NULL, res.val, res.ctx.val)
658+
r = compat_fmpz_mod_mat_rref(res.val, res.ctx.val)
656659
return (res, r)

0 commit comments

Comments
 (0)