Skip to content

Commit

Permalink
Merge pull request #17398 from martinholters/rem_eltype_plus
Browse files Browse the repository at this point in the history
Remove eltype_plus
  • Loading branch information
JeffBezanson authored Jul 26, 2016
2 parents a8d7963 + 04aac31 commit 36ed21a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
3 changes: 0 additions & 3 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ end

## elementwise operators ##

# should this be deprecated? Only use in Base is in sparsematrix.jl
eltype_plus(As::AbstractArray...) = promote_eltype_op(+, As...)

for op in (:÷, :%, :<<, :>>, :-, :/, :\, ://, :^)
@eval $(Symbol(:., op))(A::AbstractArray, B::AbstractArray) = broadcast($(op), A, B)
end
Expand Down
4 changes: 2 additions & 2 deletions base/sparse/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module SparseArrays

using Base: ReshapedArray, setindex_shape_check, to_shape
using Base: ReshapedArray, promote_op, setindex_shape_check, to_shape
using Base.Sort: Forward
using Base.LinAlg: AbstractTriangular, PosDefException

Expand All @@ -26,7 +26,7 @@ import Base: @get!, acos, acosd, acot, acotd, acsch, asech, asin, asind, asinh,
rotl90, rotr90, round, scale!, setindex!, similar, size, transpose, tril,
triu, vcat, vec, permute!

import Base.Broadcast: eltype_plus, broadcast_shape
import Base.Broadcast: broadcast_shape

export AbstractSparseArray, AbstractSparseMatrix, AbstractSparseVector,
SparseMatrixCSC, SparseVector, blkdiag, dense, droptol!, dropzeros!, dropzeros,
Expand Down
14 changes: 4 additions & 10 deletions base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1653,21 +1653,15 @@ broadcast_zpreserving{Tv,Ti}(f::Function, A_1::Union{Array,BitArray,Number}, A_2

## Binary arithmetic and boolean operators

for (op, pro) in ((+, :eltype_plus),
(-, :eltype_plus),
(min, :promote_eltype),
(max, :promote_eltype),
(&, :promote_eltype),
(|, :promote_eltype),
($, :promote_eltype))
for op in (+, -, min, max, &, |, $)
body = gen_broadcast_body_sparse(op, true)
OP = Symbol(string(op))
@eval begin
function ($OP){Tv1,Ti1,Tv2,Ti2}(A_1::SparseMatrixCSC{Tv1,Ti1}, A_2::SparseMatrixCSC{Tv2,Ti2})
if size(A_1,1) != size(A_2,1) || size(A_1,2) != size(A_2,2)
throw(DimensionMismatch(""))
end
Tv = ($pro)(A_1, A_2)
Tv = promote_op($op, Tv1, Tv2)
B = spzeros(Tv, promote_type(Ti1, Ti2), to_shape(broadcast_shape(A_1, A_2)))
$body
B
Expand Down Expand Up @@ -1710,10 +1704,10 @@ end # macro
(.^)(A::Array, B::SparseMatrixCSC) = (.^)(A, full(B))

.+{Tv1,Ti1,Tv2,Ti2}(A_1::SparseMatrixCSC{Tv1,Ti1}, A_2::SparseMatrixCSC{Tv2,Ti2}) =
broadcast!(+, spzeros(eltype_plus(A_1, A_2), promote_type(Ti1, Ti2), to_shape(broadcast_shape(A_1, A_2))), A_1, A_2)
broadcast!(+, spzeros(promote_op(+, Tv1, Tv2), promote_type(Ti1, Ti2), to_shape(broadcast_shape(A_1, A_2))), A_1, A_2)

function .-{Tva,Tia,Tvb,Tib}(A::SparseMatrixCSC{Tva,Tia}, B::SparseMatrixCSC{Tvb,Tib})
broadcast!(-, spzeros(eltype_plus(A, B), promote_type(Tia, Tib), to_shape(broadcast_shape(A, B))), A, B)
broadcast!(-, spzeros(promote_op(-, Tva, Tvb), promote_type(Tia, Tib), to_shape(broadcast_shape(A, B))), A, B)
end

## element-wise comparison operators returning SparseMatrixCSC ##
Expand Down

0 comments on commit 36ed21a

Please sign in to comment.