@@ -5,7 +5,8 @@ module HigherOrderFns
5
5
# This module provides higher order functions specialized for sparse arrays,
6
6
# particularly map[!]/broadcast[!] for SparseVectors and SparseMatrixCSCs at present.
7
7
import Base: map, map!, broadcast, broadcast!
8
- import Base. Broadcast: containertype, promote_containertype, broadcast_indices, broadcast_c
8
+ import Base. Broadcast: containertype, promote_containertype,
9
+ broadcast_indices, broadcast_c, broadcast_c!
9
10
10
11
using Base: front, tail, to_shape
11
12
using .. SparseArrays: SparseVector, SparseMatrixCSC, AbstractSparseArray, indtype
@@ -852,11 +853,15 @@ promote_containertype(::Type{Tuple}, ::Type{AbstractSparseArray}) = Array
852
853
promote_containertype (:: Type{AbstractSparseArray} , :: Type{Array} ) = Array
853
854
promote_containertype (:: Type{AbstractSparseArray} , :: Type{Tuple} ) = Array
854
855
855
- # broadcast entry point for combinations of sparse arrays and other types
856
- function broadcast_c (f, :: Type{AbstractSparseArray} , mixedargs... )
856
+ # broadcast[!] entry points for combinations of sparse arrays and other types
857
+ @inline function broadcast_c {N} (f, :: Type{AbstractSparseArray} , mixedargs:: Vararg{Any,N} )
857
858
parevalf, passedargstup = capturescalars (f, mixedargs)
858
859
return broadcast (parevalf, passedargstup... )
859
860
end
861
+ @inline function broadcast_c! {N} (f, :: Type{AbstractSparseArray} , dest:: SparseVecOrMat , mixedsrcargs:: Vararg{Any,N} )
862
+ parevalf, passedsrcargstup = capturescalars (f, mixedsrcargs)
863
+ return broadcast! (parevalf, dest, passedsrcargstup... )
864
+ end
860
865
# capturescalars takes a function (f) and a tuple of mixed sparse vectors/matrices and
861
866
# broadcast scalar arguments (mixedargs), and returns a function (parevalf) and a reduced
862
867
# argument tuple (passedargstup) containing only the sparse vectors/matrices in mixedargs
0 commit comments