11struct NoExpand <: Algorithm end
22
33function changebonds_left (AL, Cs, alg; kwargs... )
4+ @info " Old size: $(dim (right_virtualspace (AL))) "
45 AL, Cs = changebonds (; expand_rightspace = AL, embed_leftspace = Cs, alg, kwargs... )[[2 ,end ]]
5- return Cs, AL
6+ @info " New size: $(dim (right_virtualspace (AL))) "
7+ return AL, Cs
68end
79function changebonds_right (Cs, AR, alg; kwargs... )
810 Cs, AR = changebonds (; expand_leftspace = AR, embed_rightspace = Cs, alg, kwargs... )[[1 ,4 ]]
@@ -29,28 +31,34 @@ function changebonds(;
2931 expansion_leftspace, expansion_rightspace
3032 )
3133end
32- const MissingOrTuple = Union{Missing, Tuple{ <: Any } }
34+ const MissingOrTuple = Union{Missing, <: Tuple }
3335function changebonds (
3436 embed_rightspace:: MissingOrTuple , expand_rightspace, embed_both:: MissingOrTuple , expand_leftspace, embed_leftspace:: MissingOrTuple , alg;
3537 expansion_leftspace, expansion_rightspace
3638 )
3739 if ! ismissing (expand_rightspace)
38- expand_rightspace = _expand_leftisometry (expand_rightspace, alg, expansion_leftspace)
39- if ! ismissing (embed_rightspace)
40- embed_rightspace = (_embed_left_space (expand_rightspace, A, alg) for A in embed_rightspace)
41- end
42- if ! ismissing (embed_both)
43- embed_both = (_embed_left_space (expand_rightspace, A, alg) for A in embed_both)
40+ expand_rightspace_new = _expand_leftisometry (expand_rightspace, alg, expansion_leftspace)
41+ if space (expand_rightspace) != space (expand_rightspace_new) || true
42+ if ! ismissing (embed_leftspace)
43+ embed_leftspace = (_embed_left_space (expand_rightspace_new, A, alg) for A in embed_leftspace)
44+ end
45+ if ! ismissing (embed_both)
46+ embed_both = (_embed_left_space (expand_rightspace_new, A, alg) for A in embed_both)
47+ end
4448 end
49+ expand_rightspace = expand_rightspace_new
4550 end
4651 if ! ismissing (expand_leftspace)
47- expand_leftspace = _expand_rightisometry (expand_leftspace, alg, expansion_rightspace)
48- if ! ismissing (embed_leftspace)
49- embed_leftspace = (_embed_right_space (A, expand_leftspace, alg) for A in embed_leftspace)
50- end
51- if ! ismissing (embed_both)
52- embed_both = (_embed_right_space (A, expand_leftspace, alg) for A in embed_both)
52+ expand_leftspace_new = _expand_rightisometry (expand_leftspace, alg, expansion_rightspace)
53+ if space (expand_leftspace) != space (expand_leftspace_new) || true
54+ if ! ismissing (embed_rightspace)
55+ embed_rightspace = (_embed_right_space (A, expand_leftspace_new, alg) for A in embed_rightspace)
56+ end
57+ if ! ismissing (embed_both)
58+ embed_both = (_embed_right_space (A, expand_leftspace_new, alg) for A in embed_both)
59+ end
5360 end
61+ expand_leftspace = expand_leftspace_new
5462 end
5563 return embed_rightspace, expand_rightspace, embed_both, expand_leftspace, embed_leftspace
5664end
@@ -65,7 +73,8 @@ function sup_inf_space(ac2)
6573 return supremum (VL, VR) ⊖ infimum (VL, VR)
6674end
6775function _sample_space (space, sup, trscheme)
68- return sample_space (infimum (space, sup), trscheme)
76+ sp = ismissing (sup) ? space : infimum (space, sup)
77+ return sample_space (sp, trscheme)
6978end
7079function _expand_leftisometry (A:: MPSTensor , alg, expansion_leftspace)
7180 VL = left_null (A)
@@ -109,3 +118,14 @@ function _embed_right_space(Anext::MPSTensor, A::AbstractTensorMap, alg)
109118 Anext′ = TensorKit. absorb! (Anext′, Anext)
110119 return Anext′
111120end
121+
122+
123+ extract_sector_types (:: Type{GradedSpace{S,D}} ) where {S<: Sector ,D} = (S,)
124+ extract_sector_types (:: Type{GradedSpace{ProductSector{T},D}} ) where {T<: Tuple ,D} = Tuple (T. parameters)
125+ extract_sector_types (sp:: GradedSpace ) = extract_sector_types (typeof (sp))
126+ function generate_sampling_space (psi:: MPSKit.AbstractMPS , cutoff:: Integer = 100 )
127+ sp = physicalspace (psi. AL[1 ])
128+ x = extract_sector_types (sp)
129+ iterator = Iterators. product ((Iterators. take (values (T),cutoff) for T in x). .. )
130+ return typeof (sp)([T=> 1 for T in iterator])
131+ end
0 commit comments