Skip to content

Commit b9bb9d5

Browse files
author
Katharine Hyatt
committed
Fixup svd pullback
1 parent 2832937 commit b9bb9d5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/pullbacks/svd.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,18 @@ function svd_pullback!(
8989
length(indS) == pS || throw(DimensionMismatch("length of selected S diagonals ($(length(indS))) does not match length of ΔS diagonal ($(length(ΔS)))"))
9090
view(diagview(UdΔAV), indS) .+= real.(ΔS)
9191
end
92-
ΔA .+= Ur * UdΔAV * Vᴴr # add the contribution to ΔA
92+
ΔA = mul!(ΔA, Ur, UdΔAV * Vᴴr, 1, 1) # add the contribution to ΔA
9393

9494
# Add the remaining contributions
9595
if m > r && !iszerotangent(ΔU) # remaining ΔU is already orthogonal to Ur
9696
Sp = view(S, indU)
9797
Vᴴp = view(Vᴴ, indU, :)
98-
ΔA .+= (ΔU ./ Sp') * Vᴴp
98+
ΔA = mul!(ΔA, ΔU ./ Sp', Vᴴp, 1, 1)
9999
end
100100
if n > r && !iszerotangent(ΔVᴴ) # remaining ΔV is already orthogonal to Vᴴr
101101
Sp = view(S, indV)
102102
Up = view(U, :, indV)
103-
ΔA .+= Up * (Sp .\ ΔVᴴ)
103+
ΔA = mul!(ΔA, Up, Sp .\ ΔVᴴ, 1, 1)
104104
end
105105
return ΔA
106106
end
@@ -174,7 +174,7 @@ function svd_trunc_pullback!(
174174
aVΔV = project_antihermitian!(VΔV)
175175

176176
# check whether cotangents arise from gauge-invariance objective function
177-
check_svd_cotangents(aUΔU, Sr, aVΔV; degeneracy_atol, gauge_atol)
177+
check_svd_cotangents(aUΔU, S, aVΔV; degeneracy_atol, gauge_atol)
178178

179179
UdΔAV = (aUΔU .+ aVΔV) .* inv_safe.(S' .- S, degeneracy_atol) .+
180180
(aUΔU .- aVΔV) .* inv_safe.(S' .+ S, degeneracy_atol)

0 commit comments

Comments
 (0)