Skip to content

Commit bad2b2c

Browse files
committed
Rename the kept-column factors in svd_pullback! to Sₖ, Uₖ and Vᴴₖ
1 parent d4461d4 commit bad2b2c

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎src/pullbacks/svd.jl‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ function svd_pullback!(
178178

179179
# UᴴΔAV is nonzero only in its rows and columns ind′, which are UᴴΔAVₖ and UᴴΔAVʳ'. For k ≤ r / 2,
180180
# applying these two blocks directly, in O(m n k), is faster than forming UᴴΔAV.
181-
S′ = view(S, ind′)
182-
U′ = U[:, ind′]
183-
Vᴴ′ = Vᴴ[ind′, :] # this might be slightly confusion with adjoint
181+
Sₖ = view(S, ind′)
182+
Uₖ = U[:, ind′]
183+
Vᴴₖ = Vᴴ[ind′, :]
184184
if 2 * length(ind′) <= r
185185
UᴴΔAVʳ[ind′, :] .= zero(eltype(UᴴΔAVʳ)) # these entries are part of the columns ind′
186-
ΔA = mul!(ΔA, U₁ * UᴴΔAVₖ, Vᴴ′, 1, 1)
187-
ΔA = mul!(ΔA, U′, UᴴΔAVʳ' * V₁ᴴ, 1, 1)
186+
ΔA = mul!(ΔA, U₁ * UᴴΔAVₖ, Vᴴₖ, 1, 1)
187+
ΔA = mul!(ΔA, Uₖ, UᴴΔAVʳ' * V₁ᴴ, 1, 1)
188188
else
189189
if is_leading_index(ind′, r) # NOTE: all columns in order (e.g. `ind = Colon()`): the original path
190190
UᴴΔAV = UᴴΔAVₖ
@@ -198,12 +198,12 @@ function svd_pullback!(
198198

199199
# Add the remaining contributions
200200
if m > r && !iszerotangent(ΔU₊) # ΔU₁ is already orthogonal to U₁
201-
ΔU₊ ./= transpose(S′)
202-
ΔA = mul!(ΔA, ΔU₊, Vᴴ′, 1, 1)
201+
ΔU₊ ./= transpose(Sₖ)
202+
ΔA = mul!(ΔA, ΔU₊, Vᴴₖ, 1, 1)
203203
end
204204
if n > r && !iszerotangent(ΔV₊ᴴ) # ΔV₁ᴴ is already orthogonal to V₁ᴴ
205-
ΔV₊ᴴ .= S′ .\ ΔV₊ᴴ
206-
ΔA = mul!(ΔA, U′, ΔV₊ᴴ, 1, 1)
205+
ΔV₊ᴴ .= Sₖ .\ ΔV₊ᴴ
206+
ΔA = mul!(ΔA, Uₖ, ΔV₊ᴴ, 1, 1)
207207
end
208208
return ΔA
209209
end

0 commit comments

Comments
 (0)