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
28 changes: 26 additions & 2 deletions src/Ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
#
###############################################################################

function ideal
end
# We assume that the functions
# ideal(R::Ring, x::RingElement)
# ideal(R::Ring, xs::AbstractVector)
# are implemented in the package that uses AbstractAlgebra.
paemurru marked this conversation as resolved.
Show resolved Hide resolved
# 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)
return ideal(R, x)
Expand All @@ -15,6 +18,27 @@
return ideal(R, x)
end

function *(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
paemurru marked this conversation as resolved.
Show resolved Hide resolved
paemurru marked this conversation as resolved.
Show resolved Hide resolved
end

function *(x::Any, R::Ring)
return ideal(R, R(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
paemurru marked this conversation as resolved.
Show resolved Hide resolved
end

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

Check warning on line 30 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L29-L30

Added lines #L29 - L30 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 34 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L33-L34

Added lines #L33 - L34 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 39 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L37-L39

Added lines #L37 - L39 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