Skip to content

Commit 98530ef

Browse files
committed
Fix remove_svd_gauge_dependence! for rank-deficient SVDs
1 parent c3cf149 commit 98530ef

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/pullbacks/svd.jl‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ function remove_svd_gauge_dependence!(
342342
Sdiag = diagview(S)
343343
gaugepart = mul!(U₁' * ΔU₁, Vᴴ₁, ΔVᴴ₁', true, true)
344344
gaugepart = project_antihermitian!(gaugepart)
345-
gaugepart[abs.(transpose(Sdiag) .- Sdiag) .>= degeneracy_atol] .= 0
345+
gaugepart[abs.(transpose(Sdiag[1:r]) .- Sdiag[1:r]) .>= degeneracy_atol] .= 0
346346
mul!(ΔU₁, U₁, gaugepart, -1, 1)
347347
if size(ΔU, 2) > r
348348
if r < length(Sdiag) # rank-deficient case, no stable information can be extracted from extra columns of U
349-
zero!(ΔU[:, (r + 1):end])
349+
zero!(@view ΔU[:, (r + 1):end])
350350
else # the component of ΔU₂ along U₁ contains gauge-invariant information
351351
p = size(ΔU, 2)
352352
ΔU₂ = view(ΔU, :, (r + 1):p)
@@ -356,7 +356,7 @@ function remove_svd_gauge_dependence!(
356356
end
357357
if size(ΔVᴴ, 1) > r
358358
if r < length(Sdiag) # rank-deficient case, no stable information can be extracted from extra rows of Vᴴ
359-
zero!(ΔVᴴ[(r + 1):end, :])
359+
zero!(@view ΔVᴴ[(r + 1):end, :])
360360
else # the component of ΔVᴴ₂ along Vᴴ₁ contains gauge-invariant information
361361
p = size(ΔVᴴ, 1)
362362
ΔVᴴ₂ = view(ΔVᴴ, (r + 1):p, :)

0 commit comments

Comments
 (0)