Skip to content

Commit

Permalink
faster sparse(::Diagonal)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Aug 31, 2017
1 parent 7e35ac6 commit e3b4bd0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,11 @@ function sparse(B::Bidiagonal)
return sparse([1:m;1:m-1],[1:m;2:m],[B.dv;B.ev], Int(m), Int(m)) # upper bidiagonal
end

function sparse(D::Diagonal)
m = length(D.diag)
return SparseMatrixCSC(m, m, [1:m; m+1], [1:m;], D.diag)
end

## Transposition and permutation methods

"""
Expand Down

0 comments on commit e3b4bd0

Please sign in to comment.