@@ -120,19 +120,18 @@ blocktype(a::BlockSparseArrayLike) = eltype(blocks(a))
120120blocktype (arraytype:: Type{<:BlockSparseArrayLike} ) = eltype (blockstype (arraytype))
121121
122122using 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
126123function Base. getindex (a:: BlockSparseArrayLike{<:Any,N} , I:: CartesianIndices{N} ) where {N}
127124 return ArrayLayouts. layout_getindex (a, I)
128125end
129126function Base. getindex (
130- a:: BlockSparseArrayLike{<:Any,N} , I:: Vararg{AbstractUnitRange,N}
127+ a:: BlockSparseArrayLike{<:Any,N} , I:: Vararg{AbstractUnitRange{<:Integer} ,N}
131128) where {N}
132129 return ArrayLayouts. layout_getindex (a, I... )
133130end
134131# 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+ )
136135 return ArrayLayouts. layout_getindex (a, I... )
137136end
138137
199198
200199# Needed by `BlockArrays` matrix multiplication interface
201200function Base. similar (
202- arraytype:: Type{<:BlockSparseArrayLike} , axes:: Tuple{Vararg{AbstractUnitRange}}
201+ arraytype:: Type{<:BlockSparseArrayLike} , axes:: Tuple{Vararg{AbstractUnitRange{<:Integer} }}
203202)
204203 return similar (arraytype, eltype (arraytype), axes)
205204end
@@ -210,53 +209,45 @@ end
210209# Delete once we drop support for older versions of Julia.
211210function Base. similar (
212211 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}}} ,
223213)
224214 return similar (arraytype, eltype (arraytype), axes)
225215end
226216
227- # Needed by `BlockArrays` matrix multiplication interface
228- # Fixes ambiguity error with `BlockArrays.jl`.
217+ # Fixes ambiguity error with `BlockArrays`.
229218function Base. similar (
230219 arraytype:: Type{<:BlockSparseArrayLike} ,
231- axes:: Tuple {
232- AbstractBlockedUnitRange,AbstractBlockedUnitRange,Vararg{AbstractUnitRange{Int}}
233- },
220+ axes:: Tuple{AbstractBlockedUnitRange{<:Integer},Vararg{AbstractUnitRange{<:Integer}}} ,
234221)
235222 return similar (arraytype, eltype (arraytype), axes)
236223end
237224
238- # Needed by `BlockArrays` matrix multiplication interface
239- # Fixes ambiguity error with `BlockArrays.jl`.
225+ # Fixes ambiguity error with `BlockArrays`.
240226function Base. similar (
241227 arraytype:: Type{<:BlockSparseArrayLike} ,
242228 axes:: Tuple {
243- AbstractUnitRange{Int},AbstractBlockedUnitRange,Vararg{AbstractUnitRange{Int}}
229+ AbstractUnitRange{<: Integer },
230+ AbstractBlockedUnitRange{<: Integer },
231+ Vararg{AbstractUnitRange{<: Integer }},
244232 },
245233)
246234 return similar (arraytype, eltype (arraytype), axes)
247235end
248236
249237# Needed for disambiguation
250238function Base. similar (
251- arraytype:: Type{<:BlockSparseArrayLike} , axes:: Tuple{Vararg{AbstractBlockedUnitRange}}
239+ arraytype:: Type{<:BlockSparseArrayLike} ,
240+ axes:: Tuple{Vararg{AbstractBlockedUnitRange{<:Integer}}} ,
252241)
253242 return similar (arraytype, eltype (arraytype), axes)
254243end
255244
256245# Needed by `BlockArrays` matrix multiplication interface
257246# TODO : Define a `blocksparse_similar` function.
258247function 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}}} ,
260251)
261252 # TODO : Make generic for GPU, maybe using `blocktype`.
262253 # TODO : For non-block axes this should output `Array`.
265256
266257# TODO : Define a `blocksparse_similar` function.
267258function Base. similar (
268- a:: BlockSparseArrayLike , elt:: Type , axes:: Tuple{Vararg{AbstractUnitRange}}
259+ a:: BlockSparseArrayLike , elt:: Type , axes:: Tuple{Vararg{AbstractUnitRange{<:Integer} }}
269260)
270261 # TODO : Make generic for GPU, maybe using `blocktype`.
271262 # TODO : For non-block axes this should output `Array`.
277268function Base. similar (
278269 a:: BlockSparseArrayLike ,
279270 elt:: Type ,
280- axes:: Tuple{AbstractBlockedUnitRange,Vararg{AbstractBlockedUnitRange}} ,
271+ axes:: Tuple {
272+ AbstractBlockedUnitRange{<: Integer },Vararg{AbstractBlockedUnitRange{<: Integer }}
273+ },
281274)
282275 # TODO : Make generic for GPU, maybe using `blocktype`.
283276 # TODO : For non-block axes this should output `Array`.
@@ -289,13 +282,37 @@ end
289282function Base. similar (
290283 a:: BlockSparseArrayLike ,
291284 elt:: Type ,
292- axes:: Tuple{AbstractUnitRange,Vararg{AbstractUnitRange}} ,
285+ axes:: Tuple{AbstractUnitRange{<:Integer} ,Vararg{AbstractUnitRange{<:Integer} }} ,
293286)
294287 # TODO : Make generic for GPU, maybe using `blocktype`.
295288 # TODO : For non-block axes this should output `Array`.
296289 return BlockSparseArray {elt} (undef, axes)
297290end
298291
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+
299316# TODO : Define a `blocksparse_similar` function.
300317# Fixes ambiguity error with `StaticArrays`.
301318function Base. similar (
0 commit comments