Skip to content

Commit

Permalink
fix stack overflow for .*
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Aug 3, 2016
1 parent 270b61a commit 9ade765
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,9 @@ broadcast(::typeof(-), A::SparseMatrixCSC, B::Number) = convert(Array, A) .- B
broadcast(::typeof(-), A::Number, B::SparseMatrixCSC) = A .- convert(Array, B)
(-)(A::Array , B::SparseMatrixCSC) = A - convert(Array, B)

broadcast(::typeof(*), A::AbstractArray, B::AbstractArray) = broadcast_zpreserving(*, A, B)
broadcast(::typeof(*), A::SparseMatrixCSC, B::SparseMatrixCSC) = broadcast_zpreserving(*, A, B)
broadcast(::typeof(*), A::SparseMatrixCSC, B::Union{Array,BitArray}) = broadcast_zpreserving(*, A, B)
broadcast(::typeof(*), A::Union{Array,BitArray}, B::SparseMatrixCSC) = broadcast_zpreserving(*, A, B)
broadcast(::typeof(*), A::SparseMatrixCSC, B::Number) = SparseMatrixCSC(A.m, A.n, copy(A.colptr), copy(A.rowval), A.nzval .* B)
broadcast(::typeof(*), A::Number, B::SparseMatrixCSC) = SparseMatrixCSC(B.m, B.n, copy(B.colptr), copy(B.rowval), A .* B.nzval)

Expand Down
3 changes: 3 additions & 0 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ let x = [1:4;], y = x
@test y === x == [0,1,2,3]
end

# PR #17623: Fused binary operators
@test [true] .* [true] == [true]

# PR 16988
@test Base.promote_op(+, Bool) === Int
@test isa(broadcast(+, [true]), Array{Int,1})
Expand Down

0 comments on commit 9ade765

Please sign in to comment.