Skip to content

Commit ec570c6

Browse files
committed
increase coverage
1 parent 04bb12c commit ec570c6

File tree

2 files changed

+41
-31
lines changed

2 files changed

+41
-31
lines changed

src/banded/infbanded.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ for op in (:-, :+)
207207
function $op::UniformScaling, A::PertToeplitz{V}) where V
208208
l,u = bandwidths(A)
209209
TV = promote_type(eltype(λ),V)
210-
a, t = convert.(AbstractVector{TV}, A.data.args)
210+
a, t = map(AbstractArray{TV}, A.data.args)
211211
b = $op.(t.args[1])
212-
a[u+1,:] += λ.λ
212+
a[u+1,:] .+= λ.λ
213213
b[u+1] += λ.λ
214214
_BandedMatrix(Hcat(a, b*Ones{TV}(1,∞)), ℵ₀, l, u)
215215
end

test/runtests.jl

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,44 @@ import LazyBandedMatrices: BroadcastBandedBlockBandedLayout, BroadcastBandedLayo
3636

3737
@test B*A*x isa Vcat
3838
@test (B*A*x)[1:10] == [0; 10; 14; 12; zeros(6)]
39+
40+
@test _BandedMatrix((1:∞)', ∞, -1, 1) isa BandedMatrix
41+
42+
@testset "∞-Toeplitz" begin
43+
A = BandedMatrix(1 => Fill(2im,∞), 2 => Fill(-1,∞), 3 => Fill(2,∞), -2 => Fill(-4,∞), -3 => Fill(-2im,∞))
44+
@test A isa InfToeplitz
45+
@test MemoryLayout(typeof(A.data)) == ConstRows()
46+
@test MemoryLayout(typeof(A)) == BandedToeplitzLayout()
47+
V = view(A,:,3:∞)
48+
@test MemoryLayout(typeof(bandeddata(V))) == ConstRows()
49+
@test MemoryLayout(typeof(V)) == BandedToeplitzLayout()
50+
@test BandedMatrix(V) isa InfToeplitz
51+
@test A[:,3:end] isa InfToeplitz
52+
53+
@test (A + 2I)[1:10,1:10] == (2I + A)[1:10,1:10] == A[1:10,1:10] + 2I
54+
end
55+
56+
@testset "Pert-Toeplitz" begin
57+
A = BandedMatrix(-2 => Vcat(Float64[], Fill(1/4,∞)), 0 => Vcat([1.0+im,2,3],Fill(0,∞)), 1 => Vcat(Float64[], Fill(1,∞)))
58+
@test A isa PertToeplitz
59+
@test MemoryLayout(typeof(A)) == PertToeplitzLayout()
60+
V = view(A,2:∞,2:∞)
61+
@test MemoryLayout(typeof(V)) == PertToeplitzLayout()
62+
@test BandedMatrix(V) isa PertToeplitz
63+
@test A[2:∞,2:∞] isa PertToeplitz
64+
65+
@test (A + 2I)[1:10,1:10] == (2I + A)[1:10,1:10] == A[1:10,1:10] + 2I
66+
67+
68+
@testset "InfBanded" begin
69+
A = _BandedMatrix(Fill(2,4,∞),ℵ₀,2,1)
70+
B = _BandedMatrix(Fill(3,2,∞),ℵ₀,-1,2)
71+
@test mul(A,A) isa PertToeplitz
72+
@test A*A isa PertToeplitz
73+
@test (A*A)[1:20,1:20] == A[1:20,1:23]*A[1:23,1:20]
74+
@test (A*B)[1:20,1:20] == A[1:20,1:23]*B[1:23,1:20]
75+
end
76+
end
3977
end
4078

4179
@testset "∞-block arrays" begin
@@ -184,35 +222,7 @@ end
184222
end
185223
end
186224

187-
@testset "∞-Toeplitz and Pert-Toeplitz" begin
188-
A = BandedMatrix(1 => Fill(2im,∞), 2 => Fill(-1,∞), 3 => Fill(2,∞), -2 => Fill(-4,∞), -3 => Fill(-2im,∞))
189-
@test A isa InfToeplitz
190-
@test MemoryLayout(typeof(A.data)) == ConstRows()
191-
@test MemoryLayout(typeof(A)) == BandedToeplitzLayout()
192-
V = view(A,:,3:∞)
193-
@test MemoryLayout(typeof(bandeddata(V))) == ConstRows()
194-
@test MemoryLayout(typeof(V)) == BandedToeplitzLayout()
195-
196-
@test BandedMatrix(V) isa InfToeplitz
197-
@test A[:,3:end] isa InfToeplitz
198-
199-
A = BandedMatrix(-2 => Vcat(Float64[], Fill(1/4,∞)), 0 => Vcat([1.0+im,2,3],Fill(0,∞)), 1 => Vcat(Float64[], Fill(1,∞)))
200-
@test A isa PertToeplitz
201-
@test MemoryLayout(typeof(A)) == PertToeplitzLayout()
202-
V = view(A,2:∞,2:∞)
203-
@test MemoryLayout(typeof(V)) == PertToeplitzLayout()
204-
@test BandedMatrix(V) isa PertToeplitz
205-
@test A[2:∞,2:∞] isa PertToeplitz
206-
207-
@testset "InfBanded" begin
208-
A = _BandedMatrix(Fill(2,4,∞),ℵ₀,2,1)
209-
B = _BandedMatrix(Fill(3,2,∞),ℵ₀,-1,2)
210-
@test mul(A,A) isa PertToeplitz
211-
@test A*A isa PertToeplitz
212-
@test (A*A)[1:20,1:20] == A[1:20,1:23]*A[1:23,1:20]
213-
@test (A*B)[1:20,1:20] == A[1:20,1:23]*B[1:23,1:20]
214-
end
215-
end
225+
216226

217227
@testset "Algebra" begin
218228
@testset "BandedMatrix" begin

0 commit comments

Comments
 (0)