201201 ΔA, A, USVᴴ, ΔUSVᴴ;
202202 rank_atol::Real = default_pullback_rank_atol(USVᴴ[2]),
203203 degeneracy_atol::Real = default_pullback_rank_atol(USVᴴ[2]),
204- gauge_atol::Real = default_pullback_gauge_atol(ΔUSVᴴ...)
204+ gauge_atol::Real = default_pullback_gauge_atol(ΔUSVᴴ...),
205+ cg_rtol::Real = eps(real(eltype(ΔA)))^(3 / 4)
205206 )
206207
207208Adds the pullback from the truncated SVD of `A` to `ΔA`, given the output `USVᴴ` and the
@@ -217,12 +218,16 @@ singular values (not included in `S`) are (sufficiently) smaller than those in `
217218A warning will be printed if the cotangents are not gauge-invariant, i.e. if the
218219anti-hermitian part of `U' * ΔU + Vᴴ * ΔVᴴ'`, restricted to rows `i` and columns `j` for
219220which `abs(S[i] - S[j]) < degeneracy_atol`, is not small compared to `gauge_atol`.
221+
222+ The contribution from outside the kept singular vectors is solved by conjugate gradients, to
223+ an error of about `cg_rtol` relative to its right-hand side.
220224"""
221225function svd_trunc_pullback! (
222226 ΔA:: AbstractMatrix , A, USVᴴ, ΔUSVᴴ;
223227 rank_atol:: Real = 0 ,
224228 degeneracy_atol:: Real = default_pullback_rank_atol (USVᴴ[2 ]),
225229 gauge_atol:: Real = default_pullback_gauge_atol (ΔUSVᴴ... ),
230+ cg_rtol:: Real = eps (real (eltype (ΔA)))^ (3 / 4 ),
226231 maxiter:: Int = 10 * minimum (size (ΔA)) # conjugate-gradient iterations
227232 )
228233 # Extract the SVD components
@@ -260,7 +265,7 @@ function svd_trunc_pullback!(
260265 APᴴZ = similar (X, n, p) # for applying AP AP' without forming it
261266 X = hermitian_stein_cg! (
262267 X, (GZ, Z) -> mul! (GZ, AP, mul! (view (APᴴZ, :, axes (Z, 2 )), AP' , Z)), () -> AP * AP' ,
263- S⁻¹ .^ 2 , degeneracy_atol , maxiter;
268+ S⁻¹ .^ 2 , cg_rtol * norm (X) , maxiter;
264269 cost_apply = 2 * m * n, cost_apply_formed = m^ 2 , cost_form = m^ 2 * n
265270 )
266271 Yᴴ = lmul! (Diagonal (S⁻¹), X' * AP)
@@ -273,7 +278,7 @@ function svd_trunc_pullback!(
273278 APZ = similar (Y, m, p) # for applying AP' AP without forming it
274279 Y = hermitian_stein_cg! (
275280 Y, (GZ, Z) -> mul! (GZ, AP' , mul! (view (APZ, :, axes (Z, 2 )), AP, Z)), () -> AP' * AP,
276- S⁻¹ .^ 2 , degeneracy_atol , maxiter;
281+ S⁻¹ .^ 2 , cg_rtol * norm (Y) , maxiter;
277282 cost_apply = 2 * m * n, cost_apply_formed = n^ 2 , cost_form = n^ 2 * m
278283 )
279284 X = rmul! (AP * Y, Diagonal (S⁻¹))
0 commit comments