Skip to content

Commit

Permalink
feat: adjust to upcoming Nemo finite field changes
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Jan 4, 2024
1 parent 3792dc1 commit 7a9ea0c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
7 changes: 7 additions & 0 deletions src/number/n_transExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@ function (F::Singular.N_FField)(x::fpFieldElem)
return n_transExt(F, x.data)
end

function (F::Singular.N_FField)(x::FqFieldElem)
if characteristic(F) != characteristic(parent(x))
throw(ArgumentError("wrong characteristic"))
end
return n_transExt(F, lift(Nemo.ZZ, x))
end

function (F::Singular.N_FField)(x::Union{n_Q, Nemo.QQFieldElem, Rational})
return F(numerator(x)) // F(denominator(x))
end
Expand Down
18 changes: 9 additions & 9 deletions test/libsingular/nemo-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ end
end

@testset "Nemo.fqPolyRepFieldElem" begin
F, _ = Nemo.finite_field(Nemo.next_prime(fld(typemax(Int),2)), 2, "a")
F, _ = Nemo.Native.finite_field(Nemo.next_prime(fld(typemax(Int),2)), 2, "a")
R, _ = polynomial_ring(F, ["x", "y"])
@test R isa Singular.PolyRing{Singular.n_FieldElem{Nemo.fqPolyRepFieldElem}}

F, a = Nemo.finite_field(7, 2, "a")
F, a = Nemo.Native.finite_field(7, 2, "a")

R, (x, y) = polynomial_ring(F, ["x", "y"])

Expand Down Expand Up @@ -162,11 +162,11 @@ end
end

@testset "Nemo.FqPolyRepFieldElem" begin
F, _ = Nemo.finite_field(Nemo.next_prime(Nemo.ZZ(10)^50), 2, "a")
F, _ = Nemo.Native.finite_field(Nemo.next_prime(Nemo.ZZ(10)^50), 2, "a")
R, _ = polynomial_ring(F, ["x", "y"])
@test R isa Singular.PolyRing{Singular.n_FieldElem{Nemo.FqPolyRepFieldElem}}

F, a = Nemo.finite_field(Nemo.ZZ(7), 2, "a")
F, a = Nemo.Native.finite_field(Nemo.ZZ(7), 2, "a")

R, (x, y) = polynomial_ring(F, ["x", "y"])

Expand Down Expand Up @@ -276,7 +276,7 @@ end

@testset "Nemo.gfp_fmpz_mod.polynomial_ring" begin

U = Nemo.GF(Nemo.ZZRingElem(11))
U = Nemo.Native.GF(Nemo.ZZRingElem(11))

R, (x, y) = polynomial_ring(U, ["x", "y"])

Expand Down Expand Up @@ -318,7 +318,7 @@ end

@testset "Nemo.gfp_fmpz_mod.WeylAlgebra" begin

U = Nemo.GF(Nemo.ZZRingElem(11))
U = Nemo.Native.GF(Nemo.ZZRingElem(11))

R, (x, y, dx, dy) = @inferred WeylAlgebra(U, ["x", "y"])

Expand Down Expand Up @@ -375,20 +375,20 @@ end
@test F(one(R)*i) == one(F)*i
end

S = Nemo.GF(5)
S = Nemo.Native.GF(5)
@test_throws ErrorException S(one(F))
@test_throws ErrorException F(one(S))
end

@testset "Nemo.fpFieldElem" begin
R = Nemo.GF(7)
R = Nemo.Native.GF(7)
F = Fp(7)
for i in -10:10
@test R(one(F)*i) == one(R)*i
@test F(one(R)*i) == one(F)*i
end

S = Nemo.GF(5)
S = Nemo.Native.GF(5)
@test_throws ErrorException S(one(F))
@test_throws ErrorException F(one(S))
end
Expand Down
4 changes: 2 additions & 2 deletions test/number/n_transExt-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ end
@test F(1//2) == big(1//2)
@test F(1//2) == QQ(1//2)
@test F(1//2) == Nemo.QQ(1//2)
@test F(Nemo.GF(5)(3)) == 1//2
@test_throws Exception F(Nemo.GF(7)(3))
@test F(Nemo.Native.GF(5)(3)) == 1//2
@test_throws Exception F(Nemo.Native.GF(7)(3))
end

@testset "n_transExt.unary_ops" begin
Expand Down

0 comments on commit 7a9ea0c

Please sign in to comment.