1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-19 07:20:28 +01:00

Add logging when verbose=true

This commit is contained in:
kalmarek 2017-08-27 21:23:42 +02:00
parent 6df4c790c0
commit 3b723e7f0e

View File

@ -57,8 +57,10 @@ include("OrbitDecomposition.jl")
dens(M::SparseMatrixCSC) = length(M.nzval)/length(M)
dens(M::AbstractArray) = length(findn(M)[1])/length(M)
function sparsify!{Tv,Ti}(M::SparseMatrixCSC{Tv,Ti}, eps=eps(Tv))
function sparsify!{Tv,Ti}(M::SparseMatrixCSC{Tv,Ti}, eps=eps(Tv); verbose=false)
n = nnz(M)
densM = dens(M)
for i in eachindex(M.nzval)
if abs(M.nzval[i]) < eps
M.nzval[i] = zero(Tv)
@ -67,7 +69,9 @@ function sparsify!{Tv,Ti}(M::SparseMatrixCSC{Tv,Ti}, eps=eps(Tv))
dropzeros!(M)
m = nnz(M)
info("Sparsified density:", rpad(dens(U), 15), "", rpad(dens(W),15))
if verbose
info(logger, "Sparsified density:", rpad(densM, 20), "", rpad(dens(M), 20))
end
return M
end
@ -81,6 +85,8 @@ function sparsify!{T}(M::AbstractArray{T}, eps=eps(T); check=false, verbose=fals
warn(logger, "Sparsification decreased the rank!")
end
if verbose
info(logger, "Sparsified density:", rpad(densM, 20), "", rpad(dens(M),20))
end
return M