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

Random lines in LineEnumCtx #1271

Merged
merged 4 commits into from
Nov 3, 2023
Merged

Conversation

StevellM
Copy link
Collaborator

@StevellM StevellM commented Nov 2, 2023

To prepare random Kneser's neighbour method, allow to have access to random lines from the LineEnumCtx. It might not be the most optimized way but at least it works.

@thofma
Copy link
Owner

thofma commented Nov 2, 2023

Why BigInt instead of ZZ? BigInt will be slower. You can use IntegerUnion instead of Integer if you want to support both.

@StevellM
Copy link
Collaborator Author

StevellM commented Nov 2, 2023

I have not thought about this actually, I did not know it could make a difference. You mean for the operations in the getindex function ? For the size of the LineEnumCtx, I tried putting something not integer and some tests did not pass.

@@ -16,7 +16,7 @@ function LineEnumCtx(K::T, n) where {T}
depth = n + 1
dim = n
q = order(K)
length = divexact(q^n - 1, q - 1)
length = divexact(BigInt(q)^n - 1, q - 1)
Copy link
Owner

Choose a reason for hiding this comment

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

Here

@@ -29,7 +29,7 @@ function LineEnumCtx(K::T, n::Int) where {T <: Union{fpField, FpField}}
depth = n + 1
dim = n
q = order(K)
length = divexact(q^n - 1, q - 1)
length = divexact(BigInt(q)^n - 1, q - 1)
Copy link
Owner

Choose a reason for hiding this comment

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

Here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This I cannot remove, otherwise all functions like collect, or Vector{Int}(undef, length(P)) will not work if we set the length to be a ZZRingElem

end
p = size(K)
j = i-2
n = findfirst(n -> sum(BigInt(p)^i for i in 1:n) > j, 1:256)
Copy link
Owner

Choose a reason for hiding this comment

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

Here

j = i-2
n = findfirst(n -> sum(BigInt(p)^i for i in 1:n) > j, 1:256)
v[end-n] = one(K)
j = n == 1 ? j : j-sum(BigInt(p)^k for k in 1:(n-1))
Copy link
Owner

Choose a reason for hiding this comment

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

Here

Comment on lines 2 to 9
P = Hecke.enumerate_lines(GF(5), 20)
io = IOBuffer()
show(io, MIME"text/plain"(), P)
@test length(String(take!(io))) == 98
show(IOContext(io, :supercompact => true), P)
@test length(String(take!(io))) == 25
show(io, P)
@test length(String(take!(io))) == 33
Copy link
Owner

Choose a reason for hiding this comment

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

I don't understand this test :)

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 wanted to increase test coverage, but maybe I can remove the test on the length of the strings and just leave the test calling the show functions (kind of tautological tests but it is "easy" test coverage for the corresponding lines)

@@ -444,7 +444,7 @@ mutable struct LineEnumCtx{T, S}
dim::Int
depth::Int
v::Vector{S}
length::BigInt
length::IntegerUnion
Copy link
Contributor

Choose a reason for hiding this comment

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

Doing this means you just made anything use length type unstable, unless you add a type assertion or a type conversion to every place that accesses length. Perhaps that's OK, perhaps not -- you could avoid it by adding the type of length as another type parameter to LineEnumCtx.

src/QuadForm/LineOrbits.jl Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 3, 2023

Codecov Report

Merging #1271 (094ffc2) into master (5e74ae6) will increase coverage by 0.16%.
Report is 1 commits behind head on master.
The diff coverage is 86.66%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1271      +/-   ##
==========================================
+ Coverage   74.41%   74.57%   +0.16%     
==========================================
  Files         346      346              
  Lines      111321   111333      +12     
==========================================
+ Hits        82836    83032     +196     
+ Misses      28485    28301     -184     
Files Coverage Δ
src/QuadForm/Types.jl 81.15% <ø> (ø)
src/QuadForm/LineOrbits.jl 44.97% <86.66%> (+2.44%) ⬆️

... and 39 files with indirect coverage changes

@thofma thofma merged commit f818b32 into thofma:master Nov 3, 2023
11 of 15 checks passed
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.

3 participants