Skip to content

Commit

Permalink
Provide a default isapprox method for ring elements
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Oct 9, 2024
1 parent c6f2611 commit 803f965
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ function isequal(a::RingElem, b::RingElem)
return parent(a) == parent(b) && a == b
end

# Implement `isapprox` for ring elements via equality by default. On the one
# hand, we need isapprox methods to be able to conformance test series rings.
# On the other hand this is essentially the only sensible thing to do in
# positive characteristic so we might as well do it in a generic method.
function Base.isapprox(x::NCRingElem, y::NCRingElem;

Check warning on line 15 in src/Rings.jl

View check run for this annotation

Codecov / codecov/patch

src/Rings.jl#L15

Added line #L15 was not covered by tests
atol::Real=0, rtol::Real=0,
nans::Bool=false, norm::Function=abs)
if is_exact_type(typeof(x)) && is_exact_type(typeof(y))
@req is_zero(atol) "non-zero atol not supported"
@req is_zero(rtol) "non-zero rtol not supported"
return x == y

Check warning on line 21 in src/Rings.jl

View check run for this annotation

Codecov / codecov/patch

src/Rings.jl#L18-L21

Added lines #L18 - L21 were not covered by tests
end
throw(NotImplementedError(:isapprox, x, y))

Check warning on line 23 in src/Rings.jl

View check run for this annotation

Codecov / codecov/patch

src/Rings.jl#L23

Added line #L23 was not covered by tests
end

"""
divexact(x, y; check::Bool=true)
Expand Down

0 comments on commit 803f965

Please sign in to comment.