-
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 pull request #114 from theogf/test_AD
Series of tests for AD
- Loading branch information
Showing
48 changed files
with
375 additions
and
229 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
struct Delta <: Distances.PreMetric | ||
end | ||
|
||
@inline function Distances._evaluate(::Delta,a::AbstractVector{T},b::AbstractVector{T}) where {T} | ||
@inline function Distances._evaluate(::Delta, a::AbstractVector, b::AbstractVector) where {T} | ||
@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) = promote_type(Ta, Tb) | ||
|
||
@inline (dist::Delta)(a::AbstractArray, b::AbstractArray) = Distances._evaluate(dist, a, b) | ||
@inline (dist::Delta)(a::Number,b::Number) = a == b | ||
@inline (dist::Delta)(a::Number, b::Number) = a == b |
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,13 +1,15 @@ | ||
struct DotProduct <: Distances.PreMetric end | ||
# struct DotProduct <: Distances.UnionSemiMetric end | ||
|
||
@inline function Distances._evaluate(::DotProduct, a::AbstractVector{T}, b::AbstractVector{T}) where {T} | ||
@inline function Distances._evaluate(::DotProduct, a::AbstractVector, b::AbstractVector) | ||
@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 dot(a,b) | ||
end | ||
|
||
Distances.result_type(::DotProduct, Ta::Type, Tb::Type) = promote_type(Ta, Tb) | ||
|
||
@inline Distances.eval_op(::DotProduct, a::Real, b::Real) = a * b | ||
@inline (dist::DotProduct)(a::AbstractArray,b::AbstractArray) = Distances._evaluate(dist, a, b) | ||
@inline (dist::DotProduct)(a::Number,b::Number) = a * b |
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
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[deps] | ||
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" | ||
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" | ||
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" | ||
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" | ||
Kronecker = "2c470bb0-bcc8-11e8-3dad-c9649493f05e" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" | ||
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" | ||
|
||
[compat] | ||
Distances = "0.9" | ||
FiniteDifferences = "0.10" | ||
Flux = "0.10" | ||
ForwardDiff = "0.10" | ||
Kronecker = "0.4" | ||
PDMats = "0.9" | ||
ReverseDiff = "1.2" | ||
SpecialFunctions = "0.10" | ||
Zygote = "0.4" |
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
Oops, something went wrong.