Skip to content

Commit 6e38631

Browse files
committed
Rewrite broadcast/broadcast! over a pair of (input) sparse matrices with new (JuliaLang#19372) semantics / less pessimistic allocation behavior and optimize a few inefficiently handled common cases. Also provide a broadcast/broadcast! implementation capable of (relatively) efficiently handling an arbitrary number of (input) sparse matrices. Integrate with the map/map! implementation, and touch up a few rough edges of the map/map! implementation. Test.
1 parent be9198c commit 6e38631

File tree

3 files changed

+583
-336
lines changed

3 files changed

+583
-336
lines changed

base/sparse/linalg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ function norm(A::SparseMatrixCSC,p::Real=2)
507507
nA::Tsum = 0
508508
for j=1:n
509509
colSum::Tsum = 0
510-
for i = A.colptr[j]:A.colptr[j+1]-1
510+
for i in nzrange(A, j)
511511
colSum += abs(A.nzval[i])
512512
end
513513
nA = max(nA, colSum)
@@ -517,7 +517,7 @@ function norm(A::SparseMatrixCSC,p::Real=2)
517517
throw(ArgumentError("2-norm not yet implemented for sparse matrices. Try norm(Array(A)) or norm(A, p) where p=1 or Inf."))
518518
elseif p==Inf
519519
rowSum = zeros(Tsum,m)
520-
for i=1:length(A.nzval)
520+
for i in 1:nnz(A)
521521
rowSum[A.rowval[i]] += abs(A.nzval[i])
522522
end
523523
return convert(Tnorm, maximum(rowSum))

0 commit comments

Comments
 (0)