-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into tgf/docstring_kronmat
- Loading branch information
Showing
7 changed files
with
99 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
# Delta is not following the PreMetric rules since d(x, x) == 1 | ||
struct Delta <: Distances.UnionPreMetric end | ||
|
||
@inline Distances.eval_op(::Delta, a::Real, b::Real) = a == b | ||
@inline Distances.eval_reduce(::Delta, a, b) = a && b | ||
@inline Distances.eval_start(::Delta, a, b) = true | ||
@inline (dist::Delta)(a::AbstractArray, b::AbstractArray) = Distances._evaluate(dist, a, b) | ||
@inline (dist::Delta)(a::Number, b::Number) = a == b | ||
(dist::Delta)(a::Number, b::Number) = a == b | ||
Base.@propagate_inbounds function (dist::Delta)( | ||
a::AbstractArray{<:Number}, b::AbstractArray{<:Number} | ||
) | ||
@boundscheck if length(a) != length(b) | ||
throw( | ||
DimensionMismatch( | ||
"first array has length $(length(a)) which does not match the length of the second, $(length(b)).", | ||
), | ||
) | ||
end | ||
return a == b | ||
end | ||
|
||
Distances.result_type(::Delta, Ta::Type, Tb::Type) = Bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters