|
11 | 11 | An `AbstractArray` can be repacked into a `BlockArray` with `BlockArray(array, block_sizes...)`. The block sizes are each an `AbstractVector{Int}` which determines the size of the blocks in that dimension (so the sum of `block_sizes` in every dimension must match the size of `array` in that dimension).
|
12 | 12 |
|
13 | 13 | ```jldoctest
|
14 |
| -julia> BlockArray(Array(reshape(1:16, 4, 4)), [1,3], [1,1,2]) |
| 14 | +julia> BlockArray(Array(reshape(1:16, 4, 4)), [2,2], [1,1,2]) |
15 | 15 | 2×3-blocked 4×4 BlockMatrix{Int64}:
|
16 | 16 | 1 │ 5 │ 9 13
|
17 |
| - ───┼─────┼──────── |
18 | 17 | 2 │ 6 │ 10 14
|
| 18 | + ───┼─────┼──────── |
19 | 19 | 3 │ 7 │ 11 15
|
20 | 20 | 4 │ 8 │ 12 16
|
21 | 21 |
|
@@ -138,36 +138,27 @@ julia> block_array[1, 2]
|
138 | 138 |
|
139 | 139 | To view and modify blocks of `BlockArray` use the `view` syntax.
|
140 | 140 | ```jldoctest
|
141 |
| -julia> A = BlockArray([11:16;], 1:3) |
142 |
| -3-blocked 6-element BlockVector{Int64, Vector{Vector{Int64}}, Tuple{BlockedOneTo{ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}: |
143 |
| - 11 |
144 |
| - ── |
145 |
| - 12 |
146 |
| - 13 |
147 |
| - ── |
148 |
| - 14 |
149 |
| - 15 |
150 |
| - 16 |
| 141 | +julia> A = BlockArray(ones(6), 1:3); |
151 | 142 |
|
152 | 143 | julia> view(A, Block(2))
|
153 |
| -2-element Vector{Int64}: |
154 |
| - 12 |
155 |
| - 13 |
156 |
| -
|
157 |
| -julia> view(A, Block(2)) .= [3,4]; |
| 144 | +2-element Vector{Float64}: |
| 145 | + 1.0 |
| 146 | + 1.0 |
158 | 147 |
|
159 |
| -julia> A[Block(2)] |
160 |
| -2-element Vector{Int64}: |
161 |
| - 3 |
162 |
| - 4 |
| 148 | +julia> view(A, Block(2)) .= [3,4]; A[Block(2)] |
| 149 | +2-element Vector{Float64}: |
| 150 | + 3.0 |
| 151 | + 4.0 |
163 | 152 |
|
164 | 153 | julia> view(A, Block.(1:2))
|
165 |
| -3-element view(::BlockVector{Int64, Vector{Vector{Int64}}, Tuple{BlockedOneTo{ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}, BlockSlice(BlockRange(1:2),1:1:3)) with eltype Int64 with indices BlockedOneTo([1, 3]): |
166 |
| - 11 |
167 |
| - 3 |
168 |
| - 4 |
| 154 | +3-element view(::BlockVector{Float64, Vector{Vector{Float64}}, Tuple{BlockedOneTo{ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}, BlockSlice(BlockRange(1:2),1:1:3)) with eltype Float64 with indices BlockedOneTo([1, 3]): |
| 155 | + 1.0 |
| 156 | + 3.0 |
| 157 | + 4.0 |
169 | 158 | ```
|
170 | 159 |
|
| 160 | + |
| 161 | + |
171 | 162 | ## Converting between `BlockArray` and normal arrays
|
172 | 163 |
|
173 | 164 | An array can be repacked into a `BlockArray` with `BlockArray(array, block_sizes...)`:
|
|
0 commit comments