Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust to upcoming Nemo finite field changes #743

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Singular"
uuid = "bcd08a7b-43d2-5ff7-b6d4-c458787f915c"
version = "0.21.1"
version = "0.21.2"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand Down
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
Loading