|
1 | 1 | module MatrixAlgebraKitGenericLinearAlgebraExt |
2 | 2 |
|
3 | 3 | using MatrixAlgebraKit |
4 | | -using MatrixAlgebraKit: sign_safe, check_input, diagview |
| 4 | +using MatrixAlgebraKit: sign_safe, check_input, diagview, gaugefix! |
5 | 5 | using GenericLinearAlgebra: svd!, svdvals!, eigen!, eigvals!, Hermitian, qr! |
6 | 6 | using LinearAlgebra: I, Diagonal, lmul! |
7 | 7 |
|
|
16 | 16 | function MatrixAlgebraKit.svd_compact!(A::AbstractMatrix, USVᴴ, ::GLA_QRIteration) |
17 | 17 | F = svd!(A) |
18 | 18 | U, S, Vᴴ = F.U, Diagonal(F.S), F.Vt |
19 | | - return MatrixAlgebraKit.gaugefix!(svd_compact!, U, S, Vᴴ, size(A)...) |
| 19 | + |
| 20 | + dogaugefix = get(alg.kwargs, :gaugefix, true)::Bool |
| 21 | + dogaugefix && gaugefix!(svd_compact!, U, Vᴴ) |
| 22 | + |
| 23 | + return U, S, Vᴴ |
20 | 24 | end |
21 | 25 |
|
22 | 26 | function MatrixAlgebraKit.svd_full!(A::AbstractMatrix, USVᴴ, ::GLA_QRIteration) |
23 | 27 | F = svd!(A; full = true) |
24 | 28 | U, Vᴴ = F.U, F.Vt |
25 | 29 | S = MatrixAlgebraKit.zero!(similar(F.S, (size(U, 2), size(Vᴴ, 1)))) |
26 | 30 | diagview(S) .= F.S |
27 | | - return MatrixAlgebraKit.gaugefix!(svd_full!, U, S, Vᴴ, size(A)...) |
| 31 | + |
| 32 | + dogaugefix = get(alg.kwargs, :gaugefix, true)::Bool |
| 33 | + dogaugefix && gaugefix!(svd_full!, U, Vᴴ) |
| 34 | + |
| 35 | + return U, S, Vᴴ |
28 | 36 | end |
29 | 37 |
|
30 | 38 | function MatrixAlgebraKit.svd_vals!(A::AbstractMatrix, S, ::GLA_QRIteration) |
|
0 commit comments