Skip to content

Commit

Permalink
Rename FiniteField -> finite_field (#1543)
Browse files Browse the repository at this point in the history
* Rename FiniteField -> finite_field

Also add a backwards compatibility @alias

* Ensure compatibility with current Hecke

* Update src/Native.jl
  • Loading branch information
fingolfin authored Sep 27, 2023
1 parent 7c86256 commit 5b857fe
Show file tree
Hide file tree
Showing 24 changed files with 338 additions and 333 deletions.
2 changes: 1 addition & 1 deletion benchmarks/resultant.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function benchmark_resultant()
print("benchmark_resultant ... ")
R, x = FiniteField(7, 11, "x")
R, x = finite_field(7, 11, "x")
S, y = polynomial_ring(R, "y")
T = residue_ring(S, y^3 + 3x*y + 1)
U, z = polynomial_ring(T, "z")
Expand Down
2 changes: 1 addition & 1 deletion docs/src/constructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ they represent.
|---------------------------------------|-----------------------------------------------|
| $R = \mathbb{Z}$ | `R = ZZ` |
| $R = \mathbb{Q}$ | `R = QQ` |
| $R = \mathbb{F}_{p^n}$ | `R, a = FiniteField(p, n, "a")` |
| $R = \mathbb{F}_{p^n}$ | `R, a = finite_field(p, n, "a")` |
| $R = \mathbb{Z}/n\mathbb{Z}$ | `R = residue_ring(ZZ, n)` |
| $S = R[x]$ | `S, x = polynomial_ring(R, "x")` |
| $S = R[x, y]$ | `S, (x, y) = polynomial_ring(R, ["x", "y"])` |
Expand Down
8 changes: 4 additions & 4 deletions docs/src/ff_embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ embed(::fqPolyRepField, ::fqPolyRepField)
**Examples**

```jldoctest; filter = r"[gG]F"
julia> k2, x2 = FiniteField(19, 2, "x2")
julia> k2, x2 = finite_field(19, 2, "x2")
(Finite field of degree 2 over GF(19), x2)
julia> k4, x4 = FiniteField(19, 4, "x4")
julia> k4, x4 = finite_field(19, 4, "x4")
(Finite field of degree 4 over GF(19), x4)
julia> f = embed(k2, k4)
Expand All @@ -62,10 +62,10 @@ preimage_map(::FinFieldMorphism)
**Examples**

```jldoctest
julia> k7, x7 = FiniteField(13, 7, "x7")
julia> k7, x7 = finite_field(13, 7, "x7")
(Finite field of degree 7 over GF(13), x7)
julia> k21, x21 = FiniteField(13, 21, "x21")
julia> k21, x21 = finite_field(13, 21, "x21")
(Finite field of degree 21 over GF(13), x21)
julia> s = preimage_map(k7, k21)
Expand Down
16 changes: 8 additions & 8 deletions docs/src/finitefield.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Finite fields are constructed using the `FlintFiniteField` function. However,
for convenience we define

```
FiniteField = FlintFiniteField
finite_field = FlintFiniteField
```

so that finite fields can be constructed using `FiniteField` rather than
so that finite fields can be constructed using `finite_field` rather than
`FlintFiniteField`. Note that this is the name of the constructor, but not of
finite field type.

Expand Down Expand Up @@ -69,16 +69,16 @@ resulting parent objects to coerce various elements into those fields.
**Examples**

```jldoctest
julia> R, x = FiniteField(7, 3, "x")
julia> R, x = finite_field(7, 3, "x")
(Finite field of degree 3 over GF(7), x)
julia> S, y = FiniteField(ZZ(12431351431561), 2, "y")
julia> S, y = finite_field(ZZ(12431351431561), 2, "y")
(Finite field of degree 2 over GF(12431351431561), y)
julia> T, t = polynomial_ring(residue_ring(ZZ, 12431351431561), "t")
(Univariate polynomial ring in t over ZZ/(12431351431561), t)
julia> U, z = FiniteField(t^2 + 7, "z")
julia> U, z = finite_field(t^2 + 7, "z")
(Finite field of degree 2 over GF(12431351431561), z)
julia> a = R(5)
Expand Down Expand Up @@ -119,7 +119,7 @@ modulus(::FqPolyRepField)
**Examples**

```jldoctest
julia> R, x = FiniteField(ZZ(7), 5, "x")
julia> R, x = finite_field(ZZ(7), 5, "x")
(Finite field of degree 5 over GF(7), x)
julia> c = gen(R)
Expand Down Expand Up @@ -161,7 +161,7 @@ pth_root(::FqPolyRepFieldElem)
**Examples**

```jldoctest
julia> R, x = FiniteField(ZZ(7), 5, "x")
julia> R, x = finite_field(ZZ(7), 5, "x")
(Finite field of degree 5 over GF(7), x)
julia> a = x^4 + 3x^2 + 6x + 1
Expand Down Expand Up @@ -192,7 +192,7 @@ lift(::FpPolyRing, ::FqPolyRepFieldElem)
**Examples**

```jldoctest
julia> R, x = FiniteField(23, 2, "x")
julia> R, x = finite_field(23, 2, "x")
(Finite field of degree 2 over GF(23), x)
julia> S, y = polynomial_ring(GF(23), "y")
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Here is an example using generic recursive ring constructions.
```jldoctest
julia> using Nemo
julia> R, x = FiniteField(7, 11, "x")
julia> R, x = finite_field(7, 11, "x")
(Finite field of degree 11 over GF(7), x)
julia> S, y = polynomial_ring(R, "y")
Expand Down
2 changes: 2 additions & 0 deletions src/Aliases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,5 @@
@alias NmodRelSeriesRing zzModRelPowerSeriesRing

@alias MPolyElem MPolyRingElem

@alias FiniteField finite_field
23 changes: 13 additions & 10 deletions src/Native.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,54 @@ function GF(n::ZZRingElem; cached::Bool=true)
return FpField(n, cached)
end

function FiniteField(char::ZZRingElem, deg::Int, s::VarName = :o; cached = true)
function finite_field(char::ZZRingElem, deg::Int, s::VarName = :o; cached = true)
parent_obj = FqPolyRepField(char, deg, Symbol(s), cached)
return parent_obj, gen(parent_obj)
end

function FiniteField(pol::Union{ZZModPolyRingElem, FpPolyRingElem},
function finite_field(pol::Union{ZZModPolyRingElem, FpPolyRingElem},
s::VarName = :o; cached = true, check::Bool=true)
parent_obj = FqPolyRepField(pol, Symbol(s), cached, check=check)
return parent_obj, gen(parent_obj)
end

function FiniteField(F::FqPolyRepField, deg::Int, s::VarName = :o; cached = true)
function finite_field(F::FqPolyRepField, deg::Int, s::VarName = :o; cached = true)
return FqPolyRepField(characteristic(F), deg, Symbol(s), cached)
end

function FiniteField(char::Int, deg::Int, s::VarName = :o; cached = true)
function finite_field(char::Int, deg::Int, s::VarName = :o; cached = true)
parent_obj = fqPolyRepField(ZZRingElem(char), deg, Symbol(s), cached)
return parent_obj, gen(parent_obj)
end

function FiniteField(pol::Zmodn_poly, s::VarName = :o; cached = true, check::Bool=true)
function finite_field(pol::Zmodn_poly, s::VarName = :o; cached = true, check::Bool=true)
parent_obj = fqPolyRepField(pol, Symbol(s), cached, check=check)
return parent_obj, gen(parent_obj)
end

function FiniteField(F::fqPolyRepField, deg::Int, s::VarName = :o; cached = true)
function finite_field(F::fqPolyRepField, deg::Int, s::VarName = :o; cached = true)
return fqPolyRepField(characteristic(F), deg, Symbol(s), cached)
end

# Additional from Hecke
function FiniteField(p::Integer; cached::Bool = true)
function finite_field(p::Integer; cached::Bool = true)
@assert is_prime(p)
k = GF(p, cached=cached)
return k, k(1)
end

function FiniteField(p::ZZRingElem; cached::Bool = true)
function finite_field(p::ZZRingElem; cached::Bool = true)
@assert is_prime(p)
k = GF(p, cached=cached)
return k, k(1)
end

GF(p::Integer, k::Int, s::VarName = :o; cached::Bool = true) = FiniteField(p, k, s, cached = cached)[1]
GF(p::Integer, k::Int, s::VarName = :o; cached::Bool = true) = finite_field(p, k, s, cached = cached)[1]

GF(p::ZZRingElem, k::Int, s::VarName = :o; cached::Bool = true) = FiniteField(p, k, s, cached = cached)[1]
GF(p::ZZRingElem, k::Int, s::VarName = :o; cached::Bool = true) = finite_field(p, k, s, cached = cached)[1]

import ..Nemo: @alias
@alias FiniteField finite_field # for compatibility with Hecke

end # module

Expand Down
8 changes: 4 additions & 4 deletions src/Nemo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import AbstractAlgebra: nullspace, @show_name, @show_special, find_name,
get_cached!,
@show_special_elem, force_coerce, force_op, expressify

# We don't want the QQ, ZZ, FiniteField, number_field from AbstractAlgebra
# We don't want the QQ, ZZ, finite_field, number_field from AbstractAlgebra
# as they are for parents of Julia types or naive implementations
# We only import AbstractAlgebra, not export
# We do not want the AbstractAlgebra version of certain functions as the Base version
Expand Down Expand Up @@ -76,7 +76,7 @@ export PadicField, QadicField, NGFiniteField
export QQBar

# Things/constants which are also defined in AbstractAlgebra:
export ZZ, QQ, FiniteField, number_field
export ZZ, QQ, finite_field, number_field


# FIXME/TODO: for compatibility with AbstractAlgebra before 0.28.x; remove in the future
Expand Down Expand Up @@ -477,15 +477,15 @@ const _ecm_nCs = Vector{Int}[_ecm_nC]

###############################################################################
#
# Set domain for ZZ, QQ, PadicField, FiniteField to Flint
# Set domain for ZZ, QQ, PadicField, finite_field to Flint
#
###############################################################################

const ZZ = FlintZZ
const QQ = FlintQQ
const PadicField = FlintPadicField
const QadicField = FlintQadicField
const FiniteField = FlintFiniteField
const finite_field = FlintFiniteField

###############################################################################
#
Expand Down
2 changes: 1 addition & 1 deletion src/embedding/embedding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function intersections(k::T, K::T) where T <: FinField
# and we embed it in k and S
else
# kc of same type as k but degree c
kc = FiniteField(k, c, string("x", c))
kc = finite_field(k, c, string("x", c))
embed(kc, k)
for g in subK[l]
embed(kc, domain(g))
Expand Down
28 changes: 14 additions & 14 deletions test/Native-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
@test Native.GF(UInt(2), cached = false) isa Nemo.fpField
@test Native.GF(ZZ(2)) isa Nemo.FpField
@test Native.GF(ZZ(2), cached = false) isa Nemo.FpField
@test Native.FiniteField(ZZ(2), 2, :oo) isa Tuple{FqPolyRepField, FqPolyRepFieldElem}
@test Native.FiniteField(ZZ(2), 2, :oo, cached = false) isa Tuple{FqPolyRepField, FqPolyRepFieldElem}
@test Native.FiniteField(2, 2, :oo) isa Tuple{fqPolyRepField, fqPolyRepFieldElem}
@test Native.FiniteField(2, 2, :oo, cached = false) isa Tuple{fqPolyRepField, fqPolyRepFieldElem}
@test Native.finite_field(ZZ(2), 2, :oo) isa Tuple{FqPolyRepField, FqPolyRepFieldElem}
@test Native.finite_field(ZZ(2), 2, :oo, cached = false) isa Tuple{FqPolyRepField, FqPolyRepFieldElem}
@test Native.finite_field(2, 2, :oo) isa Tuple{fqPolyRepField, fqPolyRepFieldElem}
@test Native.finite_field(2, 2, :oo, cached = false) isa Tuple{fqPolyRepField, fqPolyRepFieldElem}

F, x = Native.GF(2)["x"]
@test Native.FiniteField(x - 1, :oo, cached = false) isa Tuple{fqPolyRepField, fqPolyRepFieldElem}
@test Native.finite_field(x - 1, :oo, cached = false) isa Tuple{fqPolyRepField, fqPolyRepFieldElem}
F, x = Native.GF(ZZ(2))["x"]
@test Native.FiniteField(x - 1, :oo, cached = false) isa Tuple{FqPolyRepField, FqPolyRepFieldElem}
F, = Native.FiniteField(2, 2)
@test Native.FiniteField(F, 2) isa fqPolyRepField
F, = Native.FiniteField(ZZ(2), 2)
@test Native.FiniteField(F, 2) isa FqPolyRepField
@test Native.finite_field(x - 1, :oo, cached = false) isa Tuple{FqPolyRepField, FqPolyRepFieldElem}
F, = Native.finite_field(2, 2)
@test Native.finite_field(F, 2) isa fqPolyRepField
F, = Native.finite_field(ZZ(2), 2)
@test Native.finite_field(F, 2) isa FqPolyRepField

@test Native.FiniteField(2) isa Tuple{Nemo.fpField, Nemo.fpFieldElem}
@test Native.FiniteField(2, cached = false) isa Tuple{Nemo.fpField, Nemo.fpFieldElem}
@test Native.FiniteField(ZZ(2)) isa Tuple{Nemo.FpField, Nemo.FpFieldElem}
@test Native.FiniteField(ZZ(2), cached = false) isa Tuple{Nemo.FpField, Nemo.FpFieldElem}
@test Native.finite_field(2) isa Tuple{Nemo.fpField, Nemo.fpFieldElem}
@test Native.finite_field(2, cached = false) isa Tuple{Nemo.fpField, Nemo.fpFieldElem}
@test Native.finite_field(ZZ(2)) isa Tuple{Nemo.FpField, Nemo.FpFieldElem}
@test Native.finite_field(ZZ(2), cached = false) isa Tuple{Nemo.FpField, Nemo.FpFieldElem}

@test Native.GF(2, 2) isa fqPolyRepField
@test Native.GF(ZZ(2), 2) isa FqPolyRepField
Expand Down
4 changes: 2 additions & 2 deletions test/Rings-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const ring_to_mat = Dict(FlintZZ => ZZMatrix,
FlintQQ => QQMatrix,
residue_ring(ZZ, 9) => zzModMatrix,
GF(5) => fpMatrix,
FiniteField(3, 2, "b")[1] => fqPolyRepMatrix,
FiniteField(ZZRingElem(3), 2, "b")[1] => FqPolyRepMatrix,
finite_field(3, 2, "b")[1] => fqPolyRepMatrix,
finite_field(ZZRingElem(3), 2, "b")[1] => FqPolyRepMatrix,
ArbField() => arb_mat,
AcbField() => acb_mat,
RealField() => RealMat,
Expand Down
Loading

0 comments on commit 5b857fe

Please sign in to comment.