Open
Description
For example:
julia> using BlockArrays
julia> using BlockArrays: BlockDiagonal
julia> using LinearAlgebra
julia> pkgversion(BlockArrays)
v"1.1.1"
julia> pkgversion(LinearAlgebra)
v"1.11.0"
julia> A = BlockDiagonal([randn(2, 2), randn(2, 2)])
2×2-blocked 4×4 BlockMatrix{Float64, Diagonal{Matrix{Float64}, Vector{Matrix{Float64}}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}}}:
-1.73455 1.11785 │ ⋅ ⋅
-0.99245 -0.549115 │ ⋅ ⋅
─────────────────────┼───────────────────────
⋅ ⋅ │ -0.285518 -0.592538
⋅ ⋅ │ -0.0665603 0.425891
julia> D = Diagonal(BlockedVector([1, 2, 3, 4], [2, 2]))
4×4 Diagonal{Int64, BlockedVector{Int64, Vector{Int64}, Tuple{BlockedOneTo{Int64, Vector{Int64}}}}} with indices BlockedOneTo([2, 4])×BlockedOneTo([2, 4]):
1 ⋅ │ ⋅ ⋅
⋅ 2 │ ⋅ ⋅
──────┼──────
⋅ ⋅ │ 3 ⋅
⋅ ⋅ │ ⋅ 4
julia> A * D
ERROR: BoundsError: attempt to access 1-element Base.OneTo{Int64} at index [1:2]
Stacktrace:
[1] throw_boundserror(A::Base.OneTo{Int64}, I::Tuple{UnitRange{Int64}})
@ Base ./essentials.jl:14
[2] checkbounds
@ ./abstractarray.jl:699 [inlined]
[3] getindex
@ ./range.jl:973 [inlined]
[4] getindex
@ ~/.julia/packages/BlockArrays/VccC2/src/blockaxis.jl:10 [inlined]
[5] unblock
@ ~/.julia/packages/BlockArrays/VccC2/src/views.jl:10 [inlined]
[6] to_indices
@ ~/.julia/packages/BlockArrays/VccC2/src/views.jl:29 [inlined]
[7] to_indices
@ ~/.julia/packages/BlockArrays/VccC2/src/views.jl:44 [inlined]
[8] view
@ ./subarray.jl:213 [inlined]
[9] _bview
@ ~/.julia/packages/BlockArrays/VccC2/src/blockbroadcast.jl:124 [inlined]
[10] (::BlockArrays.var"#56#61"{Base.Broadcast.Broadcasted{…}, Tuple{…}})(i::Int64)
@ BlockArrays ~/.julia/packages/BlockArrays/VccC2/src/blockbroadcast.jl:156
[11] ntuple
@ ./ntuple.jl:19 [inlined]
[12] _generic_blockbroadcast_copyto!(dest::BlockMatrix{…}, bc::Base.Broadcast.Broadcasted{…})
@ BlockArrays ~/.julia/packages/BlockArrays/VccC2/src/blockbroadcast.jl:156
[13] copyto!(dest::BlockMatrix{…}, bc::Base.Broadcast.Broadcasted{…})
@ BlockArrays ~/.julia/packages/BlockArrays/VccC2/src/blockbroadcast.jl:163
[14] copy
@ ./broadcast.jl:892 [inlined]
[15] materialize
@ ./broadcast.jl:867 [inlined]
[16] copy(M::ArrayLayouts.Rmul{BlockArrays.BlockLayout{…}, ArrayLayouts.DiagonalLayout{…}, BlockMatrix{…}, Diagonal{…}})
@ ArrayLayouts ~/.julia/packages/ArrayLayouts/48qDX/src/diagonal.jl:20
[17] copy
@ ~/.julia/packages/ArrayLayouts/48qDX/src/mul.jl:140 [inlined]
[18] materialize
@ ~/.julia/packages/ArrayLayouts/48qDX/src/mul.jl:137 [inlined]
[19] mul
@ ~/.julia/packages/ArrayLayouts/48qDX/src/mul.jl:138 [inlined]
[20] *(A::BlockMatrix{Float64, Diagonal{…}, Tuple{…}}, B::Diagonal{Int64, BlockedVector{…}})
@ ArrayLayouts ~/.julia/packages/ArrayLayouts/48qDX/src/ArrayLayouts.jl:225
[21] top-level scope
@ REPL[32]:1
Some type information was truncated. Use `show(err)` to see complete types.
julia> D * A
ERROR: BoundsError: attempt to access 2-blocked 4-element BlockedVector{Int64} at index [BlockSlice(Block(1)[1:2],1:2), BlockSlice(Block(1)[1:2],Base.OneTo(2))]
Stacktrace:
[1] throw_boundserror(A::BlockedVector{…}, I::Tuple{…})
@ Base ./essentials.jl:14
[2] checkbounds
@ ./abstractarray.jl:699 [inlined]
[3] view
@ ./subarray.jl:214 [inlined]
[4] _bview
@ ~/.julia/packages/BlockArrays/VccC2/src/blockbroadcast.jl:124 [inlined]
[5] (::BlockArrays.var"#56#61"{Base.Broadcast.Broadcasted{…}, Tuple{…}})(i::Int64)
@ BlockArrays ~/.julia/packages/BlockArrays/VccC2/src/blockbroadcast.jl:156
[6] ntuple
@ ./ntuple.jl:19 [inlined]
[7] _generic_blockbroadcast_copyto!(dest::BlockMatrix{…}, bc::Base.Broadcast.Broadcasted{…})
@ BlockArrays ~/.julia/packages/BlockArrays/VccC2/src/blockbroadcast.jl:156
[8] copyto!
@ ~/.julia/packages/BlockArrays/VccC2/src/blockbroadcast.jl:163 [inlined]
[9] copy
@ ./broadcast.jl:892 [inlined]
[10] materialize
@ ./broadcast.jl:867 [inlined]
[11] copy
@ ~/.julia/packages/ArrayLayouts/48qDX/src/diagonal.jl:19 [inlined]
[12] copy
@ ~/.julia/packages/ArrayLayouts/48qDX/src/mul.jl:140 [inlined]
[13] materialize
@ ~/.julia/packages/ArrayLayouts/48qDX/src/mul.jl:137 [inlined]
[14] mul
@ ~/.julia/packages/ArrayLayouts/48qDX/src/mul.jl:138 [inlined]
[15] *(A::Diagonal{Int64, BlockedVector{…}}, B::BlockMatrix{Float64, Diagonal{…}, Tuple{…}})
@ ArrayLayouts ~/.julia/packages/ArrayLayouts/48qDX/src/ArrayLayouts.jl:224
[16] top-level scope
@ REPL[33]:1
Some type information was truncated. Use `show(err)` to see complete types.
julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 10 × Apple M1 Max
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Metadata
Metadata
Assignees
Labels
No labels