@@ -12,9 +12,10 @@ function check_and_prepare_svd_cotangents(
1212 U₁ = view (U, :, 1 : r)
1313 V₁ᴴ = view (Vᴴ, 1 : r, :)
1414 S₁ = view (S, 1 : r)
15- indU = axes (U, 2 )[ind]
16- indV = axes (Vᴴ, 1 )[ind]
17- indS = axes (S, 1 )[ind]
15+
16+ indU = select_indices (axes (U, 2 ), ind)
17+ indV = select_indices (axes (Vᴴ, 1 ), ind)
18+ indS = select_indices (axes (S, 1 ), ind)
1819 Δgauge = zero (eltype (S))
1920
2021 # Only the columns ind₀ ⊆ 1:r of UᴴΔAV are computed.
@@ -80,7 +81,7 @@ function check_and_prepare_svd_cotangents(
8081 aVᴴΔV₁₀ = zero! (similar (V₁ᴴ, (r, k)))
8182 end
8283
83- S₀ = view (S, ind₀)
84+ S₀ = S[ ind₀] # view fails broadcasting below on GPU
8485 hUᴴΔAV₁₀ = (aUᴴΔU₁₀ .+ aVᴴΔV₁₀) .* inv_safe .(transpose (S₀) .- S₁, degeneracy_atol) # hermitian part of UᴴΔAV, restricted to rows 1:r and columns ind₀
8586 aUᴴΔAV₁₀ = (aUᴴΔU₁₀ .- aVᴴΔV₁₀) .* inv_safe .(transpose (S₀) .+ S₁, degeneracy_atol) # antihermitian part of UᴴΔAV, restricted to rows 1:r and columns ind₀
8687
@@ -90,7 +91,7 @@ function check_and_prepare_svd_cotangents(
9091 if ! iszerotangent (ΔSmat)
9192 ΔS = diagview (ΔSmat)
9293 length (indS) == length (ΔS) || throw (DimensionMismatch (lazy " length of selected S values ($(length(indS))) does not match length of ΔS ($(length(ΔS)))" ))
93- diagview (view (hUᴴΔAV₁₀, ind₀, :)) .+ = real .(view (ΔS, J₁)) # the diagonal entries
94+ diagview (view (hUᴴΔAV₁₀, ind₀, :)) .+ = real .(view (ΔS, J₁)) # diagonal entries
9495 Δgauge = max (Δgauge, maximum (abs, view (ΔS, J₂); init = zero (Δgauge)))
9596 end
9697
0 commit comments