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 methods for computing orth. discriminants #2748

Merged
merged 3 commits into from
Sep 8, 2023
Merged

some methods for computing orth. discriminants #2748

merged 3 commits into from
Sep 8, 2023

Conversation

ThomasBreuer
Copy link
Member

  • add od_from_order, od_from_eigenvalues, od_for_specht_module
  • add utilities character_of_entry, order_omega_mod_N, reduce_mod_squares

- add `od_from_order`, `od_from_eigenvalues`, `od_for_specht_module
- add utilities `character_of_entry`, `order_omega_mod_N`, `reduce_mod_squares`
@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Merging #2748 (2f6f7c0) into master (f562757) will increase coverage by 0.21%.
Report is 7 commits behind head on master.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2748      +/-   ##
==========================================
+ Coverage   73.20%   73.41%   +0.21%     
==========================================
  Files         446      451       +5     
  Lines       63675    63886     +211     
==========================================
+ Hits        46615    46905     +290     
+ Misses      17060    16981      -79     
Files Changed Coverage
...ogonalDiscriminants/src/OrthogonalDiscriminants.jl ø
experimental/OrthogonalDiscriminants/src/data.jl 100.00%
...imental/OrthogonalDiscriminants/src/theoretical.jl 100.00%
experimental/OrthogonalDiscriminants/src/utils.jl 100.00%
...mental/OrthogonalDiscriminants/test/theoretical.jl 100.00%
experimental/OrthogonalDiscriminants/test/utils.jl 100.00%

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

Fine by me, but some questions and suggestions -- but all optional, feel free to ignore some or all.

```
"""
function reduce_mod_squares(F::AnticNumberField, val::nf_elem)
@req parent(val) === F "val must have parent F"
Copy link
Member

Choose a reason for hiding this comment

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

Why is F even an argument when the only place using it is this check?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.
I still have to get used to the fact that the elements carry the relevant context.

is_zero(val) && return val
d = denominator(val)
if ! isone(d)
val = val * d^2
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
val = val * d^2
val *= d^2

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you want to say that this syntax is preferable?
If yes then should this be stated in the "Deveoper Style Guide"? (There are quite some places in the code where one could switch to this syntax.)

Copy link
Member

Choose a reason for hiding this comment

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

From my POV either is fine, this is a matter of taste. Pick whichever you prefer :-)

val = val * d^2
end
if is_integer(val)
val = ZZ(val)
Copy link
Member

Choose a reason for hiding this comment

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

It may not matter, but just FYI, this breaks type stability (and I think possibly even of the whole function?) for val if it is not already a ZZRingElem.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not understand this comment. In the end, an element of F is returned.

Copy link
Member

Choose a reason for hiding this comment

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

The code inside this function is unstable: Julia cannot determine a concrete type for val anymore: val was initially an nf_elem, but now is a ZZRingElem -- so the best it can do is to say that val is a Union{nf_elem, ZZRingElem} in this function. You can see this in @code_warntype.

This kind of issue can percolate: Julia may or may not be able to deduce which sign method is called, and thus may or may not be able to predict the type of sgn, and then good, and finally for the return value.

In this case, it seems to be OK as the union splitting code in the Julia compiler can deal with it. But in general I would recommend to avoid re-using a variable for a value of a different type (instead call it val2 or whatever)

Comment on lines 89 to 90
good = filter(x -> is_odd(x[2]), collect(factor(val)))
return F(prod([x[1] for x in good], init = sgn))
Copy link
Member

Choose a reason for hiding this comment

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

The following might avoid the second allocation. Dunno if it makes things better or not, though...

Suggested change
good = filter(x -> is_odd(x[2]), collect(factor(val)))
return F(prod([x[1] for x in good], init = sgn))
good = [x[1] for x in collect(factor(val)) if is_odd(x[2])]
return F(prod(good, init = sgn))

s = s * p^(e-1)
end
end
return F(c // s)
Copy link
Member

Choose a reason for hiding this comment

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

I am confused, isn't c a vector at this point?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we want the vector where each entry is divided by s.
Perhaps it is better to divide val by s.

if iseven(e)
s = s * p^e
elseif e > 1
s = s * p^(e-1)
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
s = s * p^(e-1)
s *= p^(e-1)

q2 = ZZ(q)^2
q2i = ZZ(1)
for i in 1:(m-1)
q2i = q2 * q2i
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
q2i = q2 * q2i
q2i *= q2

experimental/OrthogonalDiscriminants/src/utils.jl Outdated Show resolved Hide resolved
res = 1
for pair in gramdet
if is_odd(pair[2])
res = res * pair[1]
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
res = res * pair[1]
res *= pair[1]


# Now we know that `chi` belongs to Sym(n) or extends to Sym(n)
gramdet = gram_determinant_specht_module(partition(para))
res = 1
Copy link
Member

Choose a reason for hiding this comment

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

Is this type stable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Better ZZ(1).
(However, for the return value of the function, this does not matter because we call string(res).)

@thofma
Copy link
Collaborator

thofma commented Sep 1, 2023

How unique does your reduction modulo squares need to be? There is an (unexported) Hecke.reduce_mod_powers(::nf_elem, ::Int), which also tries to reduce something modulo powers.

@ThomasBreuer
Copy link
Member Author

@thofma Thanks for the hint.

How unique does your reduction modulo squares need to be?

If the value is in fact in the prime field then I need that the reduction is represented by a squarefree rational integer.
Otherwise I cannot expect uniqueness, and what Hecke.reduce_mod_powers promises seems to be useful.

Comment on lines 20 to 24
exp = 0
while mod(N, q) == 0
exp = exp + 1
N = div(N, q)
end
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think it might be possible to replace this by

Suggested change
exp = 0
while mod(N, q) == 0
exp = exp + 1
N = div(N, q)
end
exp, N = remove(N, q)

Comment on lines 29 to 31
while mod(N, p) == 0
N = div(N, p)
end
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
while mod(N, p) == 0
N = div(N, p)
end
_, N = remove(N, p)

@fingolfin fingolfin enabled auto-merge (squash) September 8, 2023 21:06
@fingolfin fingolfin merged commit 79874fd into oscar-system:master Sep 8, 2023
8 of 12 checks passed
fieker pushed a commit that referenced this pull request Sep 29, 2023
- add `od_from_order`, `od_from_eigenvalues`, `od_for_specht_module`
- add utilities `character_of_entry`, `order_omega_mod_N`, `reduce_mod_squares`
@ThomasBreuer ThomasBreuer deleted the TB_OD_first_methods branch October 10, 2023 13:13
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.

None yet

3 participants