|
1 | 1 | using BlockArrays:
|
2 |
| - Block, BlockIndex, BlockedArray, BlockedVector, block, blockedrange, blockindex, mortar |
3 |
| -using BlockSparseArrays: BlockSparseArrays, BlockIndexVector, GenericBlockIndex |
| 2 | + Block, |
| 3 | + BlockIndex, |
| 4 | + BlockSlice, |
| 5 | + BlockedArray, |
| 6 | + BlockedVector, |
| 7 | + block, |
| 8 | + blockedrange, |
| 9 | + blockindex, |
| 10 | + mortar |
| 11 | +using BlockSparseArrays: |
| 12 | + BlockSparseArrays, |
| 13 | + BlockIndexVector, |
| 14 | + BlockIndices, |
| 15 | + GenericBlockIndex, |
| 16 | + blocksparsezeros, |
| 17 | + blockedunitrange_getindices, |
| 18 | + to_block, |
| 19 | + to_block_indices, |
| 20 | + to_blockindexrange |
4 | 21 | using Test: @test, @test_broken, @testset
|
5 | 22 |
|
6 | 23 | # blockrange
|
@@ -157,4 +174,111 @@ using Test: @test, @test_broken, @testset
|
157 | 174 | i = GenericBlockIndex(Block(2), 2)
|
158 | 175 | @test to_indices(a, (i, i)) == (4, 4)
|
159 | 176 | @test to_indices(a, axes(a), (i, i)) == (4, 4)
|
| 177 | + |
| 178 | + r = blockedrange([2, 3]) |
| 179 | + i = mortar([BlockIndexVector(Block(2), [1, 3]), BlockIndexVector(Block(1), [2])]) |
| 180 | + @test blockedunitrange_getindices(r, i) == mortar([[3, 5], [2]]) |
| 181 | + |
| 182 | + r = blockedrange([2, 3]) |
| 183 | + T = GenericBlockIndex{1,Tuple{Int},Tuple{Int}} |
| 184 | + i = mortar([ |
| 185 | + BlockIndexVector{1,T}(Block(2), [1, 3]), BlockIndexVector{1,T}(Block(1), [2]) |
| 186 | + ]) |
| 187 | + @test blockedunitrange_getindices(r, i) == mortar([[3, 5], [2]]) |
| 188 | + |
| 189 | + # Internal functions. |
| 190 | + @test to_block(Block(2)) === Block(2) |
| 191 | + @test to_block(Block(2)[2:3]) === Block(2) |
| 192 | + @test to_block(BlockIndexVector(Block(2), [1, 3])) === Block(2) |
| 193 | + @test to_block_indices(Block(2)) === (:) |
| 194 | + @test to_block_indices(Block(2)[2:3]) === 2:3 |
| 195 | + @test to_block_indices(BlockIndexVector(Block(2), [1, 3])) == [1, 3] |
| 196 | + |
| 197 | + a = blocksparsezeros([2, 3], [2, 3]) |
| 198 | + i = Block(2)[2:3] |
| 199 | + @test to_indices(a, (i, i)) === |
| 200 | + to_indices(a, axes(a), (i, i)) === |
| 201 | + (BlockSlice(i, 4:5), BlockSlice(i, 4:5)) |
| 202 | + |
| 203 | + a = blocksparsezeros([2, 3], [2, 3]) |
| 204 | + i = mortar([Block(2)[2:3], Block(1)[2:2]]) |
| 205 | + for I in (to_indices(a, (i, i)), to_indices(a, axes(a), (i, i))) |
| 206 | + for Iⱼ in I |
| 207 | + @test Iⱼ == BlockIndices(i, mortar([4:5, 2:2])) |
| 208 | + @test Iⱼ isa BlockIndices |
| 209 | + @test Iⱼ.blocks == i |
| 210 | + @test Iⱼ.indices == mortar([4:5, 2:2]) |
| 211 | + end |
| 212 | + end |
| 213 | + |
| 214 | + a = blocksparsezeros([2, 3], [2, 3]) |
| 215 | + i = BlockIndexVector(Block(2), [1, 3]) |
| 216 | + for I in (to_indices(a, (i, i)), to_indices(a, axes(a), (i, i))) |
| 217 | + for Iⱼ in I |
| 218 | + @test Iⱼ == BlockIndices(i, [3, 5]) |
| 219 | + @test Iⱼ isa BlockIndices |
| 220 | + @test Iⱼ.blocks == i |
| 221 | + @test Iⱼ.indices == [3, 5] |
| 222 | + end |
| 223 | + end |
| 224 | + |
| 225 | + a = blocksparsezeros([2, 3], [2, 3]) |
| 226 | + T = GenericBlockIndex{1,Tuple{Int},Tuple{Int}} |
| 227 | + i = BlockIndexVector{1,T}(Block(2), [1, 3]) |
| 228 | + for I in (to_indices(a, (i, i)), to_indices(a, axes(a), (i, i))) |
| 229 | + for Iⱼ in I |
| 230 | + @test Iⱼ == BlockIndices(i, [3, 5]) |
| 231 | + @test Iⱼ isa BlockIndices |
| 232 | + @test Iⱼ.blocks == i |
| 233 | + @test Iⱼ.indices == [3, 5] |
| 234 | + end |
| 235 | + end |
| 236 | + |
| 237 | + a = blocksparsezeros([2, 3], [2, 3]) |
| 238 | + i = mortar([BlockIndexVector(Block(2), [1, 3]), BlockIndexVector(Block(1), [2])]) |
| 239 | + for I in (to_indices(a, (i, i)), to_indices(a, axes(a), (i, i))) |
| 240 | + for Iⱼ in I |
| 241 | + @test Iⱼ == BlockIndices(i, mortar([[3, 5], [2]])) |
| 242 | + @test Iⱼ isa BlockIndices |
| 243 | + @test Iⱼ.blocks == i |
| 244 | + @test Iⱼ.indices == mortar([[3, 5], [2]]) |
| 245 | + end |
| 246 | + end |
| 247 | + |
| 248 | + a = blocksparsezeros([2, 3], [2, 3]) |
| 249 | + i = [BlockIndexVector(Block(2), [1, 3]), BlockIndexVector(Block(1), [2])] |
| 250 | + for I in (to_indices(a, (i, i)), to_indices(a, axes(a), (i, i))) |
| 251 | + for Iⱼ in I |
| 252 | + @test Iⱼ == BlockIndices(mortar(i), mortar([[3, 5], [2]])) |
| 253 | + @test Iⱼ isa BlockIndices |
| 254 | + @test Iⱼ.blocks == mortar(i) |
| 255 | + @test Iⱼ.indices == mortar([[3, 5], [2]]) |
| 256 | + end |
| 257 | + end |
| 258 | + |
| 259 | + a = blocksparsezeros([2, 3], [2, 3]) |
| 260 | + T = GenericBlockIndex{1,Tuple{Int},Tuple{Int}} |
| 261 | + i = mortar([ |
| 262 | + BlockIndexVector{1,T}(Block(2), [1, 3]), BlockIndexVector{1,T}(Block(1), [2]) |
| 263 | + ]) |
| 264 | + for I in (to_indices(a, (i, i)), to_indices(a, axes(a), (i, i))) |
| 265 | + for Iⱼ in I |
| 266 | + @test Iⱼ == BlockIndices(i, mortar([[3, 5], [2]])) |
| 267 | + @test Iⱼ isa BlockIndices |
| 268 | + @test Iⱼ.blocks == i |
| 269 | + @test Iⱼ.indices == mortar([[3, 5], [2]]) |
| 270 | + end |
| 271 | + end |
| 272 | + |
| 273 | + a = blocksparsezeros([2, 3], [2, 3]) |
| 274 | + T = GenericBlockIndex{1,Tuple{Int},Tuple{Int}} |
| 275 | + i = [BlockIndexVector{1,T}(Block(2), [1, 3]), BlockIndexVector{1,T}(Block(1), [2])] |
| 276 | + for I in (to_indices(a, (i, i)), to_indices(a, axes(a), (i, i))) |
| 277 | + for Iⱼ in I |
| 278 | + @test Iⱼ == BlockIndices(mortar(i), mortar([[3, 5], [2]])) |
| 279 | + @test Iⱼ isa BlockIndices |
| 280 | + @test Iⱼ.blocks == mortar(i) |
| 281 | + @test Iⱼ.indices == mortar([[3, 5], [2]]) |
| 282 | + end |
| 283 | + end |
160 | 284 | end
|
0 commit comments