@@ -3,6 +3,7 @@ module ParallelKMeans
33# Based on discourse discussion
44# https://discourse.julialang.org/t/optimization-tips-for-my-julia-code-can-i-make-it-even-faster-and-or-memory-efficient/34614/20
55
6+ using StatsBase
67import Base. Threads: @spawn , @threads
78
89export kmeans
@@ -137,30 +138,30 @@ function sum_of_squares(x::Array{Float64,2}, labels::Array{Int64,1}, centre::Arr
137138 return s
138139end
139140
140- function sum_of_squares (x:: Array{Float64,2} , labels:: Array{Int64,1} , centre:: Array , nth = Base. Threads. nthreads ())
141- s = 0.0
142-
143- @inbounds for j in axes (x, 2 )
144- for i in axes (x, 1 )
145- s += (x[i, j] - centre[labels[i], j])^ 2
146- end
147- end
148-
149- return s
150- end
151-
152-
153- function inner_sum_of_squares (x:: Array{Float64,2} , labels:: Array{Int64,1} , centre:: Array , r)
154- s = 0.0
155-
156- @inbounds for j in axes (x, 2 )
157- for i in r
158- s += (x[i, j] - centre[labels[i], j])^ 2
159- end
160- end
161-
162- return s
163- end
141+ # function sum_of_squares(x::Array{Float64,2}, labels::Array{Int64,1}, centre::Array, nth = Base.Threads.nthreads())
142+ # s = 0.0
143+ #
144+ # @inbounds for j in axes(x, 2)
145+ # for i in axes(x, 1)
146+ # s += (x[i, j] - centre[labels[i], j])^2
147+ # end
148+ # end
149+ #
150+ # return s
151+ # end
152+ #
153+ #
154+ # function inner_sum_of_squares(x::Array{Float64,2}, labels::Array{Int64,1}, centre::Array, r)
155+ # s = 0.0
156+ #
157+ # @inbounds for j in axes(x, 2)
158+ # for i in r
159+ # s += (x[i, j] - centre[labels[i], j])^2
160+ # end
161+ # end
162+ #
163+ # return s
164+ # end
164165
165166"""
166167 Kmeans(design_matrix, k; k_init="k-means++", max_iters=300, tol=1e-4, verbose=true)
0 commit comments