Skip to content

Commit

Permalink
Even more simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz committed Jan 21, 2017
1 parent 149f8aa commit aa8d3a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 3 additions & 3 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ containertype(ct1, ct2) = promote_containertype(containertype(ct1), containertyp
@inline containertype(ct1, ct2, cts...) = promote_containertype(containertype(ct1), containertype(ct2, cts...))

promote_containertype(ct1, ct2) = Array
promote_containertype{T<:AbstractArray}(::Type{T}, ::Type{Tuple}) = Array
promote_containertype{T<:AbstractArray}(::Type{Tuple}, ::Type{T}) = Array
promote_containertype(::Type{Array}, ::Type{VecOrMat}) = Array
promote_containertype(::Type{VecOrMat}, ::Type{Array}) = Array
promote_containertype(::Type{VecOrMat}, ::Type{Tuple}) = Array
promote_containertype(::Type{Tuple}, ::Type{VecOrMat}) = Array
promote_containertype{T<:Array}(::Type{T}, ::ScalarType) = T
promote_containertype{T<:Array}(::ScalarType, ::Type{T}) = T
promote_containertype(::Type{Tuple}, ::ScalarType) = Tuple
Expand All @@ -52,7 +52,7 @@ broadcast_indices(A) = broadcast_indices(containertype(A), A)
broadcast_indices(::ScalarType, A) = ()
broadcast_indices(::Type{Tuple}, A) = (OneTo(length(A)),)
broadcast_indices(::Type{Array}, A::Ref) = ()
broadcast_indices{T<:Array}(::Type{T}, A) = indices(A)
broadcast_indices{T<:AbstractArray}(::Type{T}, A) = indices(A)
@inline broadcast_indices(A, B...) = broadcast_shape((), broadcast_indices(A), map(broadcast_indices, B)...)
# shape (i.e., tuple-of-indices) inputs
broadcast_shape(shape::Tuple) = shape
Expand Down
7 changes: 1 addition & 6 deletions base/sparse/higherorderfns.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ module HigherOrderFns
# This module provides higher order functions specialized for sparse arrays,
# particularly map[!]/broadcast[!] for SparseVectors and SparseMatrixCSCs at present.
import Base: map, map!, broadcast, broadcast!
import Base.Broadcast: _containertype, promote_containertype,
broadcast_indices, broadcast_c, broadcast_c!
import Base.Broadcast: _containertype, promote_containertype, broadcast_c, broadcast_c!

using Base: front, tail, to_shape
using ..SparseArrays: SparseVector, SparseMatrixCSC, AbstractSparseArray,
Expand Down Expand Up @@ -857,8 +856,6 @@ end

# (9) broadcast[!] over combinations of broadcast scalars and sparse vectors/matrices

# broadcast shape promotion for combinations of sparse arrays and other types
broadcast_indices(::Type{AbstractSparseArray}, A) = indices(A)
# broadcast container type promotion for combinations of sparse arrays and other types
_containertype{T<:SparseVecOrMat}(::Type{T}) = AbstractSparseArray
# combinations of sparse arrays with broadcast scalars should yield sparse arrays
Expand All @@ -868,9 +865,7 @@ promote_containertype{T<:AbstractSparseArray}(::Type{Any}, ::Type{T}) = Abstract
promote_containertype{T<:AbstractSparseArray}(::Type{T}, ::Type{Any}) = AbstractSparseArray
# combinations of sparse arrays with anything else should fall back to generic dense broadcast
promote_containertype{T<:AbstractSparseArray}(::Type{Array}, ::Type{T}) = Array
promote_containertype{T<:AbstractSparseArray}(::Type{Tuple}, ::Type{T}) = Array
promote_containertype{T<:AbstractSparseArray}(::Type{T}, ::Type{Array}) = Array
promote_containertype{T<:AbstractSparseArray}(::Type{T}, ::Type{Tuple}) = Array

# broadcast[!] entry points for combinations of sparse arrays and other (scalar) types
@inline function broadcast_c{T<:AbstractSparseArray,N}(f, ::Type{T}, mixedargs::Vararg{Any,N})
Expand Down

0 comments on commit aa8d3a1

Please sign in to comment.