Skip to content

Commit 17c7dc8

Browse files
committed
Add tests for lower Bidiagonal
1 parent 897c8a7 commit 17c7dc8

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/diagonal.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ _copy_diag(M::T, ::T) where {T<:Lmul} = copyto!(_similar(M.B), M)
6565
_copy_diag(M, _) = copy(M)
6666
_bidiagonal(A::Bidiagonal) = A
6767
function _bidiagonal(A)
68+
# we assume that the matrix is indeed bidiagonal
6869
if iszero(view(A, diagind(A, -1)))
69-
Bidiagonal(A, :U)
70-
elseif iszero(view(A, diagind(A, 1)))
71-
Bidiagonal(A, :L)
70+
uplo = :U
7271
else
73-
throw(InexactError(:Bidiagonal, A))
72+
uplo = :L
7473
end
74+
Bidiagonal(A, uplo)
7575
end
7676
function copy(M::Rmul{<:BidiagonalLayout,<:DiagonalLayout})
7777
A = _bidiagonal(M.A)

test/test_layoutarray.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,24 @@ Base.copy(A::MyVector) = MyVector(copy(A.A))
338338

339339
@testset "Diagonal * Bidiagonal/Tridiagonal with structured diags" begin
340340
n = size(D,1)
341-
B = Bidiagonal(map(MyVector, (rand(n), rand(n-1)))..., :U)
342-
MB = MyMatrix(B)
341+
BU = Bidiagonal(map(MyVector, (rand(n), rand(n-1)))..., :U)
342+
MBU = MyMatrix(BU)
343+
BL = Bidiagonal(map(MyVector, (rand(n), rand(n-1)))..., :L)
344+
MBL = MyMatrix(BL)
343345
S = SymTridiagonal(map(MyVector, (rand(n), rand(n-1)))...)
344346
MS = MyMatrix(S)
345347
T = Tridiagonal(map(MyVector, (rand(n-1), rand(n), rand(n-1)))...)
346348
MT = MyMatrix(T)
347-
DA, BA, SA, TA = map(Array, (D, B, S, T))
349+
DA, BUA, BLA, SA, TA = map(Array, (D, BU, BL, S, T))
348350
if VERSION >= v"1.11"
349-
@test D * B DA * BA
350-
@test B * D BA * DA
351-
@test D * MB DA * BA
352-
@test MB * D BA * DA
351+
@test D * BU DA * BUA
352+
@test BU * D BUA * DA
353+
@test D * MBU DA * BUA
354+
@test MBU * D BUA * DA
355+
@test D * BL DA * BLA
356+
@test BL * D BLA * DA
357+
@test D * MBL DA * BLA
358+
@test MBL * D BLA * DA
353359
end
354360
if VERSION >= v"1.12.0-DEV.824"
355361
@test D * S DA * SA

0 commit comments

Comments
 (0)