-
Notifications
You must be signed in to change notification settings - Fork 113
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
Improvements toric varieties #929
Improvements toric varieties #929
Conversation
@@ -109,7 +109,7 @@ nef_cone(v::NormalToricVariety) | |||
dim(v::AbstractNormalToricVariety) | |||
dim_of_torusfactor(v::AbstractNormalToricVariety) | |||
euler_characteristic(v::AbstractNormalToricVariety) | |||
betti_number(v::AbstractNormalToricVariety, i::Int) | |||
betti_numbers(v::AbstractNormalToricVariety, i::Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That renaming was not what I had in mind at all (though you are free to do it if you prefer). What I meant was that the vector with Betti numbers could be accessed via a helper with that name; since it is internal, perhaps prefix it by an underscore, so _betti_numbers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Let me remove the commit with the changes on betti_number then.
I am uncertain if I understand your suggestion (both regarding the helper and get_attribute!
, in the message below). Could you please elaborate more?
betti_numbers = fill(fmpz(-1),2*dim(v)+1) | ||
else | ||
betti_numbers = get_attribute(v, :betti_number)::Vector{fmpz} | ||
betti_numbers = get_attribute(v, :betti_numbers)::Vector{fmpz} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, the above few lines could be rewritten using get_attribute!
, too. Instead of adding a _betti_nimbers helper
182f959
to
6cef4fe
Compare
@fingolfin I have just updated this PR, so that there are no changes to
as you suggested above. Could you please reiterate in more detail what changes you propose for this method? (If your time permits, maybe you could even push a proposed change?) Thank you! |
I've pushed a commit with changes to the Betti number code, please check it and feel free to edit/revert/whatever |
By the way, you can observe the effects of these various changes. With
So it basically could not make any guess as to what the return type might be. You can get more information with
With this PR, before my commit:
With my commit:
BTW I've now added another commit which deals with a few more issues:
|
bc4f050
to
b679b03
Compare
I squashed my two commits and fixed an off-by-one-bug 😂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @fingolfin . This looks great! I am very happy with these changes.
if i > 2*dim(v) || i < 0 | ||
return 0 | ||
d = dim(v)::Int | ||
if i > 2*d || i < 0 || isodd(i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that the method now immediately returns 0 when i
is odd. As you said - reduces the amount of memory used for storage and circumvents a lot of unnecessary computations. Great!
betti_numbers = get_attribute(v, :betti_number)::Vector{fmpz} | ||
end | ||
|
||
betti_numbers = get_attribute!(() -> fill(fmpz(-1),d+1), v, :betti_number)::Vector{fmpz} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. This is the part that I was confused by before. Thank you!
@fingolfin I am happy with this PR and do not plan to make further changes. If you are happy, please consider merging this. Thank you. |
Co-authored-by: Max Horn <max@quendi.de>
- always return an fmpz, even for `i` negative or larger than 2 * dim(v) - don't store the odd Betti numbers which are always 0 - use this to reduce the storage for Betti numbers by half - use `get_attribute!` instead of `has_attribute` + `get_attribute` - remove redundant call to `set_attribute!` - don't call `dim(v)` repeatedly and add a type assertion - initialize `f_vector` via a conversion, to ensure its type is inferred correctly
b679b03
to
eb3b079
Compare
fa72ccb
to
08a655c
Compare
I have to correct myself. Since I cached Betti numbers for "standard spaces", I had to update those number to reflect that we do no longer store the trivial numbers for odd |
@fingolfin As discussed in #839, a few minor improvements:
coeffs
andtoricvariety
are now (ordinary) struct fields for toric divisorsbetti_number
tobetti_numbers
.I am not sure how to rewrite the method
betti_numbers
to use the (standard?) syntax for cached properties. This is a prototype that I expect to repeat for line/vector bundle cohomologies very soon. So it would seem worth to think more about this.i
and thereby ask for i-th Betti number withi<0
ori>2 * dimension(variety)
. In this case, one could either raise an error ("this Betti number is not defined") or return0
. Currently, the latter is implemented, but on second thought, I would think it is more reasonable to opt for the error.Irrespective, this test should probably be conducted before checking if the attribute
betti_numbers
is known and has a properly initialized value at positioni+1
.betti_numbers
has a meaningful/initialized value at positioni+1
. Ifyes
, return it and otherwise compute it.betti_numbers
with values-1
. Since this number is never a Betti number (as Betti numbers are dimensions of a vector spaces), I can then proceed as follows:In summary, I am unsure how to adjust
such that it returns only the
i+1
st element of the vectorbetti_numbers
if thisi+1
st element has been initialized (i.e. is not-1
in the current implementation).Feedback/suggestions very much appreciated.