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

Fix snf_with_transform issue over non-domain #1899

Merged
merged 1 commit into from
Nov 15, 2024
Merged

Conversation

fingolfin
Copy link
Member

@fingolfin fingolfin commented Nov 11, 2024

See oscar-system/Oscar.jl#4293

Can't really test this here as the linked example requires code from Nemo and Hecke.

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.16%. Comparing base (3ed3ea9) to head (cd154a2).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1899   +/-   ##
=======================================
  Coverage   88.16%   88.16%           
=======================================
  Files         120      120           
  Lines       30291    30291           
=======================================
  Hits        26706    26706           
  Misses       3585     3585           

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

@fingolfin fingolfin changed the title mh/snf bugfix SNF bugfix Nov 12, 2024
@fingolfin fingolfin changed the title SNF bugfix Fix snf_with_transform issue over non-domain Nov 12, 2024
@fingolfin fingolfin changed the title Fix snf_with_transform issue over non-domain Fix snf_with_transform issue over non-domain Nov 12, 2024
@@ -5285,7 +5285,7 @@ function snf_kb!(S::MatrixElem{T}, U::MatrixElem{T}, K::MatrixElem{T}, with_traf
K[r, j] = reduce!(t1 + t2)
end
end
S[j, j] = divexact(S[i, i]*S[j, j], d)
S[j, j] = S[i, i]*divexact(S[j, j], d)
Copy link
Member Author

Choose a reason for hiding this comment

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

Just to explain, this tries to compute "the" lcm of two values a and b where d is the gcd, by doing (a*b)/d, which I change to a*(b/d).

This makes a difference if there are zero divisors, e.g. in $\mathbb{Z}/8\mathbb{Z}$ if $a=b=4$ then $d=4$, then $(a\cdot b)/d = 0$, while $a\cdot(b/d) = 4$.

@fieker
Copy link
Contributor

fieker commented Nov 12, 2024 via email

@joschmitt
Copy link
Collaborator

I think I wrote this function (like > 5 years ago as a HiWi) and I never had zero-divisors in mind. The signature is not more restrictive because we don't have an "euclidean domain supertype" or something like this, if I remember correctly.

I never thought about what is mathematically required to have an SNF, but I am fairly certain that this function assumes euclidean domain or at least PID. It certainly is suspicious that it calls HNF which does not always do the right thing over non-domains (and that's why we have a Howell form these days).

@thofma
Copy link
Member

thofma commented Nov 12, 2024

I am tempted to just require is_domain_type(T).

@fieker
Copy link
Contributor

fieker commented Nov 12, 2024 via email

@fieker
Copy link
Contributor

fieker commented Nov 12, 2024 via email

@thofma
Copy link
Member

thofma commented Nov 12, 2024

When I mean requiring is_domain_type(T), I was mainly referring to this specific implementation. We definitely should have a Smith normal form implementation for "arbitrary" PIRs.

@fingolfin
Copy link
Member Author

In the meantime, anything speak against merging this? I mean if somebody wants to restrict this code or something else, fine by me, but in the meantime I see no downside?

@thofma
Copy link
Member

thofma commented Nov 14, 2024

I guess it's fine, although I don't understand why it works for anything else except for this specific example.

@fingolfin fingolfin merged commit 9d38ede into master Nov 15, 2024
28 of 29 checks passed
@fingolfin fingolfin deleted the mh/snf-bugfix branch November 15, 2024 08:50
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.

4 participants