Skip to content

Commit c7a3b00

Browse files
committed
Remove manual truncation error computation in favor of MatrixAlgebraKit.truncation_error
1 parent 7ea3b68 commit c7a3b00

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

src/utility/svd.jl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ function _svd_trunc!(
145145
trunc::TruncationStrategy,
146146
)
147147
U, S, V⁺ = svd_compact!(t; alg)
148-
Ũ, S̃, Ṽ⁺, truncerror = _truncate_compact((U, S, V⁺), trunc)
148+
Ũ, S̃, Ṽ⁺, ind = truncate(svd_trunc!, (U, S, V⁺), trunc)
149+
truncerror = MatrixAlgebraKit.truncation_error(diagview(S), ind)
149150

150151
# construct info NamedTuple
151152
condnum = cond(S)
@@ -155,18 +156,6 @@ function _svd_trunc!(
155156
return Ũ, S̃, Ṽ⁺, info
156157
end
157158

158-
# hacky way of computing the truncation error for current version of svd_trunc!
159-
# TODO: replace once TensorKit updates to new MatrixAlgebraKit which returns truncation error as well
160-
function _truncate_compact((U, S, V⁺), trunc::TruncationStrategy)
161-
if !(trunc isa NoTruncation) && !isempty(blocksectors(S))
162-
Ũ, S̃, Ṽ⁺ = truncate(svd_trunc!, (U, S, V⁺), trunc)[1]
163-
truncerror = sqrt(norm(S)^2 - norm(S̃)^2)
164-
return Ũ, S̃, Ṽ⁺, truncerror
165-
else
166-
return U, S, V⁺, zero(real(scalartype(S)))
167-
end
168-
end
169-
170159
"""
171160
$(TYPEDEF)
172161

0 commit comments

Comments
 (0)