-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
A single firsts field should work, where the last index of the range is firsts[end]-1. The advantages are:
- The codes will become cleaner and the performance can be better. There are currently many conditional statements on the first block. The proposed definition eliminates them.
- The type stability can be improved. Now
blocklengths(::BlockUnitRange{<:AbstractUnitRange})is clearly aFillandblocklengths(::BlockUnitRange{<:AbstractRange})is aVcat(::Int,::Fill). reference:BlockArrays.jl/src/blockaxis.jl
Lines 449 to 468 in 2c86412
function blockfirsts(a::BlockedUnitRange{Base.OneTo{Int}}) first(a) == 1 || error("Offset axes not supported") Base.OneTo{Int}(length(blocklasts(a))) end function blocklengths(a::BlockedUnitRange{Base.OneTo{Int}}) first(a) == 1 || error("Offset axes not supported") Ones{Int}(length(blocklasts(a))) end function blockfirsts(a::BlockedUnitRange{<:AbstractRange}) st = step(blocklasts(a)) first(a) == 1 || error("Offset axes not supported") @assert first(blocklasts(a))-first(a)+1 == st range(1; step=st, length=length(blocklasts(a))) end function blocklengths(a::BlockedUnitRange{<:AbstractRange}) st = step(blocklasts(a)) first(a) == 1 || error("Offset axes not supported") @assert first(blocklasts(a))-first(a)+1 == st Fill(st,length(blocklasts(a))) end
Metadata
Metadata
Assignees
Labels
No labels