Skip to content

Commit abbd086

Browse files
committed
Avoid copy in empty bidiag ldiv!
1 parent 5d3ef46 commit abbd086

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/bidiag.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,19 +1250,17 @@ end
12501250
ldiv!(A::Bidiagonal, b::AbstractVecOrMat) = @inline ldiv!(b, A, b)
12511251
function ldiv!(c::AbstractVecOrMat, A::Bidiagonal, b::AbstractVecOrMat)
12521252
require_one_based_indexing(c, A, b)
1253-
N = size(A, 2)
1253+
N = size(A, 1)
12541254
mb, nb = size(b, 1), size(b, 2)
12551255
if N != mb
1256-
throw(DimensionMismatch(lazy"second dimension of A, $N, does not match first dimension of b, $mb"))
1256+
throw(DimensionMismatch(lazy"first dimension of A, $N, does not match first dimension of b, $mb"))
12571257
end
12581258
mc, nc = size(c, 1), size(c, 2)
12591259
if mc != mb || nc != nb
1260-
throw(DimensionMismatch(lazy"size of result, ($mc, $nc), does not match the size of b, ($mb, $nb)"))
1260+
throw(DimensionMismatch(lazy"size of result, $(size(c)), does not match the size of b, $(size(b))"))
12611261
end
12621262

1263-
if N == 0
1264-
return copyto!(c, b)
1265-
end
1263+
N == 0 && return c # in this case c and b are also empty
12661264

12671265
zi = findfirst(iszero, A.dv)
12681266
isnothing(zi) || throw(SingularException(zi))

0 commit comments

Comments
 (0)