mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-11-27 01:10:28 +01:00
new, unified sparsify
This commit is contained in:
parent
f3874828e7
commit
760270d2e0
@ -53,11 +53,10 @@ end
|
|||||||
|
|
||||||
include("OrbitDecomposition.jl")
|
include("OrbitDecomposition.jl")
|
||||||
|
|
||||||
function sparsify{T}(U::Array{T}, eps=eps(T))
|
function sparsify{T}(U::AbstractArray{T}, eps=eps(T), check=true)
|
||||||
n = rank(U)
|
|
||||||
W = deepcopy(U)
|
W = deepcopy(U)
|
||||||
W[abs.(W) .< eps] = zero(T)
|
W[abs.(W) .< eps] = zero(T)
|
||||||
if rank(W) != n
|
if check && rank(W) != rank(U)
|
||||||
warn("Sparsification would decrease the rank!")
|
warn("Sparsification would decrease the rank!")
|
||||||
W = U
|
W = U
|
||||||
end
|
end
|
||||||
@ -66,14 +65,6 @@ function sparsify{T}(U::Array{T}, eps=eps(T))
|
|||||||
return W
|
return W
|
||||||
end
|
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)
|
function init_orbit_data(logger, sett::Settings; radius=2)
|
||||||
|
|
||||||
ex(fname) = isfile(joinpath(sett.name, fname))
|
ex(fname) = isfile(joinpath(sett.name, fname))
|
||||||
|
Loading…
Reference in New Issue
Block a user