From 98530ef03a4dc3cec3fde1eef50c42b1aef84632 Mon Sep 17 00:00:00 2001 From: leburgel Date: Wed, 30 Sep 2026 14:41:47 +0200 Subject: [PATCH 1/3] Fix `remove_svd_gauge_dependence!` for rank-deficient SVDs --- src/pullbacks/svd.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pullbacks/svd.jl b/src/pullbacks/svd.jl index 090012553..f22b675ca 100755 --- a/src/pullbacks/svd.jl +++ b/src/pullbacks/svd.jl @@ -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(Sdiag[1:r]) .- Sdiag[1:r]) .>= degeneracy_atol] .= 0 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):end]) else # the component of ΔU₂ along U₁ contains gauge-invariant information p = size(ΔU, 2) ΔU₂ = view(ΔU, :, (r + 1):p) @@ -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):end, :]) else # the component of ΔVᴴ₂ along Vᴴ₁ contains gauge-invariant information p = size(ΔVᴴ, 1) ΔVᴴ₂ = view(ΔVᴴ, (r + 1):p, :) From 73c4666a4fee6b2ff633a204ed4f4555fe5f6741 Mon Sep 17 00:00:00 2001 From: Lander Burgelman <39218680+leburgel@users.noreply.github.com> Date: Wed, 30 Sep 2026 20:59:34 +0200 Subject: [PATCH 2/3] Update src/pullbacks/svd.jl Co-authored-by: Lukas Devos --- src/pullbacks/svd.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pullbacks/svd.jl b/src/pullbacks/svd.jl index f22b675ca..9a091c5bc 100755 --- a/src/pullbacks/svd.jl +++ b/src/pullbacks/svd.jl @@ -342,7 +342,7 @@ function remove_svd_gauge_dependence!( Sdiag = diagview(S) gaugepart = mul!(U₁' * ΔU₁, Vᴴ₁, ΔVᴴ₁', true, true) gaugepart = project_antihermitian!(gaugepart) - gaugepart[abs.(transpose(Sdiag[1:r]) .- Sdiag[1:r]) .>= degeneracy_atol] .= 0 + gaugepart[abs.(transpose(view(Sdiag, 1:r)) .- view(Sdiag, 1:r)) .>= degeneracy_atol] .= 0 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 From 5afca7cc4e13bc9e935d7ab8452f85c570b41cca Mon Sep 17 00:00:00 2001 From: leburgel Date: Thu, 1 Oct 2026 08:23:51 +0200 Subject: [PATCH 3/3] Also replace two remaining `@view`s --- src/pullbacks/svd.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pullbacks/svd.jl b/src/pullbacks/svd.jl index 9a091c5bc..f3f13f5d9 100755 --- a/src/pullbacks/svd.jl +++ b/src/pullbacks/svd.jl @@ -346,7 +346,7 @@ function remove_svd_gauge_dependence!( 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!(@view ΔU[:, (r + 1):end]) + zero!(view(ΔU, :, (r + 1):size(ΔU, 2))) else # the component of ΔU₂ along U₁ contains gauge-invariant information p = size(ΔU, 2) ΔU₂ = view(ΔU, :, (r + 1):p) @@ -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!(@view Δ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, :)