Skip to content

Commit 6546108

Browse files
committed
Explicit loop in converting Bidiagonal to Matrix
1 parent a8fd121 commit 6546108

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/bidiag.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,20 @@ end
189189
#Converting from Bidiagonal to dense Matrix
190190
function Matrix{T}(A::Bidiagonal) where T
191191
B = Matrix{T}(undef, size(A))
192+
iszero(size(B,1)) && return B
192193
if haszero(T) # optimized path for types with zero(T) defined
193194
size(B,1) > 1 && fill!(B, zero(T))
194-
copyto!(diagview(B), A.dv)
195-
copyto!(diagview(B, _offdiagind(A.uplo)), A.ev)
195+
isupper = A.uplo == 'U'
196+
if isupper
197+
B[1,1] = A.dv[1]
198+
end
199+
for col in axes(A.ev,1)
200+
B[col+!isupper, col+isupper] = A.ev[col]
201+
B[col+isupper, col+isupper] = A.dv[col+isupper]
202+
end
203+
if !isupper
204+
B[end,end] = A.dv[end]
205+
end
196206
else
197207
copyto!(B, A)
198208
end

0 commit comments

Comments
 (0)