diff --git a/Orb_AutFN.jl b/Orb_AutFN.jl index e14bad2..01a2bd7 100644 --- a/Orb_AutFN.jl +++ b/Orb_AutFN.jl @@ -34,7 +34,7 @@ immutable Settings tol::Float64 end -function sparsify!{T}(U::Array{T}, eps=eps(T)) +function sparsify{T}(U::Array{T}, eps=eps(T)) n = rank(U) W = deepcopy(U) W[abs.(W) .< eps] = zero(T) @@ -42,9 +42,9 @@ function sparsify!{T}(U::Array{T}, eps=eps(T)) warn("Sparsification would decrease the rank!") W = U end - U = sparse(U) - dropzeros!(U) - return U + W = sparse(W) + dropzeros!(W) + return W end function sparsify!{T}(U::SparseMatrixCSC{T}, eps=eps(T)) @@ -53,8 +53,6 @@ function sparsify!{T}(U::SparseMatrixCSC{T}, eps=eps(T)) return U end -sparsify{T}(U::AbstractArray{T}, eps=eps(T)) = sparsify!(deepcopy(U), eps) - small_to_zero!{T}(A::AbstractArray{T}, eps=eps(T)) = A[abs(A) .< eps] = zero(T) function init_model(Uπs)