Search code examples
mathjuliagalois-fieldfinite-field

Converting FqFieldElem to an integer


I'm a beginner in Julia and I am working with the Nemo library to do stuff over finite fields.

I would like to compute the characters of a given finite field and to do so I have to compute quantities like

exp(2*pi*im*absolute_tr(a)/p)

However the type of absolute_tr(a) is FqFieldElem since it's an element of the prime subfield (here Z/pZ) of my finite field so this raises an error.

I would like to transform this integer modulo p to an int but I can't find any methods to do so (despite it being printed on the console as an integer...).


Solution

  • It isn't unambiguously defined how to map a field element into an Int. But, the following works by first going through a Nemo way to embed the field into Z:

    julia> R = GF(7)
    Prime field of characteristic 7
    
    julia> a = R(3)
    3
    
    julia> Int(lift(ZZ, a))
    3
    
    julia> typeof(Int(lift(ZZ, a)))
    Int64