diff --git a/CHANGELOG.md b/CHANGELOG.md index ab529af..6b8e8a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - `depestregression` returns `Dict` instead of a `vector` of betas like other regression methods. - `summary()` throws `ErrorException` rather than simply prompting with `@error` macro. - `robcov` doesn't use try and catch any more. - +- Replace `sortperm` with `sortperm!` in mve. # v0.11.3 diff --git a/src/mve.jl b/src/mve.jl index 9407553..5a3c10b 100644 --- a/src/mve.jl +++ b/src/mve.jl @@ -15,20 +15,24 @@ import ..Diagnostics: mahalanobisSquaredMatrix function enlargesubset(initialsubset, data::AbstractMatrix, h::Int) - p = size(data, 2) + + n, p = size(data) basicsubset = copy(initialsubset) meanvector = Array{Float64}(undef, p) + md2sortedindex = Array{Int}(undef, n) + while length(basicsubset) < h applyColumns!(meanvector, mean, data[basicsubset, :]) covmatrix = cov(data[basicsubset, :]) md2mat = mahalanobisSquaredMatrix(data, meanvector=meanvector, covmatrix=covmatrix) if !isnothing(md2mat) - md2 = diag(md2mat) - md2sortedindex = sortperm(md2) + #md2 = diag(md2mat) + #md2sortedindex = sortperm(md2) + sortperm!(md2sortedindex, diag(md2mat)) basicsubset = md2sortedindex[1:(length(basicsubset)+1)] else basicsubset = 1:(length(basicsubset)+1)