@@ -54,6 +54,12 @@ function _allocate_svd_output(A::AbstractBlockSparseMatrix, full::Bool, ::Algori
5454 S = similar (A, real (eltype (A)), s_axis)
5555 Vt = similar (A, s_axis, axes (A, 2 ))
5656
57+ # also fill in identities for blocks that aren't present
58+ for (row, col) in zip (emptyrows, emptycols)
59+ copyto! (@view! (U[Block (row, col)]), LinearAlgebra. I)
60+ copyto! (@view! (Vt[Block (col, col)]), LinearAlgebra. I)
61+ end
62+
5763 return U, S, Vt
5864end
5965
@@ -74,19 +80,5 @@ function svd!(
7480 Vt[bcol, bcol] = bUSV. Vt
7581 end
7682
77- # fill in values for blocks that aren't present, pairing them in order of occurence
78- block_inds_S = eachblockstoredindex (S)
79- i = findfirst (∉ (block_inds_S), blockaxes (S, 1 ))
80- bIs = collect (eachblockstoredindex (U))
81- browIs = Int .(first .(Tuple .(bIs)))
82- emptyrows = findall (∉ (browIs), 1 : blocksize (U, 1 ))
83- j = 0
84- while ! isnothing (i)
85- copyto! (@view! (Vt[Block (i, i)]), LinearAlgebra. I)
86- j += 1
87- copyto! (@view! (U[Block (emptyrows[j], i)]), LinearAlgebra. I)
88- i = findnext (∉ (block_inds_S), blockaxes (S, 1 ), i + 1 )
89- end
90-
9183 return SVD (U, S, Vt)
9284end
0 commit comments