Skip to content

Commit c34f093

Browse files
committed
attempt to fix
1 parent 7a73cc0 commit c34f093

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/factorizations/svd.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ function MatrixAlgebraKit.initialize_output(
6868
# this is a convention, which at least gives the expected results for blockdiagonal
6969
emptyrows = setdiff(1:bm, browIs)
7070
emptycols = setdiff(1:bn, bcolIs)
71-
for (row, col) in zip(emptyrows, emptycols)
72-
s_axes[col] = infimum(brows[row], bcols[col])
71+
for (I, (row, col)) in enumerate(zip(emptyrows, emptycols))
72+
s_axes[I + length(bIs)] = infimum(brows[row], bcols[col])
7373
end
7474

7575
s_axis = mortar_axis(s_axes)
@@ -88,9 +88,9 @@ function MatrixAlgebraKit.initialize_output(
8888
end
8989

9090
# allocate output for blocks that aren't present -- do we also fill identities here?
91-
for (row, col) in zip(emptyrows, emptycols)
92-
@view!(U[Block(row, col)])
93-
@view!(Vt[Block(col, col)])
91+
for (I, (row, col)) in enumerate(zip(emptyrows, emptycols))
92+
@view!(U[Block(row, I + length(bIs))])
93+
@view!(Vt[Block(I + length(bIs), col)])
9494
end
9595

9696
return U, S, Vt
@@ -117,7 +117,7 @@ function MatrixAlgebraKit.initialize_output(
117117
v_axes = similar(bcols, bn)
118118

119119
# fill in values for blocks that are present
120-
bIs = sort!(collect(eachblockstoredindex(A)), by=Int last Tuple)
120+
bIs = sort!(collect(eachblockstoredindex(A)); by=Int last Tuple)
121121
browIs = Int.(first.(Tuple.(bIs)))
122122
bcolIs = Int.(last.(Tuple.(bIs)))
123123
for (I, bI) in enumerate(bIs)
@@ -132,9 +132,9 @@ function MatrixAlgebraKit.initialize_output(
132132
u_axes[length(bIs) .+ (1:length(emptyrows))] .= brows[emptyrows]
133133
emptycols = setdiff(1:bn, bcolIs)
134134
v_axes[length(bIs) .+ (1:length(emptycols))] .= bcols[emptycols]
135-
135+
136136
u_axis = mortar_axis(u_axes)
137-
v_axis = mortar_axis(@show v_axes)
137+
v_axis = mortar_axis(v_axes)
138138
S_axes = (u_axis, v_axis)
139139
U, S, Vt = similar_output(svd_full!, A, S_axes, alg)
140140

@@ -151,12 +151,12 @@ function MatrixAlgebraKit.initialize_output(
151151

152152
# allocate output for blocks that aren't present -- do we also fill identities here?
153153
for (I, row) in enumerate(emptyrows)
154-
@view!(U[Block(row, I)])
154+
@view!(U[Block(row, length(bIs) + I)])
155155
end
156156
for (I, col) in enumerate(emptycols)
157-
@view!(Vt[Block(I, col)])
157+
@view!(Vt[Block(length(bIs) + I, col)])
158158
end
159-
159+
160160
return U, S, Vt
161161
end
162162

@@ -210,9 +210,9 @@ function MatrixAlgebraKit.svd_compact!(
210210
# needs copyto! instead because size(::LinearAlgebra.I) doesn't work
211211
# U[Block(row, col)] = LinearAlgebra.I
212212
# Vᴴ[Block(col, col)] = LinearAlgebra.I
213-
for (row, col) in zip(emptyrows, emptycols)
214-
copyto!(@view!(U[Block(row, col)]), LinearAlgebra.I)
215-
copyto!(@view!(Vᴴ[Block(col, col)]), LinearAlgebra.I)
213+
for (I, (row, col)) in enumerate(zip(emptyrows, emptycols))
214+
copyto!(@view!(U[Block(row, I + length(bIs))]), LinearAlgebra.I)
215+
copyto!(@view!(Vᴴ[Block(I + length(bIs), col)]), LinearAlgebra.I)
216216
end
217217

218218
return (U, S, Vᴴ)

0 commit comments

Comments
 (0)