File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ is real and positive.
1010
1111# Helper functions
1212_argmaxabs (x) = reduce (_largest, x; init = zero (eltype (x)))
13- _largest (x, y) = abs (x) < abs (y) ? y : x
13+ _largest (x:: Real , y:: Real ) = abs (x) < abs (y) ? y : x
14+ _largest (x:: Complex , y:: Complex ) = abs2 (x) < abs2 (y) ? y : x
1415
1516function gaugefix! (:: typeof (qr_householder!), Q, R, Rd)
1617 ax = Base. OneTo (length (Rd))
6768
6869function gaugefix! (:: Union{typeof(svd_compact!), typeof(svd_trunc!)} , U, Vᴴ)
6970 @assert axes (U, 2 ) == axes (Vᴴ, 1 )
70- for j in axes (U, 2 )
71- u = view (U, :, j)
72- v = view (Vᴴ, j, :)
73- s = sign (_argmaxabs (u))
74- u .*= conj (s)
75- v .*= s
76- end
71+ signs = reduce (_largest, U; dims = 1 , init = zero (eltype (U)))
72+ @. signs = sign (signs)
73+ signs_t = transpose (signs)
74+ @. U = U * conj (signs)
75+ @. Vᴴ = signs_t * Vᴴ
7776 return (U, Vᴴ)
7877end
You can’t perform that action at this time.
0 commit comments