JuliaArrays / JuliaArrays/BlockArrays.jl
Linear indexing into block arrays
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 254
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
This issue relates to #168, where linear indices in a BlockIndex led to a stack overflow.
A question that arises is whether linear indexing should be supported and if so, how. Currently, there is this behaviour:
julia> using BlockArrays
A = [1 2; 3 4]
julia> A = [1 2; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> A[Block(1,1)]
2×2 Array{Int64,2}:
1 2
3 4
julia> A[Block(1)]
2-element Array{Int64,1}:
1
3
julia> A[Block(2)]
ERROR: BlockBoundsError: attempt to access 2-element Base.OneTo{Int64} at block index [2]
Indexing a matrix with Block(1) yields the first column only, but Block(2) does not yield the second column. The blocksize of the matrix is 1 indicating that A[Block(1)] == A may be more consistent. But that would be an incompatible change.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing issue #168 and the current BlockIndex behavior shown in the examples. Compare the semantics of A[Block(1)] and A[Block(2)] with the matrix blocksize, then determine whether linear indexing should be supported and whether compatibility constrains the choice. Done means the intended indexing behavior and its compatibility implications are resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100