@@ -10,20 +10,42 @@ function DerivableInterfaces.interface(::Type{<:AbstractSparseArray})
1010end
1111
1212using DerivableInterfaces: @derive
13-
14- # TODO : These need to be loaded since `AbstractArrayOps`
15- # includes overloads of functions from these modules.
16- # Ideally that wouldn't be needed and can be circumvented
17- # with `GlobalRef`.
1813using ArrayLayouts: ArrayLayouts
1914using LinearAlgebra: LinearAlgebra
2015
21- # DerivableInterfaces `Base.getindex`, `Base.setindex!`, etc.
22- # TODO : Define `AbstractMatrixOps` and overload for
23- # `AnyAbstractSparseMatrix` and `AnyAbstractSparseVector`,
24- # which is where matrix multiplication and factorizations
25- # should go.
26- @derive AnyAbstractSparseArray AbstractArrayOps
16+ # This type alias is a temporary workaround since `@derive`
17+ # doesn't parse the `@MIME_str` macro properly at the moment.
18+ const MIMEtextplain = MIME " text/plain"
19+
20+ @derive (T= AnyAbstractSparseArray,) begin
21+ Base. getindex (:: T , :: Any... )
22+ Base. getindex (:: T , :: Int... )
23+ Base. setindex! (:: T , :: Any , :: Any... )
24+ Base. setindex! (:: T , :: Any , :: Int... )
25+ Base. similar (:: T , :: Type , :: Tuple{Vararg{Int}} )
26+ Base. similar (:: T , :: Type , :: Tuple{Base.OneTo,Vararg{Base.OneTo}} )
27+ Base. copy (:: T )
28+ Base. copy! (:: AbstractArray , :: T )
29+ Base. copyto! (:: AbstractArray , :: T )
30+ Base. map (:: Any , :: T... )
31+ Base. map! (:: Any , :: AbstractArray , :: T... )
32+ Base. mapreduce (:: Any , :: Any , :: T... ; kwargs... )
33+ Base. reduce (:: Any , :: T... ; kwargs... )
34+ Base. all (:: Function , :: T )
35+ Base. all (:: T )
36+ Base. iszero (:: T )
37+ Base. real (:: T )
38+ Base. fill! (:: T , :: Any )
39+ ArrayLayouts. zero! (:: T )
40+ Base. zero (:: T )
41+ Base. permutedims! (:: Any , :: T , :: Any )
42+ Broadcast. BroadcastStyle (:: Type{<:T} )
43+ Base. copyto! (:: T , :: Broadcast.Broadcasted{Broadcast.DefaultArrayStyle{0}} )
44+ Base. cat (:: T... ; kwargs... )
45+ ArrayLayouts. MemoryLayout (:: Type{<:T} )
46+ LinearAlgebra. mul! (:: AbstractMatrix , :: T , :: T , :: Number , :: Number )
47+ Base. show (:: IO , :: MIMEtextplain , :: T )
48+ end
2749
2850function Base. replace_in_print_matrix (
2951 A:: AnyAbstractSparseArray{<:Any,2} , i:: Integer , j:: Integer , s:: AbstractString
0 commit comments