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

Some more fixes #4142

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

HechtiDerLachs
Copy link
Collaborator

Today's harvest from working on the elliptic surfaces.

@thofma
Copy link
Collaborator

thofma commented Sep 24, 2024

I think a lot of changes from #4133 and #4126 are undone here. I guess this was not on purpose.

src/Rings/mpoly-ideals.jl Outdated Show resolved Hide resolved
src/Rings/mpoly-ideals.jl Outdated Show resolved Hide resolved
src/Rings/mpoly-ideals.jl Outdated Show resolved Hide resolved
@HechtiDerLachs
Copy link
Collaborator Author

Yes, I'm already working on it. It's a bit annoying, because I had to work on the compute-server today, but there I can't put my login-credentials for GH. Thus, I manually copied the files via scp and this is what you get...

@@ -1149,7 +1170,14 @@ function minimal_primes(
end
J = K
end
result = unique!(filter!(!is_one, vcat([minimal_primes(j; algorithm, factor_generators=false) for j in J]...)))
# unique! seems to fail here. We have to do it manually.
pre_result = filter!(!is_one, vcat([minimal_primes(j; algorithm, factor_generators=false) for j in J]...))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pre_result = filter!(!is_one, vcat([minimal_primes(j; algorithm, factor_generators=false) for j in J]...))
pre_result = filter!(!is_one, reduce(vcat, [minimal_primes(j; algorithm, factor_generators=false) for j in J]))

save some allocations

Comment on lines 2282 to 2287
# Since most ideals implement `==`, they have to implement the hash function.
# See issue #4143 for problems entailed. Interestingly, this does not yet fix
# the failure of unique! on lists of ideals.
function hash(I::Ideal, c::UInt)
return hash(typeof(I), hash(base_ring(I), c))
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I advocate for this solution now. It is a matter of fact that ideals can not be hashed in general and even for polynomial rings this is probably expensive if not impossible (we need to choose an ordering which might be a dead end for a specific ideal). Yet, the == function is vital to how we use ideals and we need to be able to use them in vectors/lists/dictionaries.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it safe to hash the type? After all two mathematically equal objects may have different types.
(Thinking e.g. of IdealSheaf, RadicalIdealSheaf, PrimeIdealSheaf etc.)

Copy link
Member

Choose a reason for hiding this comment

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

Is it safe to hash the type? After all two mathematically equal objects may have different types. (Thinking e.g. of IdealSheaf, RadicalIdealSheaf, PrimeIdealSheaf etc.)

It is only safe if you don't implement == between this type and other types. In your example, you shouldn't include the type in hashes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, good to know. I was only following the suggestion by @benlorenz . But you're probably right.

@fieker
Copy link
Contributor

fieker commented Sep 27, 2024 via email

@HechtiDerLachs
Copy link
Collaborator Author

Is there any situation where you want a dict or a set where the keys/ elements are different types and then catch that 2 objects of different types are "the same"?

Probably yes. For instance, it would make sense to introduce a lazy type for radical ideals, say RadicalIdeal. This would have a special dispatch for ideal membership so that the computation of the radical can be avoided. Yet, comparison with the standard types of ideals for the respective ring could give that two ideals are equal, even though their type differs.

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.

6 participants