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

Extend ideal interface #1731

Merged
merged 10 commits into from
Aug 18, 2024
24 changes: 20 additions & 4 deletions src/Ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,33 @@
#
###############################################################################

function ideal
end
# We assume that the functions
# ideal(R::Ring, x::RingElement)
# ideal(R::Ring, xs::AbstractVector)
# are implemented by anyone implementing ideals for AbstractAlgebra rings.
# The functions in this file extend the interface for `ideal`.
fingolfin marked this conversation as resolved.
Show resolved Hide resolved

function *(x::RingElement, R::Ring)
function *(R::Ring, x::Any)

Check warning on line 13 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L13

Added line #L13 was not covered by tests
return ideal(R, x)
end

function *(R::Ring, x::RingElement)
function *(x::Any, R::Ring)

Check warning on line 17 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L17

Added line #L17 was not covered by tests
return ideal(R, x)
end

function ideal(R::Ring, x::Any)
return ideal(R, R(x))

Check warning on line 22 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L21-L22

Added lines #L21 - L22 were not covered by tests
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
end

function ideal(x::RingElement)
return ideal(parent(x), x)

Check warning on line 26 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L25-L26

Added lines #L25 - L26 were not covered by tests
end

function ideal(xs::AbstractVector{T}) where T<:RingElement
!is_empty(xs) || throw(ArgumentError("Empty collection, cannot determine parent ring, try ideal(ring, xs) instead of ideal(xs)"))
return ideal(parent(xs[1]), xs)

Check warning on line 31 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L29-L31

Added lines #L29 - L31 were not covered by tests
end

iszero(I::Ideal) = all(iszero, gens(I))

base_ring_type(::Type{<:IdealSet{T}}) where T <: RingElement = parent_type(T)
Loading