Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/pullbacks/svd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ function remove_svd_gauge_dependence!(
Sdiag = diagview(S)
gaugepart = mul!(U₁' * ΔU₁, Vᴴ₁, ΔVᴴ₁', true, true)
gaugepart = project_antihermitian!(gaugepart)
gaugepart[abs.(transpose(Sdiag) .- Sdiag) .>= degeneracy_atol] .= 0
gaugepart[abs.(transpose(view(Sdiag, 1:r)) .- view(Sdiag, 1:r)) .>= degeneracy_atol] .= 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have had an S₁ = view(Sdiag, 1:r) definition and use this here, but it's fine like this.

mul!(ΔU₁, U₁, gaugepart, -1, 1)
if size(ΔU, 2) > r
if r < length(Sdiag) # rank-deficient case, no stable information can be extracted from extra columns of U
zero!(ΔU[:, (r + 1):end])
zero!(view(ΔU, :, (r + 1):size(ΔU, 2)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was quite stupid indeed 😄 .

else # the component of ΔU₂ along U₁ contains gauge-invariant information
p = size(ΔU, 2)
ΔU₂ = view(ΔU, :, (r + 1):p)
Expand All @@ -356,7 +356,7 @@ function remove_svd_gauge_dependence!(
end
if size(ΔVᴴ, 1) > r
if r < length(Sdiag) # rank-deficient case, no stable information can be extracted from extra rows of Vᴴ
zero!(ΔVᴴ[(r + 1):end, :])
zero!(view(ΔVᴴ, (r + 1):size(ΔVᴴ, 1), :))
else # the component of ΔVᴴ₂ along Vᴴ₁ contains gauge-invariant information
p = size(ΔVᴴ, 1)
ΔVᴴ₂ = view(ΔVᴴ, (r + 1):p, :)
Expand Down
Loading