Skip to content

Commit 510f583

Browse files
committed
Move isequal & isapprox methods to NCRings.jl
... and generalize isequal to NCRingElem
1 parent 983f6ec commit 510f583

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/NCRings.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,25 @@ function ==(x::NCRingElem, y::NCRingElem)
9696

9797
==(x::NCRingElement, y::NCRingElem) = parent(y)(x) == y
9898

99+
function isequal(a::NCRingElem, b::NCRingElem)
100+
return parent(a) == parent(b) && a == b
101+
end
102+
103+
# Implement `isapprox` for ring elements via equality by default. On the one
104+
# hand, we need isapprox methods to be able to conformance test series rings.
105+
# On the other hand this is essentially the only sensible thing to do in
106+
# positive characteristic so we might as well do it in a generic method.
107+
function Base.isapprox(x::NCRingElem, y::NCRingElem;
108+
atol::Real=0, rtol::Real=0,
109+
nans::Bool=false, norm::Function=abs)
110+
if is_exact_type(typeof(x)) && is_exact_type(typeof(y))
111+
@req is_zero(atol) "non-zero atol not supported"
112+
@req is_zero(rtol) "non-zero rtol not supported"
113+
return x == y
114+
end
115+
throw(NotImplementedError(:isapprox, x, y))
116+
end
117+
99118
function divexact_left(x::NCRingElem, y::NCRingElem; check::Bool = true)
100119
return divexact_left(promote(x, y)...)
101120
end

src/Rings.jl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,6 @@
44
#
55
###############################################################################
66

7-
function isequal(a::RingElem, b::RingElem)
8-
return parent(a) == parent(b) && a == b
9-
end
10-
11-
# Implement `isapprox` for ring elements via equality by default. On the one
12-
# hand, we need isapprox methods to be able to conformance test series rings.
13-
# On the other hand this is essentially the only sensible thing to do in
14-
# positive characteristic so we might as well do it in a generic method.
15-
function Base.isapprox(x::NCRingElem, y::NCRingElem;
16-
atol::Real=0, rtol::Real=0,
17-
nans::Bool=false, norm::Function=abs)
18-
if is_exact_type(typeof(x)) && is_exact_type(typeof(y))
19-
@req is_zero(atol) "non-zero atol not supported"
20-
@req is_zero(rtol) "non-zero rtol not supported"
21-
return x == y
22-
end
23-
throw(NotImplementedError(:isapprox, x, y))
24-
end
25-
267
"""
278
divexact(x, y; check::Bool=true)
289

0 commit comments

Comments
 (0)