Skip to content

Commit 6bb999c

Browse files
committed
Add tests
1 parent 3455cb3 commit 6bb999c

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

test/bidiag.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,9 +835,6 @@ end
835835
end
836836

837837
@testset "non-standard axes" begin
838-
LinearAlgebra.diagzero(T::Type, ax::Tuple{SizedArrays.SOneTo, Vararg{SizedArrays.SOneTo}}) =
839-
zeros(T, ax)
840-
841838
s = SizedArrays.SizedArray{(2,2)}([1 2; 3 4])
842839
B = Bidiagonal(fill(s,4), fill(s,3), :U)
843840
@test @inferred(B[2,1]) isa typeof(s)

test/tridiag.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,4 +1099,33 @@ end
10991099
@test opnorm(S, Inf) == opnorm(Matrix(S), Inf)
11001100
end
11011101

1102+
@testset "block-bidiagonal matrix indexing" begin
1103+
dv = [ones(4,3), ones(2,2).*2, ones(2,3).*3, ones(4,4).*4]
1104+
evu = [ones(4,2), ones(2,3).*2, ones(2,4).*3]
1105+
evl = [ones(2,3), ones(2,2).*2, ones(4,3).*3]
1106+
T = Tridiagonal(evl, dv, evu)
1107+
# check that all the matrices along a column have the same number of columns,
1108+
# and the matrices along a row have the same number of rows
1109+
for j in axes(T, 2), i in 2:size(T, 1)
1110+
@test size(T[i,j], 2) == size(T[1,j], 2)
1111+
@test size(T[i,j], 1) == size(T[i,1], 1)
1112+
if j < i-1 || j > i + 1
1113+
@test iszero(T[i,j])
1114+
end
1115+
end
1116+
1117+
@testset "non-standard axes" begin
1118+
s = SizedArrays.SizedArray{(2,2)}([1 2; 3 4])
1119+
T = Tridiagonal(fill(s,3), fill(s,4), fill(s,3))
1120+
@test @inferred(T[3,1]) isa typeof(s)
1121+
@test all(iszero, T[3,1])
1122+
end
1123+
1124+
# SymTridiagonal requires square diagonal blocks
1125+
dv = [fill(i, i, i) for i in 1:3]
1126+
ev = [ones(Int,1,2), ones(Int,2,3)]
1127+
S = SymTridiagonal(dv, ev)
1128+
@test S == Array{Matrix{Int}}(S)
1129+
end
1130+
11021131
end # module TestTridiagonal

0 commit comments

Comments
 (0)