Skip to content

Commit d81830e

Browse files
committed
add utility fullrank for spaces
1 parent 0434a44 commit d81830e

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/states/abstractmps.jl

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,11 @@ Determine whether the given tensor is full rank, i.e. whether both the map from
9393
virtual space and the physical space to the right virtual space, and the map from the right
9494
virtual space and the physical space to the left virtual space are injective.
9595
"""
96-
function isfullrank(A::GenericMPSTensor; side = :both)
97-
Vₗ = _firstspace(A)
98-
Vᵣ = _lastspace(A)
99-
P = (space.(Ref(A), 2:(numind(A) - 1))...)
96+
isfullrank(A::GenericMPSTensor; kwargs...) = isfullrank(space(A); kwargs...)
97+
function isfullrank(V::TensorKit.TensorMapSpace; side = :both)
98+
Vₗ = V[1]
99+
Vᵣ = V[numind(V)]
100+
P = (getindex.(Ref(V), 2:(numind(V) - 1))...)
100101
return if side === :both
101102
Vₗ P Vᵣ' && Vₗ' P Vᵣ
102103
elseif side === :right
@@ -129,6 +130,29 @@ function makefullrank!(A::PeriodicVector{<:GenericMPSTensor}; alg = Defaults.alg
129130
return A
130131
end
131132

133+
function makefullrank!(virtualspaces::PeriodicVector{S}, physicalspaces::PeriodicVector{S}) where {S <: ElementarySpace}
134+
haschanged = true
135+
while haschanged
136+
haschanged = false
137+
for i in 1:length(virtualspaces)
138+
Vmax = fuse(physicalspaces[i - 1], virtualspaces[i - 1])
139+
if !(virtualspaces[i] Vmax)
140+
virtualspaces[i] = infimum(virtualspaces[i], Vmax)
141+
haschanged = true
142+
end
143+
end
144+
for i in reverse(1:length(virtualspaces))
145+
Vmax = fuse(dual(physicalspaces[i]), virtualspaces[i])
146+
if !(virtualspaces[i - 1] Vmax)
147+
virtualspaces[i - 1] = infimum(virtualspaces[i - 1], Vmax)
148+
haschanged = true
149+
end
150+
end
151+
end
152+
153+
return virtualspaces
154+
end
155+
132156
# Tensor accessors
133157
# ----------------
134158
@doc """

0 commit comments

Comments
 (0)