Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove eltype_plus #17398

Merged
merged 2 commits into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,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, etree,
Expand Down
14 changes: 4 additions & 10 deletions base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1666,21 +1666,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 @@ -1723,10 +1717,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