Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
23 changes: 20 additions & 3 deletions src/abstractmps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,15 @@
end
end

ψA = MPST(A, sites; leftinds=lind, orthocenter=orthocenter - first(r) + 1, kwargs...)
linktags = [defaultlinktags(i) for i in firstsite:(lastsite - 1)]
ψA = MPST(

Check warning on line 1911 in src/abstractmps.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractmps.jl#L1910-L1911

Added lines #L1910 - L1911 were not covered by tests
A,
sites;
leftinds=lind,
orthocenter=orthocenter - first(r) + 1,
tags=linktags,
kwargs...,
)
#@assert prod(ψA) ≈ A

ψ[firstsite:lastsite] = ψA
Expand Down Expand Up @@ -1942,11 +1950,20 @@
in `sites` and `leftinds` will be dangling off of the right side of the MPS/MPO.
- `orthocenter::Integer = length(sites)`: the desired final orthogonality
center of the output MPS/MPO.
- `tags::Vector{TagSet} = [defaultlinktags(i) for i in 1:(length(sites) - 1)]`:
the tags to use for the link indices. The length of `tags` must be
`length(sites) - 1`. The default is to use the default link tags for each
site.
- `cutoff`: the desired truncation error at each link.
- `maxdim`: the maximum link dimension.
"""
function (::Type{MPST})(
A::ITensor, sites; leftinds=nothing, orthocenter::Integer=length(sites), kwargs...
A::ITensor,
sites;
leftinds=nothing,
orthocenter::Integer=length(sites),
tags::Vector{TagSet}=[defaultlinktags(i) for i in 1:(length(sites) - 1)],
kwargs...,
) where {MPST<:AbstractMPS}
N = length(sites)
for s in sites
Expand All @@ -1967,7 +1984,7 @@
if !isnothing(l)
Lis = unioninds(Lis, l)
end
L, R = factorize(Ã, Lis; kwargs..., tags="Link,n=$n", ortho="left")
L, R = factorize(Ã, Lis; kwargs..., tags=tags[n], ortho="left")

Check warning on line 1987 in src/abstractmps.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractmps.jl#L1987

Added line #L1987 was not covered by tests
l = commonind(L, R)
ψ[n] = L
à = R
Expand Down
12 changes: 12 additions & 0 deletions test/base/test_mps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,18 @@ end
end
end

@testset "movesites tags" begin
N = 4
s0 = siteinds("S=1/2", N)
ψ0 = random_mps(s0; linkdims=1)
for perm in permutations(1:N)
s = s0[perm]
ns′ = [findfirst(==(i), s0) for i in s]
ψ = movesites(ψ0, 1:N .=> ns′; cutoff=1e-15)
@test ITensorMPS.hasdefaultlinktags(ψ)
end
end

@testset "product(::Vector{ITensor}, ::MPS)" begin
N = 6
s = siteinds("Qubit", N)
Expand Down
Loading