Skip to content

Commit

Permalink
Merge pull request #208 from fieker/oscar
Browse files Browse the repository at this point in the history
Oscar
  • Loading branch information
fieker authored Mar 19, 2020
2 parents 439f410 + f26ac98 commit 7f8204c
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ version = "0.2.0"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Nemo = "2edaba10-b0f1-5616-af89-8c11ac63239a"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"

[compat]
AbstractAlgebra = "^0.8.0"
Nemo = "^0.16.0"
AbstractAlgebra = "^0.9.0"
BinaryProvider = "^0.5.8"
Nemo = "^0.17.0"
julia = "1.0, 1.1, 1.2, 1.3, 1.4"
CxxWrap = "^0.9"
BinaryProvider = "^0.5.8"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
12 changes: 12 additions & 0 deletions deps/src/rings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,22 @@ void singular_define_rings(jlcxx::Module & Singular)
[](spolyrec * p, long * ev, ip_sring * r) {
return p_GetExpVL(p, ev, r);
});
Singular.method("p_GetExpVLV_internal",
[](spolyrec * p, long * ev, ip_sring * r) {
return p_GetExpVLV(p, ev, r);
});
Singular.method("p_SetExpV_internal",
[](spolyrec * p, int * ev, ip_sring * r) {
return p_SetExpV(p, ev, r);
});
Singular.method("p_SetExpVL_internal",
[](spolyrec * p, long * ev, ip_sring * r) {
return p_SetExpVL(p, ev, r);
});
Singular.method("p_SetExpVLV_internal",
[](spolyrec * p, long * ev, long c, ip_sring * r) {
return p_SetExpVLV(p, ev, c, r);
});
Singular.method("p_Reduce",
[](spolyrec * p, sip_sideal * G, ip_sring * R) {
const ring origin = currRing;
Expand Down
17 changes: 16 additions & 1 deletion src/libsingular/rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,30 @@ function p_GetExpVL(p::poly_ptr, ev::Array{Clong, 1}, r::ring_ptr)
p_GetExpVL_internal(p, ptr, r)
end

function p_GetExpVLV(p::poly_ptr, ev::Array{Clong, 1}, r::ring_ptr)
ptr = pointer(ev)
p_GetExpVLV_internal(p, ptr, r)
end

function p_SetExpV(p::poly_ptr, ev::Array{Cint, 1}, r::ring_ptr)
@assert ev[1] == 0
ptr = pointer(ev)
p_SetExpV_internal(p, ptr, r)
end

function p_SetExpVL(p::poly_ptr, ev::Array{Clong, 1}, r::ring_ptr)
ptr = pointer(ev)
p_SetExpVL_internal(p, ptr, r)
end

function p_SetExpVLV(p::poly_ptr, ev::Array{Clong, 1}, c::Clong, r::ring_ptr)
ptr = pointer(ev)
p_SetExpVLV_internal(p, ptr, c, r)
end

function p_ExtGcd(a::poly_ptr, b::poly_ptr, res::Ptr{poly_ptr}, s::Ptr{poly_ptr}, t::Ptr{poly_ptr}, r::ring_ptr)
sp = reinterpret(Ptr{Nothing},s)
tp = reinterpret(Ptr{Nothing},t)
rp = reinterpret(Ptr{Nothing},res)
return p_ExtGcd_internal(a, b, rp, sp, tp, r)
end
end
43 changes: 43 additions & 0 deletions src/module/vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ function (S::FreeMod{T})(a::Array{T, 1}) where T <: AbstractAlgebra.RingElem
return svector{T}(R, n, v)
end

function (S::FreeMod{T})() where T <: AbstractAlgebra.RingElem
R = base_ring(S) # polynomial ring
n = S.rank
z = zero(R)
return svector{T}(R, n, z.ptr)
end


###############################################################################
#
# Conversions
Expand All @@ -176,6 +184,41 @@ function Array(v::svector{spoly{T}}) where T <: Nemo.RingElem
return [spoly{T}(R, p) for p in aa]
end

###############################################################################
#
# iterators
#
###############################################################################

function Base.iterate(p::svector{spoly{T}}) where T <: Nemo.RingElem
ptr = p.ptr
if ptr.cpp_object == C_NULL
return nothing
else
R = base_ring(p)
A = Array{Int}(undef, nvars(R))
c = libSingular.p_GetExpVLV(ptr, A, R.ptr)
S = base_ring(R)
a = S(libSingular.n_Copy(libSingular.pGetCoeff(ptr), S.ptr))
return (c, A, a), ptr
end
end

function Base.iterate(p::svector{spoly{T}}, state) where T <: Nemo.RingElem
state = libSingular.pNext(state)
if state.cpp_object == C_NULL
return nothing
else
R = base_ring(p)
A = Array{Int}(undef, nvars(R))
c = libSingular.p_GetExpVLV(state, A, R.ptr)
S = base_ring(R)
a = S(libSingular.n_Copy(libSingular.pGetCoeff(state), S.ptr))
return (c, A, a), state
end
end

Base.IteratorSize(::svector{spoly{T}}) where {T} = Base.SizeUnknown()
###############################################################################
#
# Vector constructors
Expand Down

0 comments on commit 7f8204c

Please sign in to comment.