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

function ideal
# 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 *(R::Ring, x::Any)
return ideal(R, R(x))

Check warning on line 14 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L13-L14

Added lines #L13 - L14 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 18 in src/Ideal.jl

View check run for this annotation

Codecov / codecov/patch

src/Ideal.jl#L17-L18

Added lines #L17 - L18 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 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 *(x::RingElement, R::Ring)
return ideal(R, x)
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 *(R::Ring, x::RingElement)
return ideal(R, x)
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))
Expand Down
Loading