Skip to content

Commit c050c64

Browse files
authored
Merge pull request #368 from QuantumKitHub/zy/truncrank-fix
2 parents 194a66b + 9f4a339 commit c050c64

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/factorizations/truncation.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ function MAK.findtruncated(values::SectorVector, strategy::TruncationByOrder)
171171

172172
# dimensions are all 1 so no need to account for weight
173173
if FusionStyle(I) isa UniqueFusion
174-
perm = partialsortperm(parent(values), 1:strategy.howmany; strategy.by, strategy.rev)
174+
howmany = min(length(parent(values)), strategy.howmany)
175+
perm = partialsortperm(parent(values), 1:howmany; strategy.by, strategy.rev)
175176
result = similar(values, Bool)
176177
fill!(parent(result), false)
177178
parent(result)[perm] .= true

test/tensors/factorizations.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ for V in spacelist
254254
@test isisometric(U)
255255
@test isisometric(Vᴴ; side = :right)
256256

257+
# when rank of t is already smaller than truncrank
258+
t_rank = ceil(Int, min(dim(codomain(t)), dim(domain(t))))
259+
U, S, Vᴴ, ϵ = @constinferred svd_trunc(t; trunc = truncrank(t_rank + 1))
260+
@test U * S * Vᴴ t
261+
@test ϵ 0
262+
@test isisometric(U)
263+
@test isisometric(Vᴴ; side = :right)
264+
257265
# dimension of S is a float for IsingBimodule
258266
nvals = round(Int, dim(domain(S)) / 2)
259267
trunc = truncrank(nvals)

0 commit comments

Comments
 (0)