Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah committed Jun 14, 2015
2 parents 6608027 + 0497967 commit 21be6ab
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions base/sparse/csparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,19 @@ function fkeep!{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, f, other)
A
end

droptol!(A::SparseMatrixCSC, tol) = fkeep!(A, (i,j,x,other)->abs(x)>other, tol)
dropzeros!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->x!=0, nothing)
triu!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->(j>=i), nothing)

immutable DropTolFun <: Func{4} end
call(::DropTolFun, i,j,x,other) = abs(x)>other
immutable DropZerosFun <: Func{4} end
call(::DropZerosFun, i,j,x,other) = x!=0
immutable TriuFun <: Func{4} end
call(::TriuFun, i,j,x,other) = j>=i
immutable TrilFun <: Func{4} end
call(::TrilFun, i,j,x,other) = i>=j

droptol!(A::SparseMatrixCSC, tol) = fkeep!(A, DropTolFun(), tol)
dropzeros!(A::SparseMatrixCSC) = fkeep!(A, DropZerosFun(), nothing)
triu!(A::SparseMatrixCSC) = fkeep!(A, TriuFun(), nothing)
triu(A::SparseMatrixCSC) = triu!(copy(A))
tril!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->(i>=j), nothing)
tril!(A::SparseMatrixCSC) = fkeep!(A, TrilFun(), nothing)
tril(A::SparseMatrixCSC) = tril!(copy(A))

0 comments on commit 21be6ab

Please sign in to comment.