Skip to content

Commit 1f85308

Browse files
Jutholkdvos
andauthored
one more code suggestion
Co-authored-by: Lukas Devos <ldevos98@gmail.com>
1 parent 079838b commit 1f85308

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/pullbacks/svd.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ function check_and_prepare_svd_cotangents(
8181
ΔV₊ᴴ = nothing
8282
aVᴴΔV₁ = zero!(similar(V₁ᴴ, (r, r)))
8383
end
84-
mask = abs.(S₁' .- S₁) .< degeneracy_atol
85-
Δgauge = max(Δgauge, norm(view(aUᴴΔU₁, mask) + view(aVᴴΔV₁, mask), Inf))
84+
bc = Base.broadcasted(S₁', S₁, aUᴴΔU₁, aVᴴΔV₁) do s1, s2, u, v
85+
return abs(s1 - s2) < degeneracy_atol ? zero(u) + zero(v) : u + v
86+
end
87+
Δgauge = max(Δgauge, norm(bc, Inf))
8688

8789
if !iszerotangent(ΔSmat)
8890
ΔS = diagview(ΔSmat)

0 commit comments

Comments
 (0)