Skip to content

Commit c53b555

Browse files
committed
Update test_infbanded.jl
1 parent 90393ad commit c53b555

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

test/test_infbanded.jl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
8282
T = Tridiagonal(Fill(1,∞), Fill(2,∞), Fill(3,∞))
8383
@test T isa TriToeplitz
8484
@test (T + 2I)[1:10,1:10] == (2I + T)[1:10,1:10] == T[1:10,1:10] + 2I
85+
86+
S = SymTridiagonal(Fill(1,∞), Fill(2,∞))
87+
@test (S + 2I)[1:10,1:10] == (2I + S)[1:10,1:10] == S[1:10,1:10] + 2I
8588
end
8689

8790
@testset "constant data" begin
@@ -103,6 +106,11 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
103106
@test simplifiable(*, D, A) == Val(true)
104107
@test simplifiable(*, A, D) == Val(true)
105108
end
109+
110+
@testset "change bands" begin
111+
A = SymTridiagonal(Fill(2,∞), Fill(1,∞))
112+
@test BandedMatrix(A, (3,1))[1:5,1:5] == A[1:5,1:5]
113+
end
106114
end
107115

108116
@testset "Pert-Toeplitz" begin
@@ -133,7 +141,6 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
133141
@test (Adjoint(A) + 2I)[1:10,1:10] == (2I + Adjoint(A))[1:10,1:10] == Adjoint(A)[1:10,1:10] + 2I
134142
end
135143

136-
137144
@testset "InfBanded" begin
138145
A = _BandedMatrix(Fill(2,4,∞),ℵ₀,2,1)
139146
B = _BandedMatrix(Fill(3,2,∞),ℵ₀,-1,2)
@@ -142,6 +149,11 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
142149
@test (A*A)[1:20,1:20] == A[1:20,1:23]*A[1:23,1:20]
143150
@test (A*B)[1:20,1:20] == A[1:20,1:23]*B[1:23,1:20]
144151
end
152+
153+
@testset "change bands" begin
154+
A = BandedMatrix(-2 => Vcat(Float64[], Fill(1/4,∞)), 0 => Vcat([1.0+im,2,3],Fill(0,∞)), 1 => Vcat(Float64[], Fill(1,∞)))
155+
@test BandedMatrix(A, (3,1))[1:5,1:5] == A[1:5,1:5]
156+
end
145157
end
146158

147159
@testset "adjortrans" begin
@@ -199,6 +211,14 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
199211

200212
A = BandedMatrix{Int}((2 => Vcat([1,2], Fill(2,∞)),), (∞,∞), (0,2))
201213
@test A[band(2)][1:5] == [1; fill(2,4)]
214+
@test A[band(4)] Zeros{Int}(∞)
215+
end
216+
217+
@testset "prepad with fill" begin
218+
A = BandedMatrix(2 => Zeros(∞))
219+
@test A[band(2)][1:10] == Zeros(10)
220+
A = BandedMatrix(2 => Ones(∞))
221+
@test A[band(2)][1:10] == Ones(10)
202222
end
203223

204224
@testset "Algebra" begin
@@ -311,5 +331,4 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
311331
@test bandwidths(A + B) == (0, 1)
312332
@test bandwidths(2 * (A + B)) == (0, 1)
313333
end
314-
315334
end

0 commit comments

Comments
 (0)