Skip to content

Commit 7c7a6a0

Browse files
committed
fix truncrank when no value is truncated
1 parent 9d5c34d commit 7c7a6a0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/factorizations/truncation.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,13 @@ function MAK.findtruncated_svd(values::SectorDict, strategy::TruncationByOrder)
165165
I = keytype(values)
166166
truncdim = SectorDict{I, Int}(c => length(d) for (c, d) in values)
167167
totaldim = sum(dim(c) * d for (c, d) in truncdim; init = 0)
168-
while true
168+
while totaldim > strategy.howmany
169169
next = _findnexttruncvalue(values, truncdim; strategy.by, strategy.rev)
170170
isnothing(next) && break
171171
_, cmin = next
172172
truncdim[cmin] -= 1
173173
totaldim -= dim(cmin)
174174
truncdim[cmin] == 0 && delete!(truncdim, cmin)
175-
totaldim <= strategy.howmany && break
176175
end
177176
return SectorDict(c => Base.OneTo(d) for (c, d) in truncdim)
178177
end

0 commit comments

Comments
 (0)