Skip to content

Commit

Permalink
Fast mean for sparse matrices along dimensions. (#7788)
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah committed Nov 23, 2014
1 parent 229f4aa commit bde4e65
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,8 @@ sum{T}(A::SparseMatrixCSC{T}, region) = reducedim(+,A,region,zero(T))
prod{T}(A::SparseMatrixCSC{T}) = nnz(A)!=length(A) ? zero(T) : prod(A.nzval)
prod{T}(A::SparseMatrixCSC{T}, region) = reducedim(*,A,region,one(T))

mean(A::SparseMatrixCSC, region::Integer) = sum(A, region) / size(A, region)

#all(A::SparseMatrixCSC{Bool}, region) = reducedim(all,A,region,true)
#any(A::SparseMatrixCSC{Bool}, region) = reducedim(any,A,region,false)
#sum(A::SparseMatrixCSC{Bool}, region) = reducedim(+,A,region,0,Int)
Expand Down

2 comments on commit bde4e65

@ViralBShah
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkelman
Copy link
Contributor

@tkelman tkelman commented on bde4e65 Feb 1, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backported in 541610b

Please sign in to comment.