@@ -1907,7 +1907,20 @@ function setindex!(
19071907 end
19081908 end
19091909
1910- ψA = MPST(A, sites; leftinds= lind, orthocenter= orthocenter - first(r) + 1 , kwargs... )
1910+ # use the first link index if present, otherwise use the default tag
1911+ linktags = TagSet[
1912+ (b = linkind(ψ, i);
1913+ isnothing(b) ? defaultlinkindtags(i) : tags(b)) for i in firstsite: (lastsite - 1 )
1914+ ]
1915+
1916+ ψA = MPST(
1917+ A,
1918+ sites;
1919+ leftinds= lind,
1920+ orthocenter= orthocenter - first(r) + 1 ,
1921+ tags= linktags,
1922+ kwargs... ,
1923+ )
19111924 # @assert prod(ψA) ≈ A
19121925
19131926 ψ[firstsite: lastsite] = ψA
@@ -1942,11 +1955,20 @@ by site according to the site indices `sites`.
19421955 in `sites` and `leftinds` will be dangling off of the right side of the MPS/MPO.
19431956- `orthocenter::Integer = length(sites)`: the desired final orthogonality
19441957 center of the output MPS/MPO.
1958+ - `tags = [defaultlinktags(i) for i in 1:(length(sites) - 1)]`:
1959+ the tags to use for the link indices. The length of `tags` must be
1960+ `length(sites) - 1`. The default is to use the default link tags for each
1961+ site.
19451962- `cutoff`: the desired truncation error at each link.
19461963- `maxdim`: the maximum link dimension.
19471964"""
19481965function (:: Type{MPST} )(
1949- A:: ITensor , sites; leftinds= nothing , orthocenter:: Integer = length(sites), kwargs...
1966+ A:: ITensor ,
1967+ sites;
1968+ leftinds= nothing ,
1969+ orthocenter:: Integer = length(sites),
1970+ tags= [defaultlinktags(i) for i in 1 : (length(sites) - 1 )],
1971+ kwargs... ,
19501972) where {MPST<: AbstractMPS }
19511973 N = length(sites)
19521974 for s in sites
@@ -1967,7 +1989,7 @@ function (::Type{MPST})(
19671989 if ! isnothing(l)
19681990 Lis = unioninds(Lis, l)
19691991 end
1970- L, R = factorize(Ã, Lis; kwargs... , tags= " Link,n= $n " , ortho= " left" )
1992+ L, R = factorize(Ã, Lis; kwargs... , tags= tags[n] , ortho= " left" )
19711993 l = commonind(L, R)
19721994 ψ[n] = L
19731995 Ã = R
0 commit comments