diff --git a/base/broadcast.jl b/base/broadcast.jl index 7adf7d63f303a..9106f6e86446c 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -203,8 +203,8 @@ arguments to `f` unless it is also listed in the `As`, as in `broadcast!(f, A, A, B)` to perform `A[:] = broadcast(f, A, B)`. """ @inline broadcast!{N}(f, C::AbstractArray, A, Bs::Vararg{Any,N}) = - broadcast_c!(f, containertype(C, A, Bs...), C, A, Bs...) -@inline function broadcast_c!{N}(f, ::Type, C::AbstractArray, A, Bs::Vararg{Any,N}) + broadcast_c!(f, containertype(C), containertype(A, Bs...), C, A, Bs...) +@inline function broadcast_c!{N}(f, ::Type, ::Type, C, A, Bs::Vararg{Any,N}) shape = indices(C) @boundscheck check_broadcast_indices(shape, A, Bs...) keeps, Idefaults = map_newindexer(shape, A, Bs) diff --git a/base/sparse/higherorderfns.jl b/base/sparse/higherorderfns.jl index 1dfb6bddc8a02..a866776194d1c 100644 --- a/base/sparse/higherorderfns.jl +++ b/base/sparse/higherorderfns.jl @@ -854,7 +854,7 @@ promote_containertype(::Type{Tuple}, ::Type{AbstractSparseArray}) = Array promote_containertype(::Type{AbstractSparseArray}, ::Type{Array}) = Array promote_containertype(::Type{AbstractSparseArray}, ::Type{Tuple}) = Array -# broadcast[!] entry points for combinations of sparse arrays and other types +# broadcast[!] entry points for combinations of sparse arrays and other (scalar) types @inline function broadcast_c{N}(f, ::Type{AbstractSparseArray}, mixedargs::Vararg{Any,N}) parevalf, passedargstup = capturescalars(f, mixedargs) return broadcast(parevalf, passedargstup...) @@ -914,7 +914,12 @@ promote_containertype(::Type{Tuple}, ::Type{StructuredArray}) = Array # for combinations involving sparse/structured arrays and scalars only, # promote all structured arguments to sparse and then rebroadcast -broadcast_c{N,Tf}(f::Tf, ::Type{StructuredArray}, As::Vararg{Any,N}) = broadcast(f, map(_sparsifystructured, As)...) +@inline broadcast_c{N}(f, ::Type{StructuredArray}, As::Vararg{Any,N}) = + broadcast(f, map(_sparsifystructured, As)...) +@inline broadcast_c!{N}(f, ::Type{AbstractSparseArray}, ::Type{StructuredArray}, C, B, As::Vararg{Any,N}) = + broadcast!(f, C, _sparsifystructured(B), map(_sparsifystructured, As)...) +@inline broadcast_c!{N}(f, CT::Type, ::Type{StructuredArray}, C, B, As::Vararg{Any,N}) = + broadcast_c!(f, CT, Array, C, B, As...) @inline _sparsifystructured(S::SymTridiagonal) = SparseMatrixCSC(S) @inline _sparsifystructured(T::Tridiagonal) = SparseMatrixCSC(T) @inline _sparsifystructured(B::Bidiagonal) = SparseMatrixCSC(B)