Skip to content

Commit 755775c

Browse files
thchrLilithHafner
andauthored
Improve performance of isapprox(::AbstractArray, ::AbstractArray) when rtol = 0 (#47464)
Co-authored-by: Lilith Orion Hafner <[email protected]>
1 parent 7116a8b commit 755775c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stdlib/LinearAlgebra/src/generic.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ function isapprox(x::AbstractArray, y::AbstractArray;
17721772
nans::Bool=false, norm::Function=norm)
17731773
d = norm(x - y)
17741774
if isfinite(d)
1775-
return d <= max(atol, rtol*max(norm(x), norm(y)))
1775+
return iszero(rtol) ? d <= atol : d <= max(atol, rtol*max(norm(x), norm(y)))
17761776
else
17771777
# Fall back to a component-wise approximate comparison
17781778
# (mapreduce instead of all for greater generality [#44893])

0 commit comments

Comments
 (0)