Skip to content

Commit 4906add

Browse files
committed
Specialize for strided contiguous SubArrays
1 parent abfb65d commit 4906add

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/generic.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,8 +2004,8 @@ function isapprox(x::AbstractArray, y::AbstractArray;
20042004
atol::Real=0,
20052005
rtol::Real=Base.rtoldefault(promote_leaf_eltypes(x),promote_leaf_eltypes(y),atol),
20062006
nans::Bool=false, norm::Function=norm)
2007+
Base.promote_shape(size(x), size(y)) # ensure compatible size
20072008
d = if isempty(x) && isempty(y)
2008-
Base.promote_shape(size(x), size(y)) # ensure same size
20092009
norm(zero(eltype(x)) - zero(eltype(y)))
20102010
else
20112011
norm_x_minus_y(x, y)
@@ -2020,8 +2020,8 @@ function isapprox(x::AbstractArray, y::AbstractArray;
20202020
end
20212021

20222022
norm_x_minus_y(x, y) = norm(x - y)
2023-
function norm_x_minus_y(x::Array, y::Array)
2024-
Base.promote_shape(size(x), size(y)) # ensure same size
2023+
const ArrayOrFastContiguousSubArrayStrided = Union{Array, FastContiguousSubArrayStrided}
2024+
function norm_x_minus_y(x::ArrayOrFastContiguousSubArrayStrided, y::ArrayOrFastContiguousSubArrayStrided)
20252025
norm(Iterators.map(splat(-), zip(x,y)))
20262026
end
20272027

0 commit comments

Comments
 (0)