Open kirtsar opened 5 years ago
We can't really fix this completely when the input is a matrix because we specialize on the dimension if the points. If the input was a vector of static vectors then it should be theoretically possible to have it be type stable. In practice it is unlikely to be too much of an issue since in most cases there is either a function barrier or the call has enough points that the dynamic dispatch is negligible.
Note
julia> using StaticArrays
julia> x = [rand(SVector{3, Float64}) for i in 1:10];
julia> @code_warntype KDTree(x)
MethodInstance for KDTree(::Vector{SVector{3, Float64}})
from KDTree(data::AbstractVector{V}; ...) where V<:AbstractArray @ NearestNeighbors ~/JuliaPkgs/NearestNeighbors.jl/src/kd_tree.jl:19
Static Parameters
V = SVector{3, Float64}
Arguments
#self#::Type{KDTree}
data::Vector{SVector{3, Float64}}
Body::KDTree{SVector{3, Float64}, Euclidean, Float64, SVector{3, Float64}}
Given some data X, i want to create tree (KDTree, or Ball)