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

Add fmpz_mod_mat #106

Merged
merged 3 commits into from
Nov 29, 2023
Merged

Conversation

oscarbenjamin
Copy link
Collaborator

Since fmpz_mod and fmpz_mod_poly were recently added (gh-87 gh-83) this PR adds the corresponding matrix type fmpz_mod_mat.

The tests added are mostly generic tests applied to the 4 exact matrix types fmpz_mat, fmpq_mat, nmod_mat and fmpz_mod_mat. Various methods are added to some of the other types so that they have more consistent interfaces. Also some exception types were changed and some cases where Flint would abort are now handled with Python exceptions (e.g. charpoly on a non-square matrix).

Also nmod_mat now subclasses flint_mat along with the other matrix types and the matrix printing was made more consistent in how ctx.pretty is handled.

@oscarbenjamin
Copy link
Collaborator Author

Does anyone want to review this @deinst @GiacomoPope or should I just merge?

@GiacomoPope
Copy link
Contributor

I had a quick look and it looks good. Nice work with the tests and aligning the other matrix types with this new addition.

@oscarbenjamin
Copy link
Collaborator Author

Thanks.

Writing the generic test code would be a lot easier if we had a more uniform interface for the different types wrt contexts e.g.:

Rs = [fmpz_ctx(), fmpq_ctx(), nmod_ctx(7), fmpz_mod_ctx(7), ...]
for R in Rs:
    a = R(2)
    p = R.poly([1, 2])
    M = R.matrix([[1, 2], [3, 4]])
    assert M.charpoly() == R.poly([1, 2, 3])
    ...

Working on this has made it clear that a uniform interface is worthwhile so I think I will add that soon.

@oscarbenjamin
Copy link
Collaborator Author

Okay, let's get this in.

@oscarbenjamin oscarbenjamin merged commit e5da576 into flintlib:master Nov 29, 2023
22 checks passed
@oscarbenjamin oscarbenjamin deleted the pr_fmpz_mod_mat branch November 29, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants