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

Chore: Adapt to new AA and Nemo #756

Merged
merged 5 commits into from
Jan 25, 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
6 changes: 3 additions & 3 deletions 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.3"
version = "0.22.0"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand All @@ -19,12 +19,12 @@ lib4ti2_jll = "1493ae25-0f90-5c0e-a06c-8c5077d6d66f"
libsingular_julia_jll = "ae4fbd8f-ecdb-54f8-bbce-35570499b30e"

[compat]
AbstractAlgebra = "0.34, 0.35"
AbstractAlgebra = "0.36"
BinaryWrappers = "~0.1.1"
CxxWrap = "0.14"
Libdl = "1.6"
LinearAlgebra = "1.6"
Nemo = "0.38, 0.39"
Nemo = "0.40"
Pidfile = "1.3"
Pkg = "1.6"
Random = "1.6"
Expand Down
3 changes: 1 addition & 2 deletions docs/src/modn.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ Coerce a Singular or Flint integer value into the ring.
**Examples**

```jldoctest
julia> R = residue_ring(ZZ, 26)
Residue Ring of Integer Ring modulo 26
julia> R, = residue_ring(ZZ, 26);

julia> a = R(5)
5
Expand Down
10 changes: 7 additions & 3 deletions src/number/n_Zn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,16 @@ promote_rule(C::Type{n_Zn}, ::Type{n_Z}) = n_Zn

(R::Nemo.ZZModRing)(n::n_Zn) = R(BigInt(n))

lift(n::n_Zn) = ZZ(BigInt(n))

###############################################################################
#
# SingularResidueRing constructor
#
###############################################################################

residue_ring(R::Integers, a::Int; cached=true) = N_ZnRing(BigInt(a), cached)

residue_ring(R::Integers, a::BigInt; cached=true) = N_ZnRing(a, cached)
function residue_ring(R::Integers, a::Integer; cached=true)
S = N_ZnRing(BigInt(a), cached)
f = Generic.EuclideanRingResidueMap(R, S)
return S, f
end
6 changes: 3 additions & 3 deletions test/libsingular/nemo-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ end
end

@testset "Nemo.zzModRingElem" begin
R = residue_ring(Nemo.ZZ, 15)
R = residue_ring(Nemo.ZZ, 15)[1]
S, (x, y) = polynomial_ring(R, ["x", "y"])
p = x*2
@test string(p) == "2*x"
Expand All @@ -368,7 +368,7 @@ end
@test length(p) == 0
@test is_zero(p)

R = residue_ring(Nemo.ZZ, 7)
R = residue_ring(Nemo.ZZ, 7)[1]
F = Fp(7)
for i in -10:10
@test R(one(F)*i) == one(R)*i
Expand All @@ -394,7 +394,7 @@ end
end

@testset "Nemo.ZZModRingElem" begin
U = Nemo.residue_ring(Nemo.ZZ, Nemo.ZZRingElem(11))
U = Nemo.residue_ring(Nemo.ZZ, Nemo.ZZRingElem(11))[1]
R, (x, y) = polynomial_ring(U, ["x", "y"])

wrappedUtype = Singular.n_RingElem{Singular.RingElemWrapper{Nemo.ZZModRing, Nemo.ZZModRingElem}}
Expand Down
2 changes: 1 addition & 1 deletion test/number-test.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
testrings = [
(n_Z, Integers, Union{}, ZZ),
(n_Q, Rationals, ZZ, QQ),
(n_Zn, N_ZnRing, ZZ, residue_ring(ZZ, 7)),
(n_Zn, N_ZnRing, ZZ, residue_ring(ZZ, 7)[1]),
(n_Zp, N_ZpField, Union{}, Fp(7)),
(n_GF, N_GField, Union{}, FiniteField(7, 2, "x")[1]),
(n_transExt, N_FField, QQ, FunctionField(QQ, ["a", "b", "c"])[1]),
Expand Down
45 changes: 25 additions & 20 deletions test/number/n_Zn-test.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
@testset "n_Zn.constructors" begin
F = residue_ring(ZZ, 8)
F1 = residue_ring(ZZ, 8)
F2 = residue_ring(ZZ, 8, cached = false)
F, f = residue_ring(ZZ, 8)
F1, = residue_ring(ZZ, 8)
F2, = residue_ring(ZZ, 8, cached = false)

@test f(ZZ(1)) == F(1)
@test f(preimage(f, f(ZZ(1)))) == F(1)

@test domain(f) === ZZ
@test codomain(f) === F
@test F isa Singular.Ring
@test F1 isa Singular.Ring
@test F2 isa Singular.Ring
@test F == F1
@test F != F2
@test F1 != F2

F = residue_ring(ZZ, BigInt(10)^50)
F1 = residue_ring(ZZ, BigInt(10)^50)
F2 = residue_ring(ZZ, BigInt(10)^50, cached = false)
F, = residue_ring(ZZ, BigInt(10)^50)
F1, = residue_ring(ZZ, BigInt(10)^50)
F2, = residue_ring(ZZ, BigInt(10)^50, cached = false)

@test F isa Singular.Ring
@test F1 isa Singular.Ring
Expand All @@ -26,15 +31,15 @@
end

@testset "n_Zn.printing" begin
R = residue_ring(ZZ, 5)
R, = residue_ring(ZZ, 5)

@test string(R(3)) == "3"

@test sprint(show, "text/plain", (R(3))) == "3"
end

@testset "n_Zn.manipulation" begin
R = residue_ring(ZZ, 6)
R, = residue_ring(ZZ, 6)

@test isone(one(R))
@test iszero(zero(R))
Expand All @@ -45,28 +50,28 @@ end

@test deepcopy(R(2)) == R(2)

NR = Nemo.residue_ring(Nemo.ZZ, 6)
NR = Nemo.residue_ring(Nemo.ZZ, 6)[1]
@test R(2) == R(NR(2))
@test NR(2) == NR(R(2))

NR = Nemo.residue_ring(Nemo.ZZ, Nemo.ZZ(6))
NR = Nemo.residue_ring(Nemo.ZZ, Nemo.ZZ(6))[1]
@test R(2) == R(NR(2))
@test NR(2) == NR(R(2))
end

@testset "n_Zn.unary_ops" begin
R = residue_ring(ZZ, 5)
R, = residue_ring(ZZ, 5)

@test -R(3) == R(2)
@test -R() == R()

R = residue_ring(ZZ, BigInt(10)^40)
R, = residue_ring(ZZ, BigInt(10)^40)
@test iszero(R(10)^40)

end

@testset "n_Zn.binary_ops" begin
R = residue_ring(ZZ, 5)
R, = residue_ring(ZZ, 5)

a = R(2)
b = R(3)
Expand All @@ -77,14 +82,14 @@ end
end

@testset "n_Zn.comparison" begin
R = residue_ring(ZZ, 5)
R, = residue_ring(ZZ, 5)

@test R(2) == R(2)
@test isequal(R(2), R(2))
end

@testset "n_Zn.ad_hoc_comparison" begin
R = residue_ring(ZZ, 5)
R, = residue_ring(ZZ, 5)

@test R(2) == 2
@test 2 == R(2)
Expand All @@ -96,14 +101,14 @@ end
end

@testset "n_Zn.powering" begin
R = residue_ring(ZZ, 5)
R, = residue_ring(ZZ, 5)

@test R(2)^10 == R(4)
@test_throws DomainError R(2)^-rand(1:99)
end

@testset "n_Zn.exact_division" begin
R = residue_ring(ZZ, 5)
R, = residue_ring(ZZ, 5)

@test_throws ErrorException inv(zero(R))
@test_throws ErrorException divexact(one(R), zero(R))
Expand All @@ -113,14 +118,14 @@ end
end

@testset "n_Zn.gcd_lcm" begin
R = residue_ring(ZZ, 5)
R, = residue_ring(ZZ, 5)

@test gcd(R(2), R(3)) == R(1)
@test gcd(R(0), R(0)) == R(0)
end

@testset "n_Zn.extended_gcd" begin
R = residue_ring(ZZ, 6)
R, = residue_ring(ZZ, 6)

g, s, t = gcdx(R(2), R(4))

Expand All @@ -132,7 +137,7 @@ end
end

@testset "n_Zn.Polynomials" begin
R = residue_ring(ZZ, 5)
R, = residue_ring(ZZ, 5)
S, x = Nemo.polynomial_ring(R, "x")

f = 1 + 2x + 3x^2
Expand Down
4 changes: 2 additions & 2 deletions test/poly/poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end
@test length(string(3x^2 + 2x + 1)) > 3
@test length(sprint(show, "text/plain", 3x^2 + 2x + 1)) > 3

R, (x, ) = polynomial_ring(residue_ring(ZZ, 5), ["x", ])
R, (x, ) = polynomial_ring(residue_ring(ZZ, 5)[1], ["x", ])

@test length(string(3x^2 + 2x + 1)) > 3
@test length(sprint(show, "text/plain", 3x^2 + 2x + 1)) > 3
Expand Down Expand Up @@ -191,7 +191,7 @@ end

@test pol == r

R, (x, ) = polynomial_ring(residue_ring(ZZ, 6), ["x", ])
R, (x, ) = polynomial_ring(residue_ring(ZZ, 6)[1], ["x", ])

@test characteristic(R) == 6

Expand Down
Loading