1
1
using BlockArrays, BandedMatrices, BlockBandedMatrices, FillArrays, SparseArrays, Test, ArrayLayouts , LinearAlgebra
2
2
import BlockBandedMatrices: _BandedBlockBandedMatrix, blockcolsupport, blockrowsupport, colsupport, rowsupport,
3
3
isbandedblockbanded, bandeddata, BandedBlockBandedColumns
4
+ import ArrayLayouts: RangeCumsum
4
5
5
6
@testset " BandedBlockBandedMatrix" begin
6
7
@testset " constructors" begin
@@ -181,7 +182,7 @@ import BlockBandedMatrices: _BandedBlockBandedMatrix, blockcolsupport, blockrows
181
182
A = _BandedBlockBandedMatrix (data, rows,cols, (l,u), (λ,μ))
182
183
183
184
@test A[Block (1 ), Block (1 )] isa BandedMatrix
184
- @test A[Block (1 ), Block (1 )] == A[Block (1 ,1 )] == BlockArrays . getblock (A, 1 , 1 ) == BandedMatrix (view (A, Block (1 ,1 )))
185
+ @test A[Block (1 ), Block (1 )] == A[Block (1 ,1 )] == view (A, Block ( 1 , 1 ) ) == BandedMatrix (view (A, Block (1 ,1 )))
185
186
@test A[1 ,1 ] == view (A,Block (1 ),Block (1 ))[1 ,1 ] == view (A,Block (1 ,1 ))[1 ,1 ] == A[Block (1 ,1 )][1 ,1 ] == A[Block (1 ),Block (1 )][1 ,1 ] == 5
186
187
@test A[2 ,1 ] == view (A,Block (2 ),Block (1 ))[1 ,1 ] == view (A,Block (2 ,1 ))[1 ,1 ] == 8
187
188
@test A[3 ,1 ] == view (A,Block (2 ),Block (1 ))[2 ,1 ] == 9
@@ -454,20 +455,20 @@ import BlockBandedMatrices: _BandedBlockBandedMatrix, blockcolsupport, blockrows
454
455
A = BandedBlockBandedMatrix {Float64} (undef, 1 : 2 , 1 : 5 ,(- 1 ,1 ), (- 1 ,1 ))
455
456
A. data .= randn .()
456
457
V = view (A, Block (2 ,3 ))
457
- @test MemoryLayout (typeof (V)) == BandedMatrices. BandedColumnMajor ()
458
+ @test MemoryLayout (typeof (V)) == BandedMatrices. BandedColumns {ColumnMajor} ()
458
459
@test isbanded (V)
459
460
@test bandwidths (V) == (- 1 ,1 )
460
461
@test BandedMatrix (V) == A[2 : 3 ,4 : 6 ]
461
462
V2 = view (V, :, 2 : 3 )
462
- @test MemoryLayout (typeof (V2)) == BandedMatrices. BandedColumnMajor ()
463
+ @test MemoryLayout (typeof (V2)) == BandedMatrices. BandedColumns {ColumnMajor} ()
463
464
@test bandwidths (V2) == (0 ,0 )
464
465
@test BandedMatrix (V2) == A[2 : 3 ,5 : 6 ]
465
466
V2 = view (V, 2 : 2 , :)
466
- @test MemoryLayout (typeof (V2)) == BandedMatrices. BandedColumnMajor ()
467
+ @test MemoryLayout (typeof (V2)) == BandedMatrices. BandedColumns {ColumnMajor} ()
467
468
@test bandwidths (V2) == (- 2 ,2 )
468
469
@test BandedMatrix (V2) == A[3 : 3 ,4 : 6 ]
469
470
V2 = view (V, 2 : 2 , 2 : 3 )
470
- @test MemoryLayout (typeof (V2)) == BandedMatrices. BandedColumnMajor ()
471
+ @test MemoryLayout (typeof (V2)) == BandedMatrices. BandedColumns {ColumnMajor} ()
471
472
@test bandwidths (V2) == (- 1 ,1 )
472
473
@test BandedMatrix (V2) == A[3 : 3 ,5 : 6 ]
473
474
end
@@ -487,6 +488,22 @@ import BlockBandedMatrices: _BandedBlockBandedMatrix, blockcolsupport, blockrows
487
488
A = _BandedBlockBandedMatrix (PseudoBlockVector ([1 ,2 ,3 ],[1 ,2 ])' , blockedrange ([1 ,2 ]), (- 1 ,1 ), (- 1 ,1 ))
488
489
@test MemoryLayout (A) isa BandedBlockBandedColumns{RowMajor}
489
490
end
491
+
492
+ @testset " 1:N blocks" begin
493
+ N = 10
494
+ A = BandedBlockBandedMatrix {Float64} (undef, 1 : N,1 : N, (1 ,1 ), (1 ,1 ))
495
+ @test axes (A) isa NTuple{2 ,BlockedUnitRange{<: RangeCumsum }}
496
+ end
497
+
498
+ @testset " change bandwidths" begin
499
+ l , u = 1 ,1
500
+ λ , μ = 1 ,1
501
+ N = M = 4
502
+ cols = rows = 1 : N
503
+ data = reshape (collect (1 : (λ+ μ+ 1 )* (l+ u+ 1 )* sum (cols)), ((λ+ μ+ 1 )* (l+ u+ 1 ), sum (cols)))
504
+ A = _BandedBlockBandedMatrix (data, rows,cols, (l,u), (λ,μ))
505
+ @test A == BandedBlockBandedMatrix (A, (2 ,1 ), (2 ,1 )) == BandedBlockBandedMatrix {Float64} (A, (2 ,1 ), (2 ,1 ))
506
+ end
490
507
end
491
508
492
509
if false # turned off since tests have check-bounds=yes
0 commit comments