Skip to content

Commit 7077a58

Browse files
committed
Fix Base.in for Singular.PolyRing
GAP's 'r in Ring' checks if r is a ring element. Julia's generic 'in' tries to iterate over the collection, which fails for PolyRing since Singular rings don't implement iterate(). Add Base.in methods: spoly membership by base_ring identity, and true for integers/rationals which can always be coerced.
1 parent 8e96f10 commit 7077a58

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

ext/MatricesForHomalgSingularExt.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,4 +1399,20 @@ function MatricesForHomalg.ReducedSyzygiesOfRows(A::Singular.smatrix, N::Singula
13991399
return Singular.transpose(MatricesForHomalg.ReducedSyzygiesOfColumns(Singular.transpose(A), Singular.transpose(N)))
14001400
end
14011401

1402+
## Ring membership for Singular polynomial rings
1403+
#
1404+
# In GAP, `r in Ring` checks if r is an element of Ring. Julia's generic `in`
1405+
# tries to iterate over the collection, which fails for Singular.PolyRing.
1406+
# We define explicit Base.in methods to match GAP semantics.
1407+
1408+
# A Singular polynomial belongs to R if it comes from that same ring
1409+
function Base.in(x::Singular.spoly{T}, R::Singular.PolyRing{T}) where T
1410+
Singular.base_ring(x) === R
1411+
end
1412+
1413+
# Integers and rationals can always be coerced into any polynomial ring
1414+
function Base.in(x::Union{Integer, Rational, AbstractFloat}, R::Singular.PolyRing)
1415+
true
1416+
end
1417+
14021418
end # module

0 commit comments

Comments
 (0)