Skip to content

Add new function is_probably_zero_det (for ZZMatrix, QQMatrix)#2152

Open
JohnAAbbott wants to merge 10 commits into
Nemocas:masterfrom
JohnAAbbott:JAA/NEW-is_zero_det_probabilistic
Open

Add new function is_probably_zero_det (for ZZMatrix, QQMatrix)#2152
JohnAAbbott wants to merge 10 commits into
Nemocas:masterfrom
JohnAAbbott:JAA/NEW-is_zero_det_probabilistic

Conversation

@JohnAAbbott
Copy link
Copy Markdown
Collaborator

@JohnAAbbott JohnAAbbott commented Oct 13, 2025

New heuristic function is_zero_det_probabilistic; incl. doc & tests.
RENAMED later to is_probably_zero_det (see below)

@JohnAAbbott
Copy link
Copy Markdown
Collaborator Author

This is currently restricted to ZZMatrix. An extension to QQMatrix should be fairly easy. Extending to (univariate) polynomials over ZZ or QQ would take some more work, but not excessively much.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.34%. Comparing base (53a90bc) to head (37f4469).
⚠️ Report is 47 commits behind head on master.

Files with missing lines Patch % Lines
src/flint/fmpq_mat.jl 79.16% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2152      +/-   ##
==========================================
+ Coverage   88.30%   88.34%   +0.03%     
==========================================
  Files         100      100              
  Lines       37202    37290      +88     
==========================================
+ Hits        32853    32944      +91     
+ Misses       4349     4346       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/flint/fmpq_mat.jl Outdated
@thofma
Copy link
Copy Markdown
Member

thofma commented Oct 13, 2025

There is a lot of code duplication. How much slower is it to just do is_zero_det_probablisitic(numerator(x)) in the rational case?

@JohnAAbbott
Copy link
Copy Markdown
Collaborator Author

There is a lot of code duplication. How much slower is it to just do is_zero_det_probablistic(numerator(x)) in the rational case?

Yes, there is duplication, but I don't know how to avoid that without risking a significant speed penalty in some cases, e.g. the current test uses a matrix 250x250 whose entries are 1/k for k ranging from 1 to 250^2; this takes less than 0.02s on my computer, but computing the result by taking the numerator takes nearly 1.8s -- roughly 100 times slower.
OK, I could convert the ZZMatrix into a QQMatrix and then use the QQMatrix function... but that seems wasteful.

Comment thread src/flint/fmpq_mat.jl Outdated
@thofma
Copy link
Copy Markdown
Member

thofma commented Oct 13, 2025

Thanks for checking. I agree that the overhead of converting to ZZMatrix is too large.

Co-authored-by: Tommy Hofmann <thofma@gmail.com>
@JohnAAbbott
Copy link
Copy Markdown
Collaborator Author

Converting to a non-draft PR. The extensions mentioned in comment 2 (near the start of this discussion) can be dealt with separately if there is call for them.

@JohnAAbbott JohnAAbbott marked this pull request as ready for review October 29, 2025 14:52
Comment thread src/flint/fmpq_mat.jl Outdated
# we switch to larger 61-bit primes (which are faster amortized).

@doc raw"""
is_zero_det_probabilistic(M::QQMatrix; modulus_bitsize::Int = 100)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests whether "is_zero(det(M)) is probably true (if it returns true) and otherwise definitely false (if it returns false)

We have is_probable_prime so maybe this should be is_probably_zero_det (but sounds weird?).

Having it at end makes it easier to find, though.


Should this function be added to the documentation? It is currently being exported in this PR, which to me suggests it should be in the manual...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having it at end makes it easier to find, though.

I agree

@fingolfin fingolfin requested a review from fieker January 14, 2026 10:50
@fingolfin fingolfin removed the triage label Jan 14, 2026
@JohnAAbbott JohnAAbbott added release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes and removed triage labels Mar 4, 2026
@JohnAAbbott JohnAAbbott changed the title Added new fn is_zero_det_probabilistic Added new function is_probably_zero_det (for ZZMatrix, QQMatrix) Mar 4, 2026
@JohnAAbbott
Copy link
Copy Markdown
Collaborator Author

Is the release notes tag correct for this PR? I think so, but am not sure.

@lgoettgens lgoettgens changed the title Added new function is_probably_zero_det (for ZZMatrix, QQMatrix) Add new function is_probably_zero_det (for ZZMatrix, QQMatrix) Mar 4, 2026
@lgoettgens
Copy link
Copy Markdown
Member

Is the release notes tag correct for this PR? I think so, but am not sure.

yes, looks good

@JohnAAbbott
Copy link
Copy Markdown
Collaborator Author

I believe this is ready to merge (assuming we want the new function, and are happy with the name).

@fingolfin
Copy link
Copy Markdown
Member

Note: we already have is_probable_prime and is_probable_supersingular. It is somewhat unfortunate that the names are different, but I am not sure that matters much.

The name is_probable_prime is justified by the existence of the term "probable prime".

So from my point of view, we could merge this as-is. If we later are concerned about this kind of consistency, we could add aliases?

Here at triage, nobody voiced a strong opinion...

@JohnAAbbott JohnAAbbott enabled auto-merge (squash) May 28, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants