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

another sparsify

This commit is contained in:
kalmar 2017-07-05 13:19:12 +02:00
parent c0e2577684
commit e648d2c370

View File

@ -140,6 +140,19 @@ function Cstar_repr(x::GroupRingElem, mreps)
return res
end
dens(M::SparseMatrixCSC) = length(M.nzval)/length(M)
dens(M::AbstractArray) = sum(abs.(M) .!= 0)/length(M)
function sparsify2(M::AbstractArray)
println("Density before sparsification: \t$(dens(M))")
M = deepcopy(M)
M[M .< eps(eltype(M))] .= zero(eltype(M))
M = sparse(M)
dropzeros!(M)
println("Density after sparsification: \t$(dens(M))")
return M
end
function orthSVD(M::AbstractMatrix)
M = full(M)
fact = svdfact(M)