Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero Matrix has Inverse over Finite Field #30161

Closed
prismika mannequin opened this issue Jul 16, 2020 · 10 comments
Closed

Zero Matrix has Inverse over Finite Field #30161

prismika mannequin opened this issue Jul 16, 2020 · 10 comments

Comments

@prismika
Copy link
Mannequin

prismika mannequin commented Jul 16, 2020

The bug is outlined in this post: https://ask.sagemath.org/question/52487/zero-matrix-has-an-inverse-over-finite-field/

In short, the following lines of code should throw an error, but they do not.

M = Matrix([0], ring=GF(4))
M.inverse()

Instead they return the matrix [1].

CC: @malb @slel

Component: linear algebra

Keywords: m4rie

Author: Martin Albrecht

Branch/Commit: ccaf79d

Reviewer: Samuel Lelièvre

Issue created by migration from https://trac.sagemath.org/ticket/30161

@prismika prismika mannequin added this to the sage-9.2 milestone Jul 16, 2020
@slel
Copy link
Member

slel commented Jul 17, 2020

comment:1

The source code for the __invert__ method, revealed by

sage: M.__invert__??

seems to involve mzed_invert_newton_john from m4rie.

@slel
Copy link
Member

slel commented Jul 17, 2020

Changed keywords from none to m4rie

@malb
Copy link
Member

malb commented Jul 17, 2020

comment:2

Yep, that's a bug in m4rie:

mzed_t *mzed_invert_newton_john(mzed_t *B, const mzed_t *A) {
  assert(A->nrows == A->ncols);
  mzed_t *I = mzed_init(A->finite_field, A->nrows, A->ncols);
  mzed_set_ui(I, 1);
  mzed_t *T = mzed_concat(NULL, A, I);
  mzed_free(I);

  rci_t r = mzed_echelonize_newton_john(T, 1);
  if (r != A->nrows) 
    m4ri_die("mzed_invert_newton_john: input matrix does not have full rank.");
  B = mzed_submatrix(B, T, 0, A->ncols, A->nrows, T->ncols);
  mzed_free(T);
  return B;
}

We first add an identity matrix and then check if the whole thing has full rank, which is nonsense.

@malb
Copy link
Member

malb commented Jul 17, 2020

Branch: u/malb/ticket-30161

@malb
Copy link
Member

malb commented Jul 17, 2020

Commit: ccaf79d

@malb
Copy link
Member

malb commented Jul 17, 2020

New commits:

ccaf79dcheck rank before inverting

@slel
Copy link
Member

slel commented Jul 17, 2020

Reviewer: Samuel Lelièvre

@slel
Copy link
Member

slel commented Jul 17, 2020

comment:5

Thanks!

@slel
Copy link
Member

slel commented Jul 17, 2020

Author: Martin Albrecht

@vbraun
Copy link
Member

vbraun commented Jul 28, 2020

Changed branch from u/malb/ticket-30161 to ccaf79d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants