Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/factorizations/truncation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ function MAK.findtruncated(values::SectorVector, strategy::TruncationByOrder)

# dimensions are all 1 so no need to account for weight
if FusionStyle(I) isa UniqueFusion
perm = partialsortperm(parent(values), 1:strategy.howmany; strategy.by, strategy.rev)
howmany = min(length(parent(values)), strategy.howmany)
perm = partialsortperm(parent(values), 1:howmany; strategy.by, strategy.rev)
result = similar(values, Bool)
fill!(parent(result), false)
parent(result)[perm] .= true
Expand Down
8 changes: 8 additions & 0 deletions test/tensors/factorizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ for V in spacelist
@test isisometric(U)
@test isisometric(Vᴴ; side = :right)

# when rank of t is already smaller than truncrank
t_rank = ceil(Int, min(dim(codomain(t)), dim(domain(t))))
U, S, Vᴴ, ϵ = @constinferred svd_trunc(t; trunc = truncrank(t_rank + 1))
@test U * S * Vᴴ ≈ t
@test ϵ ≈ 0
@test isisometric(U)
@test isisometric(Vᴴ; side = :right)

# dimension of S is a float for IsingBimodule
nvals = round(Int, dim(domain(S)) / 2)
trunc = truncrank(nvals)
Expand Down