@@ -120,19 +120,18 @@ blocktype(a::BlockSparseArrayLike) = eltype(blocks(a))
120
120
blocktype (arraytype:: Type{<:BlockSparseArrayLike} ) = eltype (blockstype (arraytype))
121
121
122
122
using ArrayLayouts: ArrayLayouts
123
- # # function Base.getindex(a::BlockSparseArrayLike{<:Any,N}, I::Vararg{Int,N}) where {N}
124
- # # return ArrayLayouts.layout_getindex(a, I...)
125
- # # end
126
123
function Base. getindex (a:: BlockSparseArrayLike{<:Any,N} , I:: CartesianIndices{N} ) where {N}
127
124
return ArrayLayouts. layout_getindex (a, I)
128
125
end
129
126
function Base. getindex (
130
- a:: BlockSparseArrayLike{<:Any,N} , I:: Vararg{AbstractUnitRange,N}
127
+ a:: BlockSparseArrayLike{<:Any,N} , I:: Vararg{AbstractUnitRange{<:Integer} ,N}
131
128
) where {N}
132
129
return ArrayLayouts. layout_getindex (a, I... )
133
130
end
134
131
# TODO : Define `AnyBlockSparseMatrix`.
135
- function Base. getindex (a:: BlockSparseArrayLike{<:Any,2} , I:: Vararg{AbstractUnitRange,2} )
132
+ function Base. getindex (
133
+ a:: BlockSparseArrayLike{<:Any,2} , I:: Vararg{AbstractUnitRange{<:Integer},2}
134
+ )
136
135
return ArrayLayouts. layout_getindex (a, I... )
137
136
end
138
137
199
198
200
199
# Needed by `BlockArrays` matrix multiplication interface
201
200
function Base. similar (
202
- arraytype:: Type{<:BlockSparseArrayLike} , axes:: Tuple{Vararg{AbstractUnitRange}}
201
+ arraytype:: Type{<:BlockSparseArrayLike} , axes:: Tuple{Vararg{AbstractUnitRange{<:Integer} }}
203
202
)
204
203
return similar (arraytype, eltype (arraytype), axes)
205
204
end
@@ -210,53 +209,45 @@ end
210
209
# Delete once we drop support for older versions of Julia.
211
210
function Base. similar (
212
211
arraytype:: Type{<:BlockSparseArrayLike} ,
213
- axes:: Tuple{AbstractUnitRange,Vararg{AbstractUnitRange}} ,
214
- )
215
- return similar (arraytype, eltype (arraytype), axes)
216
- end
217
-
218
- # Needed by `BlockArrays` matrix multiplication interface
219
- # Fixes ambiguity error with `BlockArrays.jl`.
220
- function Base. similar (
221
- arraytype:: Type{<:BlockSparseArrayLike} ,
222
- axes:: Tuple{AbstractBlockedUnitRange,Vararg{AbstractUnitRange{Int}}} ,
212
+ axes:: Tuple{AbstractUnitRange{<:Integer},Vararg{AbstractUnitRange{<:Integer}}} ,
223
213
)
224
214
return similar (arraytype, eltype (arraytype), axes)
225
215
end
226
216
227
- # Needed by `BlockArrays` matrix multiplication interface
228
- # Fixes ambiguity error with `BlockArrays.jl`.
217
+ # Fixes ambiguity error with `BlockArrays`.
229
218
function Base. similar (
230
219
arraytype:: Type{<:BlockSparseArrayLike} ,
231
- axes:: Tuple {
232
- AbstractBlockedUnitRange,AbstractBlockedUnitRange,Vararg{AbstractUnitRange{Int}}
233
- },
220
+ axes:: Tuple{AbstractBlockedUnitRange{<:Integer},Vararg{AbstractUnitRange{<:Integer}}} ,
234
221
)
235
222
return similar (arraytype, eltype (arraytype), axes)
236
223
end
237
224
238
- # Needed by `BlockArrays` matrix multiplication interface
239
- # Fixes ambiguity error with `BlockArrays.jl`.
225
+ # Fixes ambiguity error with `BlockArrays`.
240
226
function Base. similar (
241
227
arraytype:: Type{<:BlockSparseArrayLike} ,
242
228
axes:: Tuple {
243
- AbstractUnitRange{Int},AbstractBlockedUnitRange,Vararg{AbstractUnitRange{Int}}
229
+ AbstractUnitRange{<: Integer },
230
+ AbstractBlockedUnitRange{<: Integer },
231
+ Vararg{AbstractUnitRange{<: Integer }},
244
232
},
245
233
)
246
234
return similar (arraytype, eltype (arraytype), axes)
247
235
end
248
236
249
237
# Needed for disambiguation
250
238
function Base. similar (
251
- arraytype:: Type{<:BlockSparseArrayLike} , axes:: Tuple{Vararg{AbstractBlockedUnitRange}}
239
+ arraytype:: Type{<:BlockSparseArrayLike} ,
240
+ axes:: Tuple{Vararg{AbstractBlockedUnitRange{<:Integer}}} ,
252
241
)
253
242
return similar (arraytype, eltype (arraytype), axes)
254
243
end
255
244
256
245
# Needed by `BlockArrays` matrix multiplication interface
257
246
# TODO : Define a `blocksparse_similar` function.
258
247
function Base. similar (
259
- arraytype:: Type{<:BlockSparseArrayLike} , elt:: Type , axes:: Tuple{Vararg{AbstractUnitRange}}
248
+ arraytype:: Type{<:BlockSparseArrayLike} ,
249
+ elt:: Type ,
250
+ axes:: Tuple{Vararg{AbstractUnitRange{<:Integer}}} ,
260
251
)
261
252
# TODO : Make generic for GPU, maybe using `blocktype`.
262
253
# TODO : For non-block axes this should output `Array`.
265
256
266
257
# TODO : Define a `blocksparse_similar` function.
267
258
function Base. similar (
268
- a:: BlockSparseArrayLike , elt:: Type , axes:: Tuple{Vararg{AbstractUnitRange}}
259
+ a:: BlockSparseArrayLike , elt:: Type , axes:: Tuple{Vararg{AbstractUnitRange{<:Integer} }}
269
260
)
270
261
# TODO : Make generic for GPU, maybe using `blocktype`.
271
262
# TODO : For non-block axes this should output `Array`.
277
268
function Base. similar (
278
269
a:: BlockSparseArrayLike ,
279
270
elt:: Type ,
280
- axes:: Tuple{AbstractBlockedUnitRange,Vararg{AbstractBlockedUnitRange}} ,
271
+ axes:: Tuple {
272
+ AbstractBlockedUnitRange{<: Integer },Vararg{AbstractBlockedUnitRange{<: Integer }}
273
+ },
281
274
)
282
275
# TODO : Make generic for GPU, maybe using `blocktype`.
283
276
# TODO : For non-block axes this should output `Array`.
@@ -289,13 +282,37 @@ end
289
282
function Base. similar (
290
283
a:: BlockSparseArrayLike ,
291
284
elt:: Type ,
292
- axes:: Tuple{AbstractUnitRange,Vararg{AbstractUnitRange}} ,
285
+ axes:: Tuple{AbstractUnitRange{<:Integer} ,Vararg{AbstractUnitRange{<:Integer} }} ,
293
286
)
294
287
# TODO : Make generic for GPU, maybe using `blocktype`.
295
288
# TODO : For non-block axes this should output `Array`.
296
289
return BlockSparseArray {elt} (undef, axes)
297
290
end
298
291
292
+ # Fixes ambiguity error with `BlockArrays`.
293
+ function Base. similar (
294
+ a:: BlockSparseArrayLike ,
295
+ elt:: Type ,
296
+ axes:: Tuple{AbstractBlockedUnitRange{<:Integer},Vararg{AbstractUnitRange{<:Integer}}} ,
297
+ )
298
+ # TODO : Make generic for GPU, maybe using `blocktype`.
299
+ # TODO : For non-block axes this should output `Array`.
300
+ return BlockSparseArray {elt} (undef, axes)
301
+ end
302
+
303
+ # Fixes ambiguity errors with BlockArrays.
304
+ function Base. similar (
305
+ a:: BlockSparseArrayLike ,
306
+ elt:: Type ,
307
+ axes:: Tuple {
308
+ AbstractUnitRange{<: Integer },
309
+ AbstractBlockedUnitRange{<: Integer },
310
+ Vararg{AbstractUnitRange{<: Integer }},
311
+ },
312
+ )
313
+ return BlockSparseArray {elt} (undef, axes)
314
+ end
315
+
299
316
# TODO : Define a `blocksparse_similar` function.
300
317
# Fixes ambiguity error with `StaticArrays`.
301
318
function Base. similar (
0 commit comments