Skip to content

Commit

Permalink
Make radius a Float32
Browse files Browse the repository at this point in the history
  • Loading branch information
mkborregaard committed Jan 15, 2021
1 parent 1fc0cf5 commit 6a0e905
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/haversine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The computed distance has the same units as that of the radius.
struct Haversine{T<:Real} <: Metric
radius::T
end
Haversine() = Haversine(6371000.0)
Haversine() = Haversine(Float32(6371000))

function (dist::Haversine)(x, y)
length(x) == length(y) == 2 || haversine_error(dist)
Expand All @@ -31,7 +31,7 @@ function (dist::Haversine)(x, y)
2 * dist.radius * asin( min(a, one(a)) ) # take care of floating point errors
end

haversine(x, y, radius::Real = 6371000.0) = Haversine(radius)(x, y)
haversine(x, y, radius::Real = Float32(6371000)) = Haversine(radius)(x, y)

@noinline haversine_error(dist) = throw(ArgumentError("expected both inputs to have length 2 in $dist distance"))

Expand Down

0 comments on commit 6a0e905

Please sign in to comment.