Skip to content

Commit 196cee1

Browse files
committed
add truncation error implementation
1 parent e26ce89 commit 196cee1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/factorizations/truncation.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,17 @@ function MAK.findtruncated_svd(values::SectorDict, strategy::TruncationIntersect
242242
) for c in intersect(map(keys, inds)...)
243243
)
244244
end
245+
246+
# Truncation error
247+
# ----------------
248+
MAK.truncation_error(values::SectorDict, ind) =
249+
MAK.truncation_error!(SectorDict(c => copy(v) for (c, v) in values), ind)
250+
251+
function MAK.truncation_error!(values::SectorDict, ind)
252+
for (c, v) in values
253+
ind_c = get(ind, c, nothing)
254+
isnothing(ind_c) && continue
255+
v[ind_c] .= zero(eltype(v))
256+
end
257+
return TensorKit._norm(values, 2, zero(real(eltype(valtype(values)))))
258+
end

0 commit comments

Comments
 (0)