From 633d78e647c87db118bc71aca8845d6f426d59ba Mon Sep 17 00:00:00 2001 From: Alexey Stukalov Date: Mon, 18 Dec 2023 21:04:38 -0800 Subject: [PATCH] replace updatemin!() with min.() --- src/seeding.jl | 5 ++--- src/utils.jl | 14 -------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/seeding.jl b/src/seeding.jl index 4e0cb3f3..32107b12 100644 --- a/src/seeding.jl +++ b/src/seeding.jl @@ -180,9 +180,8 @@ function initseeds!(iseeds::AbstractVector{<:Integer}, alg::KmppAlg, iseeds[j] = p # update mincosts - c = view(X, :, p) colwise!(metric, tmpcosts, X, view(X, :, p)) - updatemin!(mincosts, tmpcosts) + mincosts .= min.(mincosts, tmpcosts) mincosts[p] = 0 end end @@ -211,7 +210,7 @@ function initseeds_by_costs!(iseeds::AbstractVector{<:Integer}, alg::KmppAlg, iseeds[j] = p # update mincosts - updatemin!(mincosts, view(costs, :, p)) + mincosts .= min.(mincosts, view(costs, :, p)) mincosts[p] = 0 end end diff --git a/src/utils.jl b/src/utils.jl index cf21ad74..c3546f61 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -64,20 +64,6 @@ display_level(s::Symbol) = get(DisplayLevels, s) do throw(ArgumentError("Invalid option display=:$s ($(join(valid_vals, ", ", ", or ")) expected)")) end -##### update minimum value - -function updatemin!(r::AbstractArray, x::AbstractArray) - n = length(r) - length(x) == n || throw(DimensionMismatch("Inconsistent array lengths.")) - @inbounds for i = 1:n - xi = x[i] - if xi < r[i] - r[i] = xi - end - end - return r -end - function check_assignments(assignments::AbstractVector{<:Integer}, nclusters::Union{Integer, Nothing}) nclu = nclusters === nothing ? maximum(assignments) : nclusters for (j, c) in enumerate(assignments)