1+ lq_rank (L; kwargs... ) = qr_rank (L; kwargs... )
2+
13function check_lq_cotangents (
2- L, Q, ΔL, ΔQ, minmn :: Int , p:: Int ;
4+ L, Q, ΔL, ΔQ, p:: Int ;
35 gauge_atol:: Real = default_pullback_gauge_atol (ΔQ)
46 )
7+ minmn = min (size (L, 1 ), size (Q, 2 ))
58 if minmn > p # case where A is rank-deficient
69 Δgauge = abs (zero (eltype (Q)))
710 if ! iszerotangent (ΔQ)
811 # in this case the number Householder reflections will
912 # change upon small variations, and all of the remaining
10- # columns of ΔQ should be zero for a gauge-invariant
13+ # rows of ΔQ should be zero for a gauge-invariant
1114 # cost function
1215 ΔQ2 = view (ΔQ, (p + 1 ): size (Q, 1 ), :)
13- Δgauge = max (Δgauge, norm (ΔQ2))
16+ Δgauge_Q = norm (ΔQ2, Inf )
17+ Δgauge = max (Δgauge, Δgauge_Q)
1418 end
1519 if ! iszerotangent (ΔL)
1620 ΔL22 = view (ΔL, (p + 1 ): size (L, 1 ), (p + 1 ): minmn)
17- Δgauge = max (Δgauge, norm (ΔL22))
21+ Δgauge_L = norm (ΔL22, Inf )
22+ Δgauge = max (Δgauge, Δgauge_L)
1823 end
1924 Δgauge ≤ gauge_atol ||
2025 @warn " `lq` cotangents sensitive to gauge choice: (|Δgauge| = $Δgauge )"
2126 end
2227 return
2328end
2429
25- function check_lq_full_cotangents (Q1, ΔQ2, ΔQ2Q1ᴴ; gauge_atol:: Real = default_pullback_gauge_atol (Q1 ))
30+ function check_lq_full_cotangents (Q1, ΔQ2, ΔQ2Q1ᴴ; gauge_atol:: Real = default_pullback_gauge_atol (ΔQ2 ))
2631 # in the case where A is full rank, but there are more columns in Q than in A
2732 # (the case of `lq_full`), there is gauge-invariant information in the
2833 # projection of ΔQ2 onto the column space of Q1, by virtue of Q being a unitary
@@ -32,7 +37,7 @@ function check_lq_full_cotangents(Q1, ΔQ2, ΔQ2Q1ᴴ; gauge_atol::Real = defaul
3237 # Q2' * ΔQ2 as a gauge dependent quantity.
3338 Δgauge = norm (mul! (copy (ΔQ2), ΔQ2Q1ᴴ, Q1, - 1 , 1 ), Inf )
3439 Δgauge ≤ gauge_atol ||
35- @warn " `lq ` cotangents sensitive to gauge choice: (|Δgauge| = $Δgauge )"
40+ @warn " `lq_full ` cotangents sensitive to gauge choice: (|Δgauge| = $Δgauge )"
3641 return
3742end
3843
@@ -62,9 +67,7 @@ function lq_pullback!(
6267 L, Q = LQ
6368 m = size (L, 1 )
6469 n = size (Q, 2 )
65- minmn = min (m, n)
66- Ld = diagview (L)
67- p = @something findlast (>= (rank_atol) ∘ abs, Ld) 0
70+ p = lq_rank (L; rank_atol)
6871
6972 ΔL, ΔQ = ΔLQ
7073
@@ -74,7 +77,7 @@ function lq_pullback!(
7477 ΔA1 = view (ΔA, 1 : p, :)
7578 ΔA2 = view (ΔA, (p + 1 ): m, :)
7679
77- check_lq_cotangents (L, Q, ΔL, ΔQ, minmn, p; gauge_atol)
80+ check_lq_cotangents (L, Q, ΔL, ΔQ, p; gauge_atol)
7881
7982 ΔQ̃ = zero! (similar (Q, (p, n)))
8083 if ! iszerotangent (ΔQ)
0 commit comments