@@ -54,6 +54,12 @@ function _allocate_svd_output(A::AbstractBlockSparseMatrix, full::Bool, ::Algori
54
54
S = similar (A, real (eltype (A)), s_axis)
55
55
Vt = similar (A, s_axis, axes (A, 2 ))
56
56
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
+
57
63
return U, S, Vt
58
64
end
59
65
@@ -74,19 +80,5 @@ function svd!(
74
80
Vt[bcol, bcol] = bUSV. Vt
75
81
end
76
82
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
-
91
83
return SVD (U, S, Vt)
92
84
end
0 commit comments