Skip to content

Commit 2ae0cd6

Browse files
committed
Needed type promotion for ForwardDiff.jl
1 parent f70adc1 commit 2ae0cd6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/distances/dotproduct.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ struct DotProduct <: Distances.PreMetric end
88
return dot(a,b)
99
end
1010

11+
Distances.result_type(::DotProduct, Ta::Type, Tb::Type) = promote_type(Ta, Tb)
12+
1113
@inline Distances.eval_op(::DotProduct, a::Real, b::Real) = a * b
1214
@inline (dist::DotProduct)(a::AbstractArray,b::AbstractArray) = Distances._evaluate(dist, a, b)
1315
@inline (dist::DotProduct)(a::Number,b::Number) = a * b

src/distances/sinus.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ Distances.parameters(d::Sinus) = d.r
88
@inline (dist::Sinus)(a::AbstractArray, b::AbstractArray) = Distances._evaluate(dist, a, b)
99
@inline (dist::Sinus)(a::Number, b::Number) = abs2(sinpi(a - b) / first(dist.r))
1010

11-
@inline function Distances._evaluate(d::Sinus, a::AbstractVector{T}, b::AbstractVector{T}) where {T}
11+
Distances.result_type(::Sinus{T}, Ta::Type, Tb::Type) where {T} = promote_type(T, Ta, Tb)
12+
13+
@inline function Distances._evaluate(d::Sinus, a::AbstractVector, b::AbstractVector) where {T}
1214
@boundscheck if (length(a) != length(b)) || length(a) != length(d.r)
1315
throw(DimensionMismatch("Dimensions of the inputs are not matching : a = $(length(a)), b = $(length(b)), r = $(length(d.r))"))
1416
end

0 commit comments

Comments
 (0)