CurrentModule = AbstractAlgebra
DocTestSetup = quote
using AbstractAlgebra
end
AbstractAlgebra.jl provides a module, implemented in src/julia/GF.jl
for
finite fields. The module is a naive implementation that supports only fields of degree
Finite fields have type GFField{T}
where T
is either Int
or BigInt
.
Elements of such a finite field have type GFElem{T}
.
In order to construct finite fields in AbstractAlgebra.jl, one must first construct the field itself. This is accomplished with the following constructors.
GF(p::T) where T <: Integer
Here are some examples of creating a finite field and making use of the resulting parent object to coerce various elements into the field.
Examples
julia> F = GF(13)
Finite field F_13
julia> g = F(3)
3
julia> h = F(g)
3
julia> GF(4)
ERROR: DomainError with 4:
Characteristic is not prime in GF(p)
Stacktrace:
[...]
The finite field module in AbstractAlgebra.jl implements the full Field interface.
We give some examples of such functionality.
Examples
julia> F = GF(13)
Finite field F_13
julia> f = F(7)
7
julia> h = zero(F)
0
julia> k = one(F)
1
julia> isone(k)
true
julia> iszero(h)
true
julia> T = parent(h)
Finite field F_13
julia> h == deepcopy(h)
true
julia> h = h + 2
2
julia> m = inv(k)
1
data(::GFElem)
lift(::GFElem)
gen{T <: Integer}(F::GFField{T})
order(F::GFField)
degree(F::GFField)
Examples
julia> F = GF(13)
Finite field F_13
julia> d = degree(F)
1
julia> n = order(F)
13
julia> g = gen(F)
1