Skip to content

Commit

Permalink
Merge #1307
Browse files Browse the repository at this point in the history
1307: Diagonalize isapprox r=charleskawczynski a=charleskawczynski

This PR diagonalize `isapprox`

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
  • Loading branch information
bors[bot] and charleskawczynski authored Jul 6, 2023
2 parents 2ad67b7 + f760760 commit 8faf2c6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Fields/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,19 @@ LinearAlgebra.norm(field::Field, p::Real = 2; normalize = true) =
)

function Base.isapprox(
x::Field,
y::Field;
x::T,
y::T;
atol::Real = 0,
rtol::Real = Base.rtoldefault(eltype(parent(x)), eltype(parent(y)), atol),
nans::Bool = false,
norm::Function = LinearAlgebra.norm,
)
d = norm(x .- y)
return isfinite(d) && d <= max(atol, rtol * max(norm(x), norm(y)))
) where {T <: Field}
Δ = (x .- y)
FT = Spaces.undertype(axes(x))
d = norm(Δ)::FT
nx = norm(x)::FT
ny = norm(y)::FT
return isfinite(d) && d <= max(atol, rtol * max(nx, ny))
end

Base.:(==)(field1::Field, field2::Field) =
Expand Down

0 comments on commit 8faf2c6

Please sign in to comment.