Skip to content

Commit

Permalink
Merge branch 'master' into trailing_coeff_mpoly
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Apr 16, 2021
2 parents 31b1ff3 + 34e0bd3 commit 39dda70
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 36 deletions.
8 changes: 4 additions & 4 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.5.0"
version = "0.5.1"

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

[compat]
AbstractAlgebra = "0.15.1"
AbstractAlgebra = "0.16.0"
CxxWrap = "0.11"
Nemo = "0.22"
Nemo = "0.22.1"
RandomExtensions = "0.4.2"
Singular_jll = "~402.000.102"
julia = "1.3"
libsingular_julia_jll = "~0.9"
libsingular_julia_jll = "~0.9.200"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
16 changes: 13 additions & 3 deletions src/Singular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import AbstractAlgebra: AbstractAlgebra, diagonal_matrix, factor,

import Nemo: add!, addeq!, base_ring, canonical_unit,
change_base_ring, characteristic, check_parent, codomain,
coeff, coefficients, compose, contains, content, crt,
coeff, coefficients, compose, constant_coefficient,
contains, content, crt,
deflate, deflation, degree, degrees, derivative, divexact,
divides, domain, elem_type, evaluate, exponent_vectors,
factor_squarefree,
Expand All @@ -47,7 +48,7 @@ import Nemo: add!, addeq!, base_ring, canonical_unit,
MPolyBuildCtx, mul!, nvars, ordering, parent_type,
parent, primpart, promote_rule, push_term!,
reconstruct, remove, set_field!, sort_terms!,
symbols, terms, total_degree, trailing_coefficient, valuation,
symbols, tail, terms, total_degree, trailing_coefficient, valuation,
var_index, vars, zero!, ResidueRing

export base_ring, elem_type, parent_type, parent
Expand Down Expand Up @@ -92,6 +93,14 @@ function __init__()
# Initialise Singular
ENV["SINGULAR_EXECUTABLE"] = binSingular
libSingular.siInit(binSingular)

# don't tell the user about each library that singular loads
libSingular.set_option("V_LOAD_LIB", false)
# don't tell the user when a library redefines a singular variable
libSingular.set_option("V_REDEFINE", false)
# silence printlevel-based printing
libSingular.set_printlevel(-100)

# set up Singular parents (we cannot do this before Singular is initialised)

global ZZ = Integers()
Expand Down Expand Up @@ -133,7 +142,8 @@ function __init__()
casting_functions = create_casting_functions()

show_banner = isinteractive() &&
!any(x->x.name in ["Oscar"], keys(Base.package_locks))
!any(x->x.name in ["Oscar"], keys(Base.package_locks)) &&
get(ENV, "SINGULAR_PRINT_BANNER", "true") != "false"

singular_version_nr=Singular.libSingular.version()
ver = digits(singular_version_nr, base = 10)
Expand Down
10 changes: 6 additions & 4 deletions src/libsingular/antic/nf_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ end
function nf_elemMPZ(b::BigInt, ptr::Ptr{Ptr{Cvoid}}, cf::Ptr{Cvoid})
ptr_load = unsafe_load(ptr)
z = BigInt(0)
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
GC.@preserve b z begin
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
end
nothing
end

Expand Down
2 changes: 2 additions & 0 deletions src/libsingular/coeffs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ function number_pop!(D::Base.Dict{UInt, live_cache}, ptr::Ptr{Cvoid})
end
end

# the caller does not necessarily hold a reference to j, but julia must keep
# j alive because it is going into nemoNumberID
function number(j::T) where {T <: Nemo.RingElem}
ptr = pointer_from_objref(j)
iptr = reinterpret(UInt, ptr) >> 24
Expand Down
10 changes: 6 additions & 4 deletions src/libsingular/flint/fmpq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,12 @@ function fmpqMPZ(b::BigInt, ptr::Ptr{Ptr{Cvoid}}, cf::Ptr{Cvoid})
ptr_load = unsafe_load(ptr)
n = julia(unsafe_load(ptr))::Nemo.fmpz
z = convert(BigInt, Nemo.numerator(n))
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
GC.@preserve b z begin
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
end
nothing
end

Expand Down
10 changes: 6 additions & 4 deletions src/libsingular/flint/fmpz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ function fmpzMPZ(b::BigInt, ptr::Ptr{Ptr{Cvoid}}, cf::Ptr{Cvoid})
ptr_load = unsafe_load(ptr)
n = julia(unsafe_load(ptr))::Nemo.fmpz
z = convert(BigInt, n)
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
GC.@preserve b z begin
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
end
nothing
end

Expand Down
10 changes: 6 additions & 4 deletions src/libsingular/flint/fq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,12 @@ end
function fqMPZ(b::BigInt, ptr::Ptr{Ptr{Cvoid}}, cf::Ptr{Cvoid})
ptr_load = unsafe_load(ptr)
z = BigInt(0)
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
GC.@preserve b z begin
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
end
nothing
end

Expand Down
10 changes: 6 additions & 4 deletions src/libsingular/flint/fq_nmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ end
function fq_nmodMPZ(b::BigInt, ptr::Ptr{Ptr{Cvoid}}, cf::Ptr{Cvoid})
ptr_load = unsafe_load(ptr)
z = BigInt(0)
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
GC.@preserve b z begin
bptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(b))
zptr = reinterpret(Ptr{Cvoid}, pointer_from_objref(z))
number_pop!(nemoNumberID, ptr_load)
mpz_init_set_internal(bptr, zptr)
end
nothing
end

Expand Down
6 changes: 4 additions & 2 deletions src/libsingular/nemo/Fields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ function nemoFieldInt(ptr::Ptr{Ptr{Cvoid}}, cf::Ptr{Cvoid})
end

function nemoFieldMPZ(b::BigInt, ptr::Ptr{Ptr{Cvoid}}, cf::Ptr{Cvoid})
bptr = pointer_from_objref(b)
mpz_init_set_si_internal(reinterpret(Ptr{Cvoid}, bptr),0)
GC.@preserve b begin
bptr = pointer_from_objref(b)
mpz_init_set_si_internal(reinterpret(Ptr{Cvoid}, bptr),0)
end
nothing
end

Expand Down
6 changes: 4 additions & 2 deletions src/libsingular/nemo/Rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ function nemoRingInt(ptr::Ptr{Ptr{Cvoid}}, cf::Ptr{Cvoid})
end

function nemoRingMPZ(b::BigInt, ptr::Ptr{Ptr{Cvoid}}, cf::Ptr{Cvoid})
bptr = pointer_from_objref(b)
mpz_init_set_si_internal(reinterpret(Ptr{Cvoid}, bptr), 0)
GC.@preserve b begin
bptr = pointer_from_objref(b)
mpz_init_set_si_internal(reinterpret(Ptr{Cvoid}, bptr), 0)
end
nothing
end

Expand Down
6 changes: 4 additions & 2 deletions src/number/NumberTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,10 @@ mutable struct CoefficientRing{T <: Nemo.RingElem} <: Ring
return CoeffRingID[R]::CoefficientRing{T}
else
c = libSingular.register(R)
ptr = pointer_from_objref(R)
z = new(libSingular.nInitChar(c, ptr), R)
GC.@preserve R begin
ptr = pointer_from_objref(R)
z = new(libSingular.nInitChar(c, ptr), R)
end
if cached
CoeffRingID[R] = z
end
Expand Down
5 changes: 3 additions & 2 deletions src/poly/poly.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export spoly, PolyRing, change_base_ring, coeff, coefficients,
content, deflation, deflate, degree, degrees, degree_bound,
constant_coefficient, content, deflation, deflate,
degree, degrees, degree_bound,
derivative, div, divides, evaluate, exponent,
exponent_vectors, factor, factor_squarefree, finish, gen,
has_global_ordering, has_mixed_ordering, has_local_ordering,
Expand All @@ -8,7 +9,7 @@ export spoly, PolyRing, change_base_ring, coeff, coefficients,
jet, leading_coefficient, leading_term, leading_monomial, lead_exponent,
monomials, MPolyBuildCtx,
nvars, order, ordering, @PolynomialRing, primpart,
push_term!, remove, sort_terms!, symbols, terms, total_degree,
push_term!, remove, sort_terms!, symbols, tail, terms, total_degree,
trailing_coefficient,
valuation, var_index, vars

Expand Down
2 changes: 1 addition & 1 deletion test/caller-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ end

@testset "caller.LibSolve" begin
R, (x,) = PolynomialRing(Singular.QQ, ["s"])
l = Singular.LibSolve.solve(Ideal(R, [x^5+1]))
l = Singular.LibSolve.solve(Ideal(R, [x^5+1]), "nodisplay")
S = l[1]
@test isa(S, Singular.PolyRing{Singular.n_unknownsingularcoefficient})
for y in l[2][:SOL]
Expand Down
5 changes: 5 additions & 0 deletions test/poly/spoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ end
@test degrees(x^2*y^3) == [2, 3]
@test vars(x^2 + 3x + 1) == [x]
@test var_index(x) == 1 && var_index(y) == 2
@test tail(3x^2*y + 2x*y + y + 7) == 2x*y + y + 7
@test tail(R(1)) == 0
@test tail(R()) == 0
@test leading_coefficient(3x^2 + 2x + 1) == 3
@test constant_coefficient(x^2*y + 2x + 3) == 3
@test constant_coefficient(x^2 + y) == 0
@test leading_monomial(3x^2 + 2x + 1) == x^2
@test leading_term(3x^2 + 2x + 1) == 3x^2
@test trailing_coefficient(3x^2*y + 2x + 7y + 9) == 9
Expand Down

0 comments on commit 39dda70

Please sign in to comment.