Closed annimesh2809 closed 7 years ago
The current implementation of kmeans has the following declaration:
kmeans
function kmeans(X::Matrix, k::Int; weights=nothing, init=_kmeans_default_init, maxiter::Integer=_kmeans_default_maxiter, tol::Real=_kmeans_default_tol, display::Symbol=_kmeans_default_display)
although it calls the function kmeans! whose declaration is:
kmeans!
function kmeans!{T<:AbstractFloat}(X::Matrix{T}, centers::Matrix{T}; weights=nothing, maxiter::Integer=_kmeans_default_maxiter, tol::Real=_kmeans_default_tol, display::Symbol=_kmeans_default_display)
Here T is a subtype of AbstractFloat. This constraint in T is not present in kmeans which allows us to call kmeans as:
T
AbstractFloat
kmeans(rand(Int,3,100), 5)
which throws an error.
I also require kmeans{T} to be constrained with T<:AbstractFloat because I am dispatching on kmeans for ImageSegmentation as:
kmeans{T}
T<:AbstractFloat
kmeans{T<:Colorant,N}(x::AbstractArray{T,N}, args...; kwargs...)
closed by #92
The current implementation of
kmeans
has the following declaration:although it calls the function
kmeans!
whose declaration is:Here
T
is a subtype ofAbstractFloat
. This constraint inT
is not present inkmeans
which allows us to callkmeans
as:which throws an error.
I also require
kmeans{T}
to be constrained withT<:AbstractFloat
because I am dispatching onkmeans
for ImageSegmentation as: