File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ using DerivableInterfaces
1919include (" abstractsparsearrayinterface.jl" )
2020include (" indexing.jl" )
2121include (" map.jl" )
22- include (" sparsearrayinterface .jl" )
22+ include (" broadcast .jl" )
2323
2424# types
2525include (" wrappers.jl" )
Original file line number Diff line number Diff line change 1+ using Base. Broadcast: Broadcasted
2+ using MapBroadcast: Mapped
3+
4+ abstract type AbstractSparseArrayStyle{N} <: Broadcast.AbstractArrayStyle{N} end
5+
6+ struct SparseArrayStyle{N} <: AbstractSparseArrayStyle{N} end
7+ SparseArrayStyle {M} (:: Val{N} ) where {M,N} = SparseArrayStyle {N} ()
8+
9+ DerivableInterfaces. interface (:: Type{<:AbstractSparseArrayStyle} ) = SparseArrayInterface ()
10+
11+ @derive (T= AbstractSparseArrayStyle,) begin
12+ Base. similar (:: Broadcasted{<:T} , :: Type , :: Tuple )
13+ Base. copyto! (:: AbstractArray , :: Broadcasted{<:T} )
14+ end
15+
16+ @interface :: AbstractSparseArrayInterface function Broadcast. BroadcastStyle (type:: Type )
17+ return SparseArrayStyle {ndims(type)} ()
18+ end
19+
20+ @interface I:: AbstractSparseArrayInterface function Base. similar (
21+ :: Broadcasted , :: Type{T} , ax
22+ ) where {T}
23+ return similar (I, T, ax)
24+ end
25+
26+ @interface I:: AbstractSparseArrayInterface function Base. copyto! (
27+ C:: AbstractArray , bc:: Broadcasted
28+ )
29+ m = Mapped (bc)
30+ return @interface I map! (m. f, C, m. args... )
31+ end
You can’t perform that action at this time.
0 commit comments