Skip to content

Commit

Permalink
normalizearray!
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Jul 13, 2024
1 parent 7766e34 commit 4fcec28
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/NMFkMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,26 @@ function normalizearray(a::AbstractArray, dim::Integer; kw...)
return normalizearray!(copy(a), dim; kw...)
end

function normalizearray!(a::AbstractArray, dim::Integer; rev::Bool=false, log::Bool=false)
function normalizearray!(a::AbstractArray, dim::Integer; rev::Bool=false, log::Bool=false, logv::AbstractVector=[])
n = size(a, dim)
logv = falses(n)
if log
if length(logv) == 0
logv = falses(n)
if log
for i = 1:n
nt = ntuple(k->(k == dim ? (i:i) : Colon()), ndims(a))
s = StatsBase.skewness(vec(a[nt...]))
if s > 1
a[nt...] .= NMFk.log10s(a[nt...])
logv[i] = true
end
end
end
else
@assert length(logv) == n
for i = 1:n
nt = ntuple(k->(k == dim ? (i:i) : Colon()), ndims(a))
s = StatsBase.skewness(vec(a[nt...]))
if s > 1
if logv[i]
a[nt...] .= NMFk.log10s(a[nt...])
logv[i] = true
end
end
end
Expand Down

0 comments on commit 4fcec28

Please sign in to comment.