@@ -74,21 +74,21 @@ _blocklengths2blocklasts(blocks::Fill) = cumsum(blocks)
74
74
_blocklengths2blocklasts (blocks:: Ones ) = cumsum (blocks)
75
75
@inline blockedrange (blocks:: Union{Tuple,AbstractVector} ) = _BlockedUnitRange (_blocklengths2blocklasts (blocks))
76
76
77
- @inline blockfirsts (a:: BlockedUnitRange ) = [a . first; @views (a . lasts [1 : end - 1 ]) .+ 1 ]
77
+ @inline blockfirsts (a:: BlockedUnitRange ) = [first (a) ; @views (blocklasts (a) [1 : end - 1 ]) .+ 1 ]
78
78
# optimize common cases
79
- @inline function blockfirsts (a:: BlockedUnitRange{<:Integer, <: Union{Vector, RangeCumsum{<:Any, <:UnitRange}}} )
80
- v = Vector {eltype(a)} (undef, length (a . lasts ))
81
- v[1 ] = a . first
82
- v[2 : end ] .= @views (a . lasts [oneto (end - 1 )]) .+ 1
79
+ @inline function blockfirsts (a:: BlockedUnitRange{<:Union{Vector, RangeCumsum{<:Any, <:UnitRange}}} )
80
+ v = Vector {eltype(a)} (undef, length (blocklasts (a) ))
81
+ v[1 ] = first (a)
82
+ v[2 : end ] .= @views (blocklasts (a) [oneto (end - 1 )]) .+ 1
83
83
return v
84
84
end
85
85
@inline blocklasts (a:: BlockedUnitRange ) = a. lasts
86
86
87
87
_diff (a:: AbstractVector ) = diff (a)
88
88
_diff (a:: Tuple ) = diff (collect (a))
89
- @inline blocklengths (a:: BlockedUnitRange ) = isempty (a . lasts) ? [_diff (a . lasts) ;] : [first (a . lasts) - a . first+ one (eltype (a)); _diff (a . lasts )]
89
+ @inline blocklengths (a:: BlockedUnitRange ) = isempty (blocklasts (a)) ? [_diff (blocklasts (a)) ;] : [first (blocklasts (a)) - first (a) + one (eltype (a)); _diff (blocklasts (a) )]
90
90
91
- length (a:: BlockedUnitRange ) = isempty (a . lasts) ? zero (eltype (a)) : Integer (last (a . lasts) - a . first+ one (eltype (a)))
91
+ length (a:: BlockedUnitRange ) = isempty (blocklasts (a)) ? zero (eltype (a)) : Integer (last (blocklasts (a)) - first (a) + one (eltype (a)))
92
92
93
93
"""
94
94
blockisequal(a::AbstractUnitRange{Int}, b::AbstractUnitRange{Int})
@@ -142,7 +142,7 @@ Base.unitrange(b::BlockedUnitRange) = first(b):last(b)
142
142
Base. promote_rule (:: Type{BlockedUnitRange{T, CS}} , :: Type{Base.OneTo{Int}} ) where {T, CS} = UnitRange{T}
143
143
144
144
"""
145
- blockaxes(A)
145
+ blockaxes(A::AbstractArray )
146
146
147
147
Return the tuple of valid block indices for array `A`.
148
148
@@ -169,19 +169,19 @@ julia> blockaxes(B)
169
169
(BlockRange(Base.OneTo(2)), BlockRange(Base.OneTo(3)))
170
170
```
171
171
"""
172
- blockaxes (b:: BlockedUnitRange ) = _blockaxes (b . lasts )
172
+ blockaxes (b:: BlockedUnitRange ) = _blockaxes (blocklasts (b) )
173
173
_blockaxes (b:: AbstractVector ) = (Block .(axes (b,1 )),)
174
174
_blockaxes (b:: Tuple ) = (Block .(Base. OneTo (length (b))),)
175
175
blockaxes (b) = blockaxes .(axes (b), 1 )
176
176
177
177
"""
178
- blockaxes(A, d)
178
+ blockaxes(A::AbstractArray , d::Int )
179
179
180
180
Return the valid range of block indices for array `A` along dimension `d`.
181
181
182
182
# Examples
183
183
```jldoctest
184
- julia> A = BlockArray([1,2,3],[2,1])
184
+ julia> A = BlockArray([1,2,3], [2,1])
185
185
2-blocked 3-element BlockVector{Int64}:
186
186
1
187
187
2
@@ -202,8 +202,8 @@ julia> blockaxes(A,1) |> collect
202
202
end
203
203
204
204
"""
205
- blocksize(A)
206
- blocksize(A,i )
205
+ blocksize(A::AbstractArray )
206
+ blocksize(A::AbstractArray, i::Int )
207
207
208
208
Return the tuple of the number of blocks along each
209
209
dimension. See also size and blocksizes.
@@ -229,8 +229,8 @@ blocksize(A,i) = length(blockaxes(A,i))
229
229
@inline blocklength (t) = prod (blocksize (t))
230
230
231
231
"""
232
- blocksizes(A)
233
- blocksizes(A,i )
232
+ blocksizes(A::AbstractArray )
233
+ blocksizes(A::AbstractArray, i::Int )
234
234
235
235
Return the tuple of the sizes of blocks along each
236
236
dimension. See also size and blocksize.
@@ -352,8 +352,8 @@ Return the first index of each block of `a`.
352
352
353
353
# Examples
354
354
```jldoctest
355
- julia> b = blockedrange(1:3 )
356
- 3-blocked 6-element BlockedUnitRange{Int64, ArrayLayouts.RangeCumsum {Int64, UnitRange{Int64} }}:
355
+ julia> b = blockedrange([1,2,3] )
356
+ 3-blocked 6-element BlockedUnitRange{Int64, Vector {Int64}}:
357
357
1
358
358
─
359
359
2
@@ -378,8 +378,8 @@ Return the last index of each block of `a`.
378
378
379
379
# Examples
380
380
```jldoctest
381
- julia> b = blockedrange(1:3 )
382
- 3-blocked 6-element BlockedUnitRange{Int64, ArrayLayouts.RangeCumsum {Int64, UnitRange{Int64} }}:
381
+ julia> b = blockedrange([1,2,3] )
382
+ 3-blocked 6-element BlockedUnitRange{Int64, Vector {Int64}}:
383
383
1
384
384
─
385
385
2
@@ -390,7 +390,7 @@ julia> b = blockedrange(1:3)
390
390
6
391
391
392
392
julia> blocklasts(b)
393
- 3-element ArrayLayouts.RangeCumsum {Int64, UnitRange{Int64} }:
393
+ 3-element Vector {Int64}:
394
394
1
395
395
3
396
396
6
@@ -404,8 +404,8 @@ Return the length of each block of `a`.
404
404
405
405
# Examples
406
406
```jldoctest
407
- julia> b = blockedrange(1:3 )
408
- 3-blocked 6-element BlockedUnitRange{Int64, ArrayLayouts.RangeCumsum {Int64, UnitRange{Int64} }}:
407
+ julia> b = blockedrange([1,2,3] )
408
+ 3-blocked 6-element BlockedUnitRange{Int64, Vector {Int64}}:
409
409
1
410
410
─
411
411
2
@@ -453,24 +453,24 @@ Base.BroadcastStyle(::Type{BlockedUnitRange{T, R}}) where {T, R} = Base.Broadcas
453
453
454
454
_blocklengths2blocklasts (blocks:: AbstractRange ) = RangeCumsum (blocks)
455
455
function blockfirsts (a:: BlockedUnitRange{<:Integer, <:Base.OneTo} )
456
- a . first == 1 || error (" Offset axes not supported" )
457
- Base. OneTo {eltype(a)} (length (a . lasts ))
456
+ first (a) == 1 || error (" Offset axes not supported" )
457
+ Base. OneTo {eltype(a)} (length (blocklasts (a) ))
458
458
end
459
459
function blocklengths (a:: BlockedUnitRange{<:Integer, <:Base.OneTo} )
460
- a . first == 1 || error (" Offset axes not supported" )
461
- Ones {eltype(a)} (length (a . lasts ))
460
+ first (a) == 1 || error (" Offset axes not supported" )
461
+ Ones {eltype(a)} (length (blocklasts (a) ))
462
462
end
463
463
function blockfirsts (a:: BlockedUnitRange{<:Integer, <:AbstractRange} )
464
- st = step (a . lasts )
465
- a . first == 1 || error (" Offset axes not supported" )
466
- @assert first (a . lasts) - a . first+ 1 == st
467
- range (one (eltype (a)); step= st, length= eltype (a)(length (a . lasts )))
464
+ st = step (blocklasts (a) )
465
+ first (a) == 1 || error (" Offset axes not supported" )
466
+ @assert first (blocklasts (a)) - first (a) + 1 == st
467
+ range (one (eltype (a)); step= st, length= eltype (a)(length (blocklasts (a) )))
468
468
end
469
469
function blocklengths (a:: BlockedUnitRange{<:Integer, <:AbstractRange} )
470
- st = step (a . lasts )
471
- a . first == 1 || error (" Offset axes not supported" )
472
- @assert first (a . lasts) - a . first+ 1 == st
473
- Fill (st,length (a . lasts ))
470
+ st = step (blocklasts (a) )
471
+ first (a) == 1 || error (" Offset axes not supported" )
472
+ @assert first (blocklasts (a)) - first (a) + 1 == st
473
+ Fill (st,length (blocklasts (a) ))
474
474
end
475
475
476
476
0 commit comments