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

new, unified sparsify

This commit is contained in:
kalmar 2017-07-05 13:14:34 +02:00
parent f3874828e7
commit 760270d2e0

View File

@ -53,11 +53,10 @@ end
include("OrbitDecomposition.jl")
function sparsify{T}(U::Array{T}, eps=eps(T))
n = rank(U)
function sparsify{T}(U::AbstractArray{T}, eps=eps(T), check=true)
W = deepcopy(U)
W[abs.(W) .< eps] = zero(T)
if rank(W) != n
if check && rank(W) != rank(U)
warn("Sparsification would decrease the rank!")
W = U
end
@ -66,14 +65,6 @@ function sparsify{T}(U::Array{T}, eps=eps(T))
return W
end
function sparsify!{T}(U::SparseMatrixCSC{T}, eps=eps(T))
U[abs.(U) .< eps] = zero(T)
dropzeros!(U)
return U
end
sparsify{T}(U::SparseMatrixCSC{T}, eps=eps(T)) = sparsify!(deepcopy(U), eps)
function init_orbit_data(logger, sett::Settings; radius=2)
ex(fname) = isfile(joinpath(sett.name, fname))