Skip to content

Commit 24f5e21

Browse files
authored
Backports to release v1.12 (#1429)
- [x] #1428
2 parents b5a8bb0 + aefcbfa commit 24f5e21

File tree

3 files changed

+24
-46
lines changed

3 files changed

+24
-46
lines changed

src/tridiag.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ function _opnorm1Inf(A::Tridiagonal, p)
11091109
case = p == Inf
11101110
lowerrange, upperrange = case ? (1:length(A.dl)-1, 2:length(A.dl)) : (2:length(A.dl), 1:length(A.dl)-1)
11111111
normfirst, normend = case ? (norm(first(A.d))+norm(first(A.du)), norm(last(A.dl))+norm(last(A.d))) : (norm(first(A.d))+norm(first(A.dl)), norm(last(A.du))+norm(last(A.d)))
1112-
1112+
size(A, 1) == 2 && return max(normfirst, normend)
11131113
return max(
11141114
mapreduce(t -> sum(norm, t),
11151115
max,
@@ -1124,7 +1124,7 @@ function _opnorm1Inf(A::SymTridiagonal, p::Real)
11241124
size(A, 1) == 1 && return norm(first(A.dv))
11251125
lowerrange, upperrange = 1:length(A.ev)-1, 2:length(A.ev)
11261126
normfirst, normend = norm(first(A.dv))+norm(first(A.ev)), norm(last(A.ev))+norm(last(A.dv))
1127-
1127+
size(A, 1) == 2 && return max(normfirst, normend)
11281128
return max(
11291129
mapreduce(t -> sum(norm, t),
11301130
max,

test/bidiag.jl

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,29 +1139,17 @@ end
11391139
end
11401140

11411141
@testset "opnorms" begin
1142-
B = Bidiagonal([1,-2,3,-4], [1,2,3], 'U')
1143-
1144-
@test opnorm(B, 1) == opnorm(Matrix(B), 1)
1145-
@test opnorm(B, 2) opnorm(Matrix(B), 2)
1146-
@test opnorm(B, Inf) == opnorm(Matrix(B), Inf)
1147-
1148-
B = Bidiagonal([1,-2,3,-4], [1,2,3], 'L')
1149-
1150-
@test opnorm(B, 1) == opnorm(Matrix(B), 1)
1151-
@test opnorm(B, 2) opnorm(Matrix(B), 2)
1152-
@test opnorm(B, Inf) == opnorm(Matrix(B), Inf)
1153-
1154-
B = Bidiagonal([2], Int[], 'L')
1155-
1156-
@test opnorm(B, 1) == opnorm(Matrix(B), 1)
1157-
@test opnorm(B, 2) opnorm(Matrix(B), 2)
1158-
@test opnorm(B, Inf) == opnorm(Matrix(B), Inf)
1159-
1160-
B = Bidiagonal([2], Int[], 'U')
1161-
1162-
@test opnorm(B, 1) == opnorm(Matrix(B), 1)
1163-
@test opnorm(B, 2) opnorm(Matrix(B), 2)
1164-
@test opnorm(B, Inf) == opnorm(Matrix(B), Inf)
1142+
for B in (Bidiagonal([1,-2,3,-4], [1,2,3], 'U'),
1143+
Bidiagonal([1,-2,3,-4], [1,2,3], 'L'),
1144+
Bidiagonal([2], Int[], 'L'),
1145+
Bidiagonal([2], Int[], 'U'),
1146+
Bidiagonal([1,-2], [-4], 'U'),
1147+
Bidiagonal([1,-2], [-4], 'L')
1148+
)
1149+
@test opnorm(B, 1) == opnorm(Matrix(B), 1)
1150+
@test opnorm(B, 2) opnorm(Matrix(B), 2)
1151+
@test opnorm(B, Inf) == opnorm(Matrix(B), Inf)
1152+
end
11651153
end
11661154

11671155
end # module TestBidiagonal

test/tridiag.jl

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,27 +1078,17 @@ end
10781078
end
10791079

10801080
@testset "opnorms" begin
1081-
T = Tridiagonal([1,2,3], [1,-2,3,-4], [1,2,3])
1082-
1083-
@test opnorm(T, 1) == opnorm(Matrix(T), 1)
1084-
@test_skip opnorm(T, 2) opnorm(Matrix(T), 2) # currently missing
1085-
@test opnorm(T, Inf) == opnorm(Matrix(T), Inf)
1086-
1087-
S = SymTridiagonal([1,-2,3,-4], [1,2,3])
1088-
1089-
@test opnorm(S, 1) == opnorm(Matrix(S), 1)
1090-
@test_skip opnorm(S, 2) opnorm(Matrix(S), 2) # currently missing
1091-
@test opnorm(S, Inf) == opnorm(Matrix(S), Inf)
1092-
1093-
T = Tridiagonal(Int[], [-5], Int[])
1094-
@test opnorm(T, 1) == opnorm(Matrix(T), 1)
1095-
@test_skip opnorm(T, 2) opnorm(Matrix(T), 2) # currently missing
1096-
@test opnorm(T, Inf) == opnorm(Matrix(T), Inf)
1097-
1098-
S = SymTridiagonal(T)
1099-
@test opnorm(S, 1) == opnorm(Matrix(S), 1)
1100-
@test_skip opnorm(S, 2) opnorm(Matrix(S), 2) # currently missing
1101-
@test opnorm(S, Inf) == opnorm(Matrix(S), Inf)
1081+
for T in (Tridiagonal([1,2,3], [1,-2,3,-4], [1,2,3]),
1082+
SymTridiagonal([1,-2,3,-4], [1,2,3]),
1083+
Tridiagonal(Int[], [-5], Int[]),
1084+
SymTridiagonal([-5], Int[]),
1085+
Tridiagonal([1], [1,-2], [3]),
1086+
SymTridiagonal([1,-2], [3])
1087+
)
1088+
@test opnorm(T, 1) == opnorm(Matrix(T), 1)
1089+
@test_skip opnorm(T, 2) opnorm(Matrix(T), 2) # currently missing
1090+
@test opnorm(T, Inf) == opnorm(Matrix(T), Inf)
1091+
end
11021092
end
11031093

11041094
end # module TestTridiagonal

0 commit comments

Comments
 (0)