Skip to content
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ LinearAlgebra = "1.10.0"
Muscle = "0.3.9"
Networks = "0.2.3, 0.3.0"
PythonCall = "0.9"
QuantumTags = "0.4.0"
QuantumTags = "0.4.2"
Random = "1.10.0"
Reexport = "1.2.2"
Tangles = "0.2.7"
Expand Down
2 changes: 2 additions & 0 deletions src/CanonicalForm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Base.copy(x::BondCanonical) = BondCanonical(copy(x.orthog_center))
Base.:(==)(a::BondCanonical, b::BondCanonical) = a.orthog_center == b.orthog_center

orthog_center(x::BondCanonical) = x.orthog_center
min_orthog_center(x::BondCanonical) = min(orthog_center(x)...)
max_orthog_center(x::BondCanonical) = max(orthog_center(x)...)

"""
VidalGauge
Expand Down
52 changes: 51 additions & 1 deletion src/Components/MPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Base.length(tn::MPS) = nsites(tn) # as required by Stefano but do not use, as it

CanonicalForm(tn::MPS) = tn.form
function unsafe_setform!(tn::MPS, form)
@assert form isa NonCanonical || form isa MixedCanonical || form isa BondCanonical
@assert form isa NonCanonical || form isa MixedCanonical || form isa BondCanonical || form isa VidalGauge
tn.form = form
return tn
end
Expand Down Expand Up @@ -93,6 +93,56 @@ function MPS(arrays::AbstractVector{<:AbstractArray}; order=defaultorder(MPS)) #
return MPS(tn)
end

function MPS(::VidalGauge, Γ, Λ; order=defaultorder(MPS))
@assert ndims(Γ[1]) == 2 "First Γ array must have 2 dimensions"
@assert all(==(3) ∘ ndims, Γ[2:(end - 1)]) "Inner Γ arrays must have 3 dimensions"
@assert ndims(Γ[end]) == 2 "Last Γ array must have 2 dimensions"
@assert all(==(1) ∘ ndims, Λ) "Λ arrays must have 1 dimension"
if !issetequal(order, defaultorder(MPS))
throw(ArgumentError("order must be a permutation of $(String.(defaultorder(MPS)))"))
end

tn = GenericTensorNetwork()

for (i, λ) in enumerate(Λ)
_bond = bond"$i - $(i+1)"
_site = lambda"$i - $(i+1)"
_tensor = Tensor(λ, [Index(_bond)])
addtensor!(tn, _tensor)
setsite!(tn, _tensor, _site)
setbond!(tn, Index(_bond), _bond)
end

for (i, γ) in enumerate(Γ)
local_order = if i == 1
filter(x -> x != :l, order)
elseif i == length(Γ)
filter(x -> x != :r, order)
else
order
end

_inds = map(local_order) do dir
if dir == :o
Index(plug"$i")
elseif dir == :r
Index(bond"$i - $(i+1)")
elseif dir == :l
Index(bond"$(i-1) - $i")
else
throw(ArgumentError("Invalid direction: $dir"))
end
end |> collect
_tensor = Tensor(γ, _inds)
addtensor!(tn, _tensor)
setsite!(tn, _tensor, site"$i")
setplug!(tn, Index(plug"$i"), plug"$i")
# bonds already set by the Λ tensors
end

return MPS(tn, VidalGauge())
end

# TODO normalize as we canonize for numerical stability
# TODO different input/output physical dims
# TODO let choose the orthogonality center
Expand Down
204 changes: 0 additions & 204 deletions src/Components/VidalMPS.jl

This file was deleted.

Loading
Loading