@@ -141,21 +141,21 @@ julia> a[BlockIndex((2,2), (2,3))]
14114120
142142```
143143"""
144- struct BlockIndex{N}
145- I:: NTuple{N, Int}
146- α:: NTuple{N, Int}
144+ struct BlockIndex{N,TI <: Tuple{Vararg{Integer,N}} ,Tα <: Tuple{Vararg{Integer,N}} }
145+ I:: TI
146+ α:: T α
147147end
148148
149149@inline BlockIndex (a:: NTuple{N,Block{1}} , b:: Tuple ) where N = BlockIndex (Int .(a), b)
150150
151- @inline BlockIndex (a:: Int , b:: Int ) = BlockIndex ((a,), (b,))
152- @inline BlockIndex (a:: Tuple , b:: Int ) = BlockIndex (a, (b,))
153- @inline BlockIndex (a:: Int , b:: Tuple ) = BlockIndex ((a,), b)
151+ @inline BlockIndex (a:: Integer , b:: Integer ) = BlockIndex ((a,), (b,))
152+ @inline BlockIndex (a:: Tuple , b:: Integer ) = BlockIndex (a, (b,))
153+ @inline BlockIndex (a:: Integer , b:: Tuple ) = BlockIndex ((a,), b)
154154
155155@inline BlockIndex (a:: Block , b:: Tuple ) = BlockIndex (a. n, b)
156- @inline BlockIndex (a:: Block , b:: Int ) = BlockIndex (a, (b,))
156+ @inline BlockIndex (a:: Block , b:: Integer ) = BlockIndex (a, (b,))
157157
158- @inline function BlockIndex (I:: NTuple{N, Int} , α:: NTuple{M, Int } ) where {M,N}
158+ @inline function BlockIndex (I:: Tuple{Vararg{Integer,N}} , α:: Tuple{Vararg{Integer,M} } ) where {M,N}
159159 M <= N || throw (ArgumentError (" number of indices must not exceed the number of blocks" ))
160160 α2 = ntuple (k -> k <= M ? α[k] : 1 , N)
161161 BlockIndex (I, α2)
164164block (b:: BlockIndex ) = Block (b. I... )
165165blockindex (b:: BlockIndex{1} ) = b. α[1 ]
166166
167- BlockIndex (indcs:: NTuple{N, BlockIndex{1}} ) where N = BlockIndex (block .(indcs), blockindex .(indcs))
167+ BlockIndex (indcs:: Tuple{Vararg{ BlockIndex{1},N }} ) where N = BlockIndex (block .(indcs), blockindex .(indcs))
168168
169169# #
170170# checkindex
@@ -178,7 +178,7 @@ BlockIndex(indcs::NTuple{N,BlockIndex{1}}) where N = BlockIndex(block.(indcs), b
178178 checkbounds (Bool, B, blockindex (I)... )
179179end
180180
181- checkbounds (:: Type{Bool} , A:: AbstractArray{<:Any,N} , I:: AbstractVector{BlockIndex{N}} ) where N =
181+ checkbounds (:: Type{Bool} , A:: AbstractArray{<:Any,N} , I:: AbstractVector{<: BlockIndex{N}} ) where N =
182182 all (checkbounds .(Bool, Ref (A), I))
183183
184184struct BlockIndexRange{N,R<: Tuple{Vararg{AbstractUnitRange{<:Integer}}} } <: AbstractArray{BlockIndex{N},N}
@@ -285,7 +285,7 @@ _indices(B) = B
285285Block (bs:: BlockSlice{<:BlockIndexRange} ) = Block (bs. block)
286286
287287
288- struct BlockRange{N,R<: NTuple{N,AbstractUnitRange{Int }} } <: AbstractArray{Block{N,Int},N}
288+ struct BlockRange{N,R<: NTuple{N,AbstractUnitRange{<:Integer }} } <: AbstractArray{Block{N,Int},N}
289289 indices:: R
290290 BlockRange {N,R} (inds:: R ) where {N,R} = new {N,R} (inds)
291291end
@@ -330,9 +330,9 @@ function BlockRange(inds::Tuple{BlockRange,Vararg{BlockRange}})
330330 BlockRange (combine_indices (inds))
331331end
332332
333- BlockRange (inds:: Tuple{Vararg{AbstractUnitRange{Int }}} ) =
333+ BlockRange (inds:: Tuple{Vararg{AbstractUnitRange{<:Integer }}} ) =
334334 BlockRange {length(inds),typeof(inds)} (inds)
335- BlockRange (inds:: Vararg{AbstractUnitRange{Int }} ) = BlockRange (inds)
335+ BlockRange (inds:: Vararg{AbstractUnitRange{<:Integer }} ) = BlockRange (inds)
336336
337337BlockRange () = BlockRange (())
338338BlockRange (sizes:: Tuple{Integer, Vararg{Integer}} ) = BlockRange (map (oneto, sizes))
@@ -343,8 +343,8 @@ BlockRange(B::AbstractArray) = BlockRange(blockaxes(B))
343343(:)(start:: Block{1} , stop:: Block{1} ) = BlockRange ((first (start. n): first (stop. n),))
344344(:)(start:: Block , stop:: Block ) = throw (ArgumentError (" Use `BlockRange` to construct a cartesian range of blocks" ))
345345broadcasted (:: DefaultArrayStyle{1} , :: Type{Block} , r:: AbstractUnitRange ) = BlockRange ((r,))
346- broadcasted (:: DefaultArrayStyle{1} , :: Type{Int } , block_range:: BlockRange{1} ) = first (block_range. indices)
347- broadcasted (:: DefaultArrayStyle{0} , :: Type{Int } , block:: Block{1} ) = Int (block)
346+ broadcasted (:: DefaultArrayStyle{1} , :: Type{<:Integer } , block_range:: BlockRange{1} ) = first (block_range. indices)
347+ broadcasted (:: DefaultArrayStyle{0} , type :: Type{<:Integer } , block:: Block{1} ) = type (block)
348348
349349
350350# AbstractArray implementation
0 commit comments