Skip to content

Commit

Permalink
Replace zero(T) with 0 in sparse matrix code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah committed May 1, 2014
1 parent 1651d99 commit 5d48bbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions base/sparse/csparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function sparse{Tv,Ti<:Integer}(I::AbstractVector{Ti}, J::AbstractVector{Ti},
Rnz[1] = 1
nz = 0
for k=1:length(I)
if V[k] != zero(Tv)
if V[k] != 0
Rnz[I[k]+1] += 1
nz += 1
end
Expand All @@ -45,7 +45,7 @@ function sparse{Tv,Ti<:Integer}(I::AbstractVector{Ti}, J::AbstractVector{Ti},
ind = I[k]
p = Wj[ind]
Vk = V[k]
if Vk != zero(Tv)
if Vk != 0
Wj[ind] += 1
Rx[p] = Vk
Ri[p] = J[k]
Expand Down Expand Up @@ -231,7 +231,7 @@ function etree{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, postorder::Bool)
head = zeros(Ti,n) # empty linked lists
next = zeros(Ti,n)
for j in n:-1:1 # traverse in reverse order
if (parent[j] == zero(Ti)); continue; end # j is a root
if (parent[j] == 0); continue; end # j is a root
next[j] = head[parent[j]] # add j to list of its parent
head[parent[j]] = j
end
Expand Down Expand Up @@ -359,7 +359,7 @@ function fkeep!{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, f, other)
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!=zero(Tv), None)
dropzeros!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->x!=0, None)
triu!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->(j>=i), None)
triu(A::SparseMatrixCSC) = triu!(copy(A))
tril!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->(i>=j), None)
Expand Down
8 changes: 4 additions & 4 deletions base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function findn{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti})

count = 1
for col = 1 : S.n, k = S.colptr[col] : (S.colptr[col+1]-1)
if S.nzval[k] != zero(Tv)
if S.nzval[k] != 0
I[count] = S.rowval[k]
J[count] = col
count += 1
Expand All @@ -317,7 +317,7 @@ function findnz{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti})

count = 1
for col = 1 : S.n, k = S.colptr[col] : (S.colptr[col+1]-1)
if S.nzval[k] != zero(Tv)
if S.nzval[k] != 0
I[count] = S.rowval[k]
J[count] = col
V[count] = S.nzval[k]
Expand Down Expand Up @@ -1421,7 +1421,7 @@ function istriu{Tv}(A::SparseMatrixCSC{Tv})
if A.rowval[l1-i] <= col
break
end
if A.nzval[l1-i] != zero(Tv)
if A.nzval[l1-i] != 0
return false
end
end
Expand All @@ -1435,7 +1435,7 @@ function istril{Tv}(A::SparseMatrixCSC{Tv})
if A.rowval[i] >= col
break
end
if A.nzval[i] != zero(Tv)
if A.nzval[i] != 0
return false
end
end
Expand Down

0 comments on commit 5d48bbd

Please sign in to comment.