Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1250,19 +1250,19 @@ end
ldiv!(A::Bidiagonal, b::AbstractVecOrMat) = @inline ldiv!(b, A, b)
function ldiv!(c::AbstractVecOrMat, A::Bidiagonal, b::AbstractVecOrMat)
require_one_based_indexing(c, A, b)
N = size(A, 2)
N = size(A, 1)
mb, nb = size(b, 1), size(b, 2)
if N != mb
throw(DimensionMismatch(lazy"second dimension of A, $N, does not match first dimension of b, $mb"))
dimstr = b isa AbstractVector ? "length" : "first dimension"
throw(DimensionMismatch(LazyString(lazy"the first dimension of the Bidiagonal matrix, $N, ",
lazy"does not match the $dimstr of the right-hand-side, $mb")))
end
mc, nc = size(c, 1), size(c, 2)
if mc != mb || nc != nb
throw(DimensionMismatch(lazy"size of result, ($mc, $nc), does not match the size of b, ($mb, $nb)"))
throw(DimensionMismatch(lazy"size of result, $(size(c)), does not match the size of b, $(size(b))"))
end

if N == 0
return copyto!(c, b)
end
N == 0 && return c # in this case c and b are also empty

zi = findfirst(iszero, A.dv)
isnothing(zi) || throw(SingularException(zi))
Expand Down
11 changes: 11 additions & 0 deletions test/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1180,4 +1180,15 @@ end
@test !isreal(im*M)
end

@testset "ldiv! error message" begin
C = zeros(2)
B = Bidiagonal(1:0, 1:0, :U)
msg = "size of result, (2,), does not match the size of b, (0, 1)"
@test_throws msg ldiv!(C, B, zeros(0,1))
msg = "the first dimension of the Bidiagonal matrix, 0, does not match the length of the right-hand-side, 2"
@test_throws msg ldiv!(C, B, zeros(2))
msg = "the first dimension of the Bidiagonal matrix, 0, does not match the first dimension of the right-hand-side, 2"
@test_throws msg ldiv!(C, B, zeros(2,1))
end

end # module TestBidiagonal