|
1 | | -# Inputs |
| 1 | +# Input |
2 | 2 | # ------ |
3 | 3 | copy_input(::typeof(svd_full), A::AbstractMatrix) = copy!(similar(A, float(eltype(A))), A) |
4 | 4 | copy_input(::typeof(svd_compact), A) = copy_input(svd_full, A) |
@@ -362,15 +362,16 @@ function svd_trunc!(A::AbstractMatrix, USVᴴ, alg::TruncatedAlgorithm{<:GPU_Ran |
362 | 362 | U, S, Vᴴ = USVᴴ |
363 | 363 | _gpu_Xgesvdr!(A, S.diag, U, Vᴴ; alg.alg.kwargs...) |
364 | 364 |
|
365 | | - do_gauge_fix = get(alg.alg.kwargs, :gaugefix, default_gaugefix())::Bool |
366 | | - do_gauge_fix && gaugefix!(svd_trunc!, U, Vᴴ) |
367 | | - |
368 | 365 | # TODO: make sure that truncation is based on maxrank, otherwise this might be wrong |
369 | | - USVᴴtrunc, ind = truncate(svd_trunc!, (U, S, Vᴴ), alg.trunc) |
370 | | - Strunc = diagview(USVᴴtrunc[2]) |
| 366 | + (Utr, Str, Vᴴtr), _ = truncate(svd_trunc!, (U, S, Vᴴ), alg.trunc) |
| 367 | + |
371 | 368 | # normal `truncation_error!` does not work here since `S` is not the full singular value spectrum |
372 | | - ϵ = sqrt(norm(A)^2 - norm(Strunc)^2) # is there a more accurate way to do this? |
373 | | - return USVᴴtrunc..., ϵ |
| 369 | + ϵ = sqrt(norm(A)^2 - norm(diagview(Str))^2) # is there a more accurate way to do this? |
| 370 | + |
| 371 | + do_gauge_fix = get(alg.alg.kwargs, :gaugefix, default_gaugefix())::Bool |
| 372 | + do_gauge_fix && gaugefix!(svd_trunc!, Utr, Vᴴtr) |
| 373 | + |
| 374 | + return Utr, Str, Vᴴtr, ϵ |
374 | 375 | end |
375 | 376 |
|
376 | 377 | function svd_compact!(A::AbstractMatrix, USVᴴ, alg::GPU_SVDAlgorithm) |
|
0 commit comments