tkluck / GaloisFields.jl

Finite fields for Julia
Other
47 stars 6 forks source link

tr() doesn't work over F2^p #13

Closed uchkw closed 3 years ago

uchkw commented 3 years ago
Julia Version 1.5.3
pkg> st
Status `~/xxx/Project.toml`
  [8d0d7f98] GaloisFields v1.0.1
julia> using GaloisFields
[ Info: Precompiling GaloisFields [8d0d7f98-d412-5cd4-8397-071c807280aa]
julia> F2 = @GaloisField 2
𝔽₂
julia> F16 = @GaloisField! 2^4 α
𝔽₁₆
julia> tr(F2, α)
fish: 'julia' terminated by signal SIGSEGV (Address boundary error)

In the REPL on Visual Studio Code, I got StackOverflowError with the same syntax described above.

tkluck commented 3 years ago

Thanks for reporting! I'll submit a fix shortly. In the meantime, could you confirm for me that defining the following is a workaround?

julia> function GaloisFields._downgrade(F::Type{GaloisFields.PrimeField{I, 2}}, i::GaloisFields.BinaryField) where I
    i.n == (i.n & 1) || throw(GaloisFields.InclusionError("$i is not contained in $F"))
    return F(i.n & 1)
end
uchkw commented 3 years ago

Yes, it worked! Thanks for fixing it!!

uchkw commented 3 years ago

I confirmed that the updated version worked well. Thanks!

tkluck commented 3 years ago

FYI I just released v1.1 which includes this fix and some dependency updates.

uchkw commented 3 years ago

Thanks for letting me know! I'll check it and report if I found anything wrong.