@@ -630,7 +630,7 @@ Perform a factorization of `A` into ITensors `L` and `R` such that `A ≈ L * R`
630
630
631
631
For truncation arguments, see: [`svd`](@ref)
632
632
"""
633
- function factorize (A:: ITensor , Linds... ; kwargs... )
633
+ function factorize (A:: ITensor , Linds... ; maxdim = nothing , kwargs... )
634
634
ortho:: String = get (kwargs, :ortho , " left" )
635
635
tags:: TagSet = get (kwargs, :tags , " Link,fact" )
636
636
plev:: Int = get (kwargs, :plev , 0 )
@@ -661,9 +661,14 @@ function factorize(A::ITensor, Linds...; kwargs...)
661
661
# Determines when to use eigen vs. svd (eigen is less precise,
662
662
# so eigen should only be used if a larger cutoff is requested)
663
663
automatic_cutoff = 1e-12
664
- Lis = indices (Linds... )
665
- dL, dR = dim (Lis), dim (indices (setdiff (inds (A), Lis)))
666
- maxdim = get (kwargs, :maxdim , min (dL, dR))
664
+ Lis = commoninds (A, indices (Linds... ))
665
+ Ris = uniqueinds (A, Lis)
666
+ dL, dR = dim (Lis), dim (Ris)
667
+ # maxdim is forced to be at most the max given SVD
668
+ if isnothing (maxdim)
669
+ maxdim = min (dL, dR)
670
+ end
671
+ maxdim = min (maxdim, min (dL, dR))
667
672
might_truncate = ! isnothing (cutoff) || maxdim < min (dL, dR)
668
673
669
674
if isnothing (which_decomp)
@@ -677,13 +682,13 @@ function factorize(A::ITensor, Linds...; kwargs...)
677
682
end
678
683
679
684
if which_decomp == " svd"
680
- LR = factorize_svd (A, Linds... ; kwargs... )
685
+ LR = factorize_svd (A, Linds... ; kwargs... , maxdim = maxdim )
681
686
if isnothing (LR)
682
687
return nothing
683
688
end
684
689
L, R, spec = LR
685
690
elseif which_decomp == " eigen"
686
- L, R, spec = factorize_eigen (A, Linds... ; kwargs... )
691
+ L, R, spec = factorize_eigen (A, Linds... ; kwargs... , maxdim = maxdim )
687
692
elseif which_decomp == " qr"
688
693
L, R = factorize_qr (A, Linds... ; kwargs... )
689
694
spec = Spectrum (nothing , 0.0 )
0 commit comments