Skip to content

Commit

Permalink
Update test_infbanded.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Nov 29, 2024
1 parent 90393ad commit c53b555
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/test_infbanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
T = Tridiagonal(Fill(1,∞), Fill(2,∞), Fill(3,∞))
@test T isa TriToeplitz
@test (T + 2I)[1:10,1:10] == (2I + T)[1:10,1:10] == T[1:10,1:10] + 2I

S = SymTridiagonal(Fill(1,∞), Fill(2,∞))
@test (S + 2I)[1:10,1:10] == (2I + S)[1:10,1:10] == S[1:10,1:10] + 2I
end

@testset "constant data" begin
Expand All @@ -103,6 +106,11 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
@test simplifiable(*, D, A) == Val(true)
@test simplifiable(*, A, D) == Val(true)
end

@testset "change bands" begin
A = SymTridiagonal(Fill(2,∞), Fill(1,∞))
@test BandedMatrix(A, (3,1))[1:5,1:5] == A[1:5,1:5]
end
end

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


@testset "InfBanded" begin
A = _BandedMatrix(Fill(2,4,∞),ℵ₀,2,1)
B = _BandedMatrix(Fill(3,2,∞),ℵ₀,-1,2)
Expand All @@ -142,6 +149,11 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
@test (A*A)[1:20,1:20] == A[1:20,1:23]*A[1:23,1:20]
@test (A*B)[1:20,1:20] == A[1:20,1:23]*B[1:23,1:20]
end

@testset "change bands" begin
A = BandedMatrix(-2 => Vcat(Float64[], Fill(1/4,∞)), 0 => Vcat([1.0+im,2,3],Fill(0,∞)), 1 => Vcat(Float64[], Fill(1,∞)))
@test BandedMatrix(A, (3,1))[1:5,1:5] == A[1:5,1:5]
end
end

@testset "adjortrans" begin
Expand Down Expand Up @@ -199,6 +211,14 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout

A = BandedMatrix{Int}((2 => Vcat([1,2], Fill(2,∞)),), (∞,∞), (0,2))
@test A[band(2)][1:5] == [1; fill(2,4)]
@test A[band(4)] Zeros{Int}(∞)
end

@testset "prepad with fill" begin
A = BandedMatrix(2 => Zeros(∞))
@test A[band(2)][1:10] == Zeros(10)
A = BandedMatrix(2 => Ones(∞))
@test A[band(2)][1:10] == Ones(10)
end

@testset "Algebra" begin
Expand Down Expand Up @@ -311,5 +331,4 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
@test bandwidths(A + B) == (0, 1)
@test bandwidths(2 * (A + B)) == (0, 1)
end

end

0 comments on commit c53b555

Please sign in to comment.